All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,rostedt@goodmis.org,peterz@infradead.org,mingo@redhat.com,ljs@kernel.org,liam@infradead.org,kees@kernel.org,dietmar.eggemann@arm.com,jansef.jian@hj-micro.com,akpm@linux-foundation.org
Subject: + kernel-fork-declare-max_threads-__read_mostly.patch added to mm-nonmm-unstable branch
Date: Tue, 07 Jul 2026 13:35:31 -0700	[thread overview]
Message-ID: <20260707203532.46CDA1F000E9@smtp.kernel.org> (raw)


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


                 reply	other threads:[~2026-07-07 20:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707203532.46CDA1F000E9@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=jansef.jian@hj-micro.com \
    --cc=kees@kernel.org \
    --cc=liam@infradead.org \
    --cc=ljs@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.