linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: paulmck@linux.vnet.ibm.com
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arjan van de Ven <arjan@infradead.org>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Milton Miller <miltonm@bga.com>, "mingo@elte.hu" <mingo@elte.hu>,
	Tejun Heo <tj@kernel.org>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Linux PM mailing list <linux-pm@vger.kernel.org>,
	nikunj@linux.vnet.ibm.com
Subject: Re: CPU Hotplug rework
Date: Wed, 11 Apr 2012 11:32:57 +0530	[thread overview]
Message-ID: <4F851E91.70603@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120411010015.GA2402@linux.vnet.ibm.com>

On 04/11/2012 06:30 AM, Paul E. McKenney wrote:

> On Tue, Apr 10, 2012 at 08:37:18PM -0400, Steven Rostedt wrote:
>> On Tue, 2012-04-10 at 17:28 -0700, Paul E. McKenney wrote:
>>
>>>> Just to throw out the stupid silly approach.
>>>>
>>>> What about creating a "__register_cpu_notifier()" that just does:
>>>>
>>>> int __ref __register_cpu_notifier(struct notifier_block *nb)
>>>> {
>>>> 	return raw_notifier_chain_register(&cpu_chain, nb);
>>>> }
>>>>
>>>> Also making cpu_maps_update_begin/done() global (and probably rename
>>>> them).
>>
>> I just noticed that the cpu_maps_update_begin/done() are already global.
>>
>>>>
>>>> and then in the above code do:
>>>>
>>>> 	cpu_maps_update_begin();
>>>> 	__register_cpu_notifier(nb);
>>>> 	do_setup();
>>>> 	cpu_maps_update_done();
>>>>
>>>>


Wow! Believe it or not, this is precisely the crux of the approach I was
suggesting all along!! :-) Just that when put to code, it looked slightly
different than this.. Sorry for not being clear.

So here is what I proposed, in a simplified form:

Modify the existing register_cpu_notifier() to this (by possibly giving
it a different name):

int __ref register_cpu_notifier(struct notifier_block *nb,
					int (*do_setup)(void))
{
	int ret;

	cpu_maps_update_begin();
	ret = raw_notifier_chain_register(&cpu_chain, nb);
	do_setup();
	cpu_maps_update_done();

	return ret;
}

and then, in the caller, do:

	register_cpu_notifier(nb, do_setup);

If the caller doesn't need any such extra setup, just do:

	register_cpu_notifier(nb, NULL);


Of course, register_cpu_notifier() should handle NULL properly.
(My patch [1] handles it, along with some other special cases.)
 
That's it!

Also, it is to be noted that cpu_maps_update_begin/done() are global, but
not exported symbols - so modules can't use them. With the above approach,
we need not make them exported symbols, since the caller need not care about
these locks at all.

>>>> Just saying,
>>>
>>> That does have some attractive properties, now that you mention it.  ;-)
>>
>> Which property? Stupid or Silly ;-)
> 
> As with any piece of software, no matter how small, both.  ;-)
> 
> Of course, __register_cpu_notifier() would need lockdep checking to make
> sure that it wasn't called without the benefit of cpu_maps_update_begin().


Not with my approach ;-) Its all automatically handled :-)

> I might be missing something, but as long as that was in place, seems
> like it is a lot simpler and easier to use than the alternatives that
> Srivatsa and I were kicking around.
> 


Hehe :-) Thanks for simplifying things, Steve!


[1]. https://lkml.org/lkml/2012/3/1/39

Regards,
Srivatsa S. Bhat


  reply	other threads:[~2012-04-11  6:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 14:44 CPU Hotplug rework Srivatsa S. Bhat
2012-03-19 14:48 ` Srivatsa S. Bhat
2012-03-20 11:28   ` Peter Zijlstra
2012-04-05 17:39   ` Paul E. McKenney
2012-04-05 17:55     ` Paul E. McKenney
2012-04-05 23:06       ` Paul E. McKenney
2012-04-06 20:15         ` Srivatsa S. Bhat
2012-04-09 16:46           ` Paul E. McKenney
2012-04-10  7:56             ` Nikunj A Dadhania
2012-04-06 19:52     ` Srivatsa S. Bhat
2012-04-09 17:13       ` Paul E. McKenney
2012-04-10 13:41         ` Srivatsa S. Bhat
2012-04-10 15:46           ` Paul E. McKenney
2012-04-10 17:26             ` Srivatsa S. Bhat
2012-04-11  0:09       ` Steven Rostedt
2012-04-11  0:28         ` Paul E. McKenney
2012-04-11  0:37           ` Steven Rostedt
2012-04-11  1:00             ` Paul E. McKenney
2012-04-11  6:02               ` Srivatsa S. Bhat [this message]
2012-04-11 12:28                 ` Paul E. McKenney
2012-03-19 23:42 ` Rusty Russell
2012-03-20 10:42   ` Peter Zijlstra
2012-03-20 23:00     ` Rusty Russell
2012-03-21  9:01       ` Peter Zijlstra
2012-03-22  4:25         ` Rusty Russell
2012-03-22 22:49           ` Paul E. McKenney
2012-03-23 23:27             ` Rusty Russell
2012-03-24  0:23               ` Paul E. McKenney
2012-03-26  0:41                 ` Rusty Russell
2012-03-26  8:02                   ` Peter Zijlstra
2012-03-26 13:09                     ` Steven Rostedt
2012-03-26 13:38                       ` Peter Zijlstra
2012-03-26 15:22                         ` Steven Rostedt
2012-03-26 16:13                           ` Peter Zijlstra
2012-03-26 17:05                             ` Steven Rostedt
2012-03-26 17:59                               ` Peter Zijlstra
2012-03-27  1:32                               ` Rusty Russell
2012-03-27  3:05                                 ` Steven Rostedt

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=4F851E91.70603@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=miltonm@bga.com \
    --cc=mingo@elte.hu \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rjw@sisk.pl \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tj@kernel.org \
    --cc=vatsa@linux.vnet.ibm.com \
    /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).