lkml.org 
[lkml]   [2020]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kernel/fork: put some fork variables into read-mostly section
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

\
 
 \ /
  Last update: 2020-01-13 10:44    [W:0.053 / U:1.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site