diff mbox

[-v8,01/11] CPU hotplug: Provide a generic helper to disable/enable CPU hotplug

Message ID 20130509150121.8c3ef60b2fc748ce542a1a52@linux-foundation.org (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Morton May 9, 2013, 10:01 p.m. UTC
On Tue,  7 May 2013 09:39:45 -0500 Robin Holt <holt@sgi.com> wrote:

> From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
> 
> There are instances in the kernel where we would like to disable
> CPU hotplug (from sysfs) during some important operation. Today
> the freezer code depends on this and the code to do it was kinda
> tailor-made for that.
> 
> Restructure the code and make it generic enough to be useful for
> other usecases too.
> 
> ...
>
> --- a/include/linux/cpu.h
> +++ b/include/linux/cpu.h
> @@ -141,6 +141,8 @@ static inline void unregister_cpu_notifier(struct notifier_block *nb)
>  }
>  #endif
>  
> +extern void cpu_hotplug_disable(void);
> +extern void cpu_hotplug_enable(void);
>  int cpu_up(unsigned int cpu);
>  void notify_cpu_starting(unsigned int cpu);
>  extern void cpu_maps_update_begin(void);
> @@ -148,6 +150,7 @@ extern void cpu_maps_update_done(void);
>  
>  #else	/* CONFIG_SMP */
>  
> +#define cpu_hotplug_disable()	do { } while (0)
>  #define cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
>  

Breaks alpha allmodconfig because cpu_hotplug_disable() is absent from
vmlinux.

cpu_hotplug_disable() doesn't get compiled unless we've defined
CONFIG_PM_SLEEP_SMP.  I cannot begin to imagine what the logic is
behind that!

I'll stick this in there and see what happens.

Comments

Rafael Wysocki May 10, 2013, 11:11 a.m. UTC | #1
On Thursday, May 09, 2013 03:01:21 PM Andrew Morton wrote:
> On Tue,  7 May 2013 09:39:45 -0500 Robin Holt <holt@sgi.com> wrote:
> 
> > From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
> > 
> > There are instances in the kernel where we would like to disable
> > CPU hotplug (from sysfs) during some important operation. Today
> > the freezer code depends on this and the code to do it was kinda
> > tailor-made for that.
> > 
> > Restructure the code and make it generic enough to be useful for
> > other usecases too.
> > 
> > ...
> >
> > --- a/include/linux/cpu.h
> > +++ b/include/linux/cpu.h
> > @@ -141,6 +141,8 @@ static inline void unregister_cpu_notifier(struct notifier_block *nb)
> >  }
> >  #endif
> >  
> > +extern void cpu_hotplug_disable(void);
> > +extern void cpu_hotplug_enable(void);
> >  int cpu_up(unsigned int cpu);
> >  void notify_cpu_starting(unsigned int cpu);
> >  extern void cpu_maps_update_begin(void);
> > @@ -148,6 +150,7 @@ extern void cpu_maps_update_done(void);
> >  
> >  #else	/* CONFIG_SMP */
> >  
> > +#define cpu_hotplug_disable()	do { } while (0)
> >  #define cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
> >  
> 
> Breaks alpha allmodconfig because cpu_hotplug_disable() is absent from
> vmlinux.
> 
> cpu_hotplug_disable() doesn't get compiled unless we've defined
> CONFIG_PM_SLEEP_SMP.  I cannot begin to imagine what the logic is
> behind that!

I suppose it was only used by suspend/hibernate code paths when this was
introduced.

Thanks,
Rafael
Andrew Morton May 10, 2013, 5:03 p.m. UTC | #2
On Fri, 10 May 2013 13:11:51 +0200 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> ...
>
> > cpu_hotplug_disable() doesn't get compiled unless we've defined
> > CONFIG_PM_SLEEP_SMP.  I cannot begin to imagine what the logic is
> > behind that!
> 
> I suppose it was only used by suspend/hibernate code paths when this was
> introduced.

OK, well I suspect that what I have now is simply wrong for Robin's
application.  Robin, can you please check this?  We probably want to
make the does-something version of cpu_hotplug_disable/enable available
if CONFIG_HOTPLUG_CPU.
Robin Holt May 11, 2013, 4:16 a.m. UTC | #3
On Fri, May 10, 2013 at 10:03:24AM -0700, Andrew Morton wrote:
> On Fri, 10 May 2013 13:11:51 +0200 "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> 
> > ...
> >
> > > cpu_hotplug_disable() doesn't get compiled unless we've defined
> > > CONFIG_PM_SLEEP_SMP.  I cannot begin to imagine what the logic is
> > > behind that!
> > 
> > I suppose it was only used by suspend/hibernate code paths when this was
> > introduced.
> 
> OK, well I suspect that what I have now is simply wrong for Robin's
> application.  Robin, can you please check this?  We probably want to
> make the does-something version of cpu_hotplug_disable/enable available
> if CONFIG_HOTPLUG_CPU.

This patch came from "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
I think I need to defer.

I spent all day trying to get an alpha cross compiler to build an
unmodified kernel and modules, only to find I didn't need to go that
far and could reproduce the failure with just building vmlinux.

Sorry for my slow response,
Robin
diff mbox

Patch

--- a/include/linux/cpu.h~cpu-hotplug-provide-a-generic-helper-to-disable-enable-cpu-hotplug-fix
+++ a/include/linux/cpu.h
@@ -141,8 +141,6 @@  static inline void unregister_cpu_notifi
 }
 #endif
 
-extern void cpu_hotplug_disable(void);
-extern void cpu_hotplug_enable(void);
 int cpu_up(unsigned int cpu);
 void notify_cpu_starting(unsigned int cpu);
 extern void cpu_maps_update_begin(void);
@@ -150,7 +148,6 @@  extern void cpu_maps_update_done(void);
 
 #else	/* CONFIG_SMP */
 
-#define cpu_hotplug_disable()	do { } while (0)
 #define cpu_notifier(fn, pri)	do { (void)(fn); } while (0)
 
 static inline int register_cpu_notifier(struct notifier_block *nb)
@@ -171,6 +168,15 @@  static inline void cpu_maps_update_done(
 }
 
 #endif /* CONFIG_SMP */
+
+#ifdef CONFIG_PM_SLEEP_SMP
+extern void cpu_hotplug_enable(void);
+extern void cpu_hotplug_disable(void);
+#else
+#define cpu_hotplug_enable()	do { } while (0)
+#define cpu_hotplug_disable()	do { } while (0)
+#endif
+
 extern struct bus_type cpu_subsys;
 
 #ifdef CONFIG_HOTPLUG_CPU