All of lore.kernel.org
 help / color / mirror / Atom feed
* + kernel-fork-declare-max_threads-__read_mostly.patch added to mm-nonmm-unstable branch
@ 2026-07-07 20:35 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-07-07 20:35 UTC (permalink / raw)
  To: mm-commits, rostedt, peterz, mingo, ljs, liam, kees,
	dietmar.eggemann, jansef.jian, akpm


The patch titled
     Subject: kernel/fork: declare max_threads __read_mostly
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     kernel-fork-declare-max_threads-__read_mostly.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kernel-fork-declare-max_threads-__read_mostly.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: JianChunfu <jansef.jian@hj-micro.com>
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/20260707092354.465847-1-jansef.jian@hj-micro.com
Signed-off-by: JianChunfu <jansef.jian@hj-micro.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 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 jansef.jian@hj-micro.com are

kernel-fork-declare-max_threads-__read_mostly.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-07 20:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 20:35 + kernel-fork-declare-max_threads-__read_mostly.patch added to mm-nonmm-unstable branch Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.