From: Christian Brauner <christian.brauner@ubuntu.com>
To: qiwuchen55@gmail.com
Cc: peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de,
oleg@redhat.com, elena.reshetova@intel.com, jgg@ziepe.ca,
christian@kellner.me, aarcange@redhat.com,
viro@zeniv.linux.org.uk, cyphar@cyphar.com, ldv@altlinux.org,
linux-kernel@vger.kernel.org, chenqiwu <chenqiwu@xiaomi.com>
Subject: Re: [PATCH] kernel/fork: put some fork variables into read-mostly section
Date: Mon, 13 Jan 2020 10:43:43 +0100 [thread overview]
Message-ID: <20200113094342.5ghlgttmhuxfqv2v@wittgenstein> (raw)
In-Reply-To: <1578885793-24095-1-git-send-email-qiwuchen55@gmail.com>
On Mon, Jan 13, 2020 at 11:23:13AM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
>
> Since total_forks/nr_threads/max_threads global variables are
> frequently used for process fork, putting these variables into
> read_mostly section can avoid unnecessary cache line bouncing.
>
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
> kernel/fork.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 0808095..163e152 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -120,10 +120,10 @@
> /*
> * Protected counters by write_lock_irq(&tasklist_lock)
> */
> -unsigned long total_forks; /* Handle normal Linux uptimes. */
> -int nr_threads; /* The idle threads do not count.. */
> +unsigned long total_forks __read_mostly; /* Handle normal Linux uptimes. */
> +int nr_threads __read_mostly; /* The idle threads do not count.. */
total_forks is incremented at every ~CLONE_THREAD and nr_threads at
CLONE_THREAD I wouldn't exactly say that this qualifies as mostly
reading.
>
> -static int max_threads; /* tunable limit on nr_threads */
> +static int max_threads __read_mostly; /* tunable limit on nr_threads */
That make sense.
Christian
next prev parent reply other threads:[~2020-01-13 9:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 3:23 [PATCH] kernel/fork: put some fork variables into read-mostly section qiwuchen55
2020-01-13 9:43 ` Christian Brauner [this message]
2020-01-14 6:16 ` chenqiwu
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=20200113094342.5ghlgttmhuxfqv2v@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=aarcange@redhat.com \
--cc=chenqiwu@xiaomi.com \
--cc=christian@kellner.me \
--cc=cyphar@cyphar.com \
--cc=elena.reshetova@intel.com \
--cc=jgg@ziepe.ca \
--cc=ldv@altlinux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=qiwuchen55@gmail.com \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).