[merged mm-nonmm-stable] kernel-fork-declare-max_threads-__read_mostly.patch removed from -mm tree
Andrew Morton <[email protected]> Mon, 03 Aug 2026 21:05:16 -0700
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The quilt patch titled
Subject: kernel/fork: declare max_threads __read_mostly
has been removed from the -mm tree. Its filename was
kernel-fork-declare-max_threads-__read_mostly.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: JianChunfu <[email protected]>
Subject: kernel/fork: declare max_threads __read_mostly
Date: Tue, 7 Jul 2026 17:23:54 +0800
max_threads is initialized once by fork_init()->set_max_threads(), and
thereafter is mostly read in hot path, such as copy_process().
The fact that it is mostly read and not written to makes it candidates for
__read_mostly declarations.
I have already tested on my machine(arm64,256core,kernel-7.1.3) with
'hackbench -P -l 500 -g 100/500/1000/2000' and the results show that there
is an average of 13% improvement in performance.
before patch:
hackbench -g 100 500 1000 2000
1.094 4.651 13.305 36.322
after patch:
hackbench -g 100 500 1000 2000
0.823 4.487 11.107 32.987
Above data are the average values obtained from multiple tests, and there
was indeed some fluctuation in the data during the tests.
Link: https://lore.kernel.org/[email protected]
Signed-off-by: JianChunfu <[email protected]>
Reviewed-by: Lorenzo Stoakes <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
kernel/fork.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/fork.c~kernel-fork-declare-max_threads-__read_mostly
+++ a/kernel/fork.c
@@ -143,7 +143,7 @@
unsigned long total_forks; /* Handle normal Linux uptimes. */
int nr_threads; /* The idle threads do not count.. */
-static int max_threads; /* tunable limit on nr_threads */
+static int max_threads __read_mostly; /* tunable limit on nr_threads */
#define NAMED_ARRAY_INDEX(x) [x] = __stringify(x)
_
Patches currently in -mm which might be from [email protected] are