From nobody Mon Sep 8 23:56:00 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFDA6C64ED6 for ; Sun, 26 Feb 2023 16:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjBZQEO (ORCPT ); Sun, 26 Feb 2023 11:04:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjBZQEB (ORCPT ); Sun, 26 Feb 2023 11:04:01 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C62E2125A7; Sun, 26 Feb 2023 08:03:49 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.169]) by gnuweeb.org (Postfix) with ESMTPSA id 08155831B7; Sun, 26 Feb 2023 16:03:44 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1677427429; bh=Yo1+jDAmCINsAVjB6QZIr6c2SpALyJNJSdY2CPV6JsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mgtuJhCTdxodogoH8lRiLcqjlFTtteVvB/jjKwArR69BaLharsOanmHPiZ3ArTXmh QzwuZWzCOGdEo6E+nuEfed+KHxc3/P2CeFWPZ9Ietfu2xSSG2bzOlW5aJ1A5A7XbUw C5mhDR+kI4p9WNy914pLnJL9fwK4rM7HadEa+x/V27VQjYjWcy7m+RDNoz436YZel1 y5r7CMRTvlxLKHjNkHNUCr+vG6eW22W3TLJU54wjg7tCkXWmZoDXVaD4PmT95w/7cD o7xAJ1U2YKYS0CHOCe+JK9uvIAg3zTZtWAxNKTH1e3klc2wNK7faplAATa14fJly8p oGq+GVZUXmNKw== From: Ammar Faizi To: Chris Mason , Josef Bacik , David Sterba , Tejun Heo Cc: Ammar Faizi , Lai Jiangshan , Filipe Manana , Linux Btrfs Mailing List , Linux Kernel Mailing List , Linux Fsdevel Mailing List , GNU/Weeb Mailing List Subject: [RFC PATCH v1 6/6] btrfs: Add `BTRFS_DEFAULT_MAX_THREAD_POOL_SIZE` macro Date: Sun, 26 Feb 2023 23:02:59 +0700 Message-Id: <20230226160259.18354-7-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230226160259.18354-1-ammarfaizi2@gnuweeb.org> References: <20230226160259.18354-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently, the default max thread pool size is hardcoded as 8. This number is not only used in one place. Keep the default max thread pool size in sync by introducing a new macro. Signed-off-by: Ammar Faizi --- fs/btrfs/async-thread.h | 2 ++ fs/btrfs/disk-io.c | 3 ++- fs/btrfs/super.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h index 2b8a76fa75ef9e69..f11c3b36568053be 100644 --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h @@ -9,6 +9,8 @@ =20 #include =20 +#define BTRFS_DEFAULT_MAX_THREAD_POOL_SIZE 8 + struct btrfs_fs_info; struct btrfs_workqueue; struct btrfs_work; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1bb1db461a30fa71..4f4ddc8e088b08ec 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2957,7 +2957,8 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) btrfs_init_ref_verify(fs_info); =20 fs_info->thread_pool_size =3D min_t(unsigned long, - num_online_cpus() + 2, 8); + num_online_cpus() + 2, + BTRFS_DEFAULT_MAX_THREAD_POOL_SIZE); =20 INIT_LIST_HEAD(&fs_info->ordered_roots); spin_lock_init(&fs_info->ordered_root_lock); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 34b7c5810d34d624..bf4be383e289ef6c 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -333,7 +333,8 @@ static void adjust_default_thread_pool_size(struct btrf= s_fs_info *info) } =20 old_thread_pool_size =3D info->thread_pool_size; - new_thread_pool_size =3D min_t(unsigned long, total_usable_cpu + 2, 8); + new_thread_pool_size =3D min_t(unsigned long, total_usable_cpu + 2, + BTRFS_DEFAULT_MAX_THREAD_POOL_SIZE); =20 if (old_thread_pool_size =3D=3D new_thread_pool_size) return; --=20 Ammar Faizi