linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Jack Steiner <steiner@sgi.com>,
	Lee Schermerhorn <lee.schermerhorn@hp.com>,
	Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Paul Menage <menage@google.com>, Robin Holt <holt@sgi.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH incremental] cpusets: initialize spread rotor lazily
Date: Mon, 18 Apr 2011 23:29:16 +0200	[thread overview]
Message-ID: <20110418212915.GA17376@tiehlicka.suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.00.1104181316110.31186@chino.kir.corp.google.com>

On Mon 18-04-11 13:19:09, David Rientjes wrote:
> On Mon, 18 Apr 2011, Michal Hocko wrote:
[...]
> > > Andrew could easily drop the earlier version and merge this v2, but I'm 
> > > asking for selfish reasons:
> > 
> > Just out of curiosity. What is the reason? Don't want to wait for new mmotm?
> > 
> 
> Because lazy initialization is another feature on top of the existing 
> patch so it should be done incrementally instead of proposing an entirely 
> new patch which is already mostly in -mm.

ok, makes sense

> > 
> > [Here is the follow-up patch based on top of
> > http://userweb.kernel.org/~akpm/mmotm/broken-out/cpusets-randomize-node-rotor-used-in-cpuset_mem_spread_node.patch]
> > ---
> > From: Michal Hocko <mhocko@suse.cz>
> > Subject: cpusets: initialize spread mem/slab rotor lazily
> > 
[...]
> > Also do not use -1 for unitialized nodes and rather use NUMA_NO_NODE
> > instead.
> > 
> 
> Don't need to refer to a previous version that used -1 since it will never 
> be committed and nobody will know what you're talking about in the git 
> log.

removed

[...]
> >  int cpuset_mem_spread_node(void)
> >  {
> > +	if (current->cpuset_mem_spread_rotor == NUMA_NO_NODE)
> > +		current->cpuset_mem_spread_rotor =
> > +			node_random(&current->mems_allowed);
> > +
> >  	return cpuset_spread_node(&current->cpuset_mem_spread_rotor);
> >  }
> >  
> >  int cpuset_slab_spread_node(void)
> >  {
> > +	if (current->cpuset_slab_spread_rotor == NUMA_NO_NODE)
> > +		current->cpuset_slab_spread_rotor
> > +			= node_random(&current->mems_allowed);
> > +
> 
> So one function has the `=' on the line with the assignment (preferred) 
> and the other has it on the new value?

fixed

Thanks! Updated patch bellow.

Changes from v3:
 - code style fix
Changes from v2:
 - use NUMA_NO_NODE rather than hardcoded -1
 - make the patch incremental to the original one because that one is in
   -mm tree already.
Changes from v1:
 - initialize cpuset_{mem,slab}_spread_rotor lazily}
---
From: Michal Hocko <mhocko@suse.cz>
Subject: cpusets: initialize spread mem/slab rotor lazily

Kosaki Motohiro raised a concern that copy_process is hot path and we do
not want to initialize cpuset_{mem,slab}_spread_rotor if they are not
used most of the time.

I think that we should rather initialize it lazily when rotors are used
for the first time.
This will also catch the case when we set up spread mem/slab later.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Index: linus_tree/kernel/cpuset.c
===================================================================
--- linus_tree.orig/kernel/cpuset.c	2011-04-18 10:33:15.000000000 +0200
+++ linus_tree/kernel/cpuset.c	2011-04-18 23:24:02.000000000 +0200
@@ -2460,11 +2460,19 @@ static int cpuset_spread_node(int *rotor
 
 int cpuset_mem_spread_node(void)
 {
+	if (current->cpuset_mem_spread_rotor == NUMA_NO_NODE)
+		current->cpuset_mem_spread_rotor =
+			node_random(&current->mems_allowed);
+
 	return cpuset_spread_node(&current->cpuset_mem_spread_rotor);
 }
 
 int cpuset_slab_spread_node(void)
 {
+	if (current->cpuset_slab_spread_rotor == NUMA_NO_NODE)
+		current->cpuset_slab_spread_rotor =
+			node_random(&current->mems_allowed);
+
 	return cpuset_spread_node(&current->cpuset_slab_spread_rotor);
 }
 
Index: linus_tree/kernel/fork.c
===================================================================
--- linus_tree.orig/kernel/fork.c	2011-04-18 10:33:15.000000000 +0200
+++ linus_tree/kernel/fork.c	2011-04-18 10:33:56.000000000 +0200
@@ -1126,8 +1126,8 @@ static struct task_struct *copy_process(
 	mpol_fix_fork_child_flag(p);
 #endif
 #ifdef CONFIG_CPUSETS
-	p->cpuset_mem_spread_rotor = node_random(&p->mems_allowed);
-	p->cpuset_slab_spread_rotor = node_random(&p->mems_allowed);
+	p->cpuset_mem_spread_rotor = NUMA_NO_NODE;
+	p->cpuset_slab_spread_rotor = NUMA_NO_NODE;
 #endif
 #ifdef CONFIG_TRACE_IRQFLAGS
 	p->irq_events = 0;
-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-04-18 21:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110414065146.GA19685@tiehlicka.suse.cz>
     [not found] ` <20110414160145.0830.A69D9226@jp.fujitsu.com>
     [not found]   ` <20110415161831.12F8.A69D9226@jp.fujitsu.com>
2011-04-15  8:20     ` [PATCH v2] cpusets: randomize node rotor used in cpuset_mem_spread_node() Michal Hocko
2011-04-15  8:29       ` KOSAKI Motohiro
2011-04-15  8:31         ` Michal Hocko
2011-04-15 23:42       ` David Rientjes
2011-04-18  8:42         ` [PATCH incremental] cpusets: initialize spread rotor lazily Michal Hocko
2011-04-18 20:19           ` David Rientjes
2011-04-18 21:29             ` Michal Hocko [this message]
2011-04-19  1:15               ` David Rientjes
2011-05-26 22:33       ` [PATCH v2] cpusets: randomize node rotor used in cpuset_mem_spread_node() Andrew Morton
2011-05-27 12:47         ` Michal Hocko
2011-05-27 19:07           ` David Rientjes
2011-05-27 23:17             ` Michal Hocko
2011-05-27 23:27               ` David Rientjes
2011-05-27 23:40                 ` Michal Hocko
2011-05-27 21:20           ` Andrew Morton
2011-05-27 23:17             ` Michal Hocko
2011-05-27 23:30               ` David Rientjes
2011-05-27 23:38                 ` Michal Hocko

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=20110418212915.GA17376@tiehlicka.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=holt@sgi.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=lee.schermerhorn@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=rientjes@google.com \
    --cc=steiner@sgi.com \
    --cc=torvalds@linux-foundation.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 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).