Re: [PATCH v2 1/2] cpumask: introduce cpumask for hotpluggable CPUs

2011-08-11 Thread Amit Kucheria
See comments inline.

On 11 Aug 10, Mike Turquette wrote:
 On some platforms it is possible to have some CPUs which support CPU
 hotplug and some which do not.  Currently the prescence of an 'online'
 sysfs entry in userspace is adequate for applications to know that a CPU
 supports hotplug, but there is no convenient way to make the same
 determination in the kernel.
 
 To better model this relationship this patch introduces a new cpumask to
 track CPUs that support CPU hotplug operations.
 
 This new cpumask is populated at boot-time and remains static for the
 life of the machine.  Bits set in the mask indicate a CPU which supports
 hotplug, but make no guarantees about whether that CPU is currently
 online or not.  Likewise a cleared bit in the mask indicates either a
 CPU which cannot hotplug or a lack of a populated CPU.
 
 The purpose of this new cpumask is to aid kernel code which uses CPU to
 take CPUs online and offline.  Possible uses are as a thermal event
 mitigation technique or as a power capping mechanism.
 
 Signed-off-by: Mike Turquette mturque...@ti.com
 ---
 Change log:
 v2: fixed missing parentheses in cpumask_test_cpu and improved grammar
 in comments
 
  include/linux/cpumask.h |   27 ++-
  kernel/cpu.c|   18 ++
  2 files changed, 40 insertions(+), 5 deletions(-)
 
 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
 index b24ac56..52e64a7 100644
 --- a/include/linux/cpumask.h
 +++ b/include/linux/cpumask.h
 @@ -39,10 +39,11 @@ extern int nr_cpu_ids;
   * The following particular system cpumasks and operations manage
   * possible, present, active and online cpus.
   *
 - * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
 - * cpu_present_mask - has bit 'cpu' set iff cpu is populated
 - * cpu_online_mask  - has bit 'cpu' set iff cpu available to scheduler
 - * cpu_active_mask  - has bit 'cpu' set iff cpu available to migration
 + * cpu_possible_mask - has bit 'cpu' set iff cpu is populatable
 + * cpu_hotpluggable_mask - has bit 'cpu' set iff cpu is hotpluggable
 + * cpu_present_mask  - has bit 'cpu' set iff cpu is populated
 + * cpu_online_mask   - has bit 'cpu' set iff cpu available to 
 scheduler
 + * cpu_active_mask   - has bit 'cpu' set iff cpu available to 
 migration
   *
   *  If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
   *
 @@ -51,7 +52,11 @@ extern int nr_cpu_ids;
   *  life of that system boot.  The cpu_present_mask is dynamic(*),
   *  representing which CPUs are currently plugged in.  And
   *  cpu_online_mask is the dynamic subset of cpu_present_mask,
 - *  indicating those CPUs available for scheduling.
 + *  indicating those CPUs available for scheduling.  The
 + *  cpu_hotpluggable_mask is also fixed at boot time as the set of CPU
 + *  id's which are possible AND can hotplug.  Cleared bits in this mask
 + *  mean that either the CPU is not possible, or it is possible but does
 + *  not support CPU hotplug operations.
   *
   *  If HOTPLUG is enabled, then cpu_possible_mask is forced to have
   *  all NR_CPUS bits set, otherwise it is just the set of CPUs that
 @@ -61,6 +66,9 @@ extern int nr_cpu_ids;
   *  depending on what ACPI reports as currently plugged in, otherwise
   *  cpu_present_mask is just a copy of cpu_possible_mask.
   *
 + *  If HOTPLUG is not enabled then cpu_hotpluggable_mask is the empty
 + *  set.
 + *
   *  (*) Well, cpu_present_mask is dynamic in the hotplug case.  If not
   *  hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.
   *
 @@ -76,6 +84,7 @@ extern int nr_cpu_ids;
   */
  
  extern const struct cpumask *const cpu_possible_mask;
 +extern const struct cpumask *const cpu_hotpluggable_mask;
  extern const struct cpumask *const cpu_online_mask;
  extern const struct cpumask *const cpu_present_mask;
  extern const struct cpumask *const cpu_active_mask;
 @@ -85,19 +94,23 @@ extern const struct cpumask *const cpu_active_mask;
  #define num_possible_cpus()  cpumask_weight(cpu_possible_mask)
  #define num_present_cpus()   cpumask_weight(cpu_present_mask)
  #define num_active_cpus()cpumask_weight(cpu_active_mask)
 +#define num_hotpluggable_cpus()  cpumask_weight(cpu_hotpluggable_mask)
  #define cpu_online(cpu)  cpumask_test_cpu((cpu), cpu_online_mask)
  #define cpu_possible(cpu)cpumask_test_cpu((cpu), cpu_possible_mask)
  #define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask)
  #define cpu_active(cpu)  cpumask_test_cpu((cpu), cpu_active_mask)
 +#define cpu_hotpluggable(cpu)cpumask_test_cpu((cpu, 
 cpu_hotpluggable_mask))

The bracket should be around cpu, like this (cpu) so that there are no
side-effects when passing anything to the macro. See the other #defines above.

  #else
  #define num_online_cpus()1U
  #define num_possible_cpus()  1U
  #define num_present_cpus()   1U
  #define num_active_cpus()1U
 

Re: [PATCH v2 1/2] cpumask: introduce cpumask for hotpluggable CPUs

2011-08-11 Thread Turquette, Mike
On Wed, Aug 10, 2011 at 11:06 PM, Amit Kucheria
amit.kuche...@linaro.org wrote:
 See comments inline.

 On 11 Aug 10, Mike Turquette wrote:
 On some platforms it is possible to have some CPUs which support CPU
 hotplug and some which do not.  Currently the prescence of an 'online'
 sysfs entry in userspace is adequate for applications to know that a CPU
 supports hotplug, but there is no convenient way to make the same
 determination in the kernel.

 To better model this relationship this patch introduces a new cpumask to
 track CPUs that support CPU hotplug operations.

 This new cpumask is populated at boot-time and remains static for the
 life of the machine.  Bits set in the mask indicate a CPU which supports
 hotplug, but make no guarantees about whether that CPU is currently
 online or not.  Likewise a cleared bit in the mask indicates either a
 CPU which cannot hotplug or a lack of a populated CPU.

 The purpose of this new cpumask is to aid kernel code which uses CPU to
 take CPUs online and offline.  Possible uses are as a thermal event
 mitigation technique or as a power capping mechanism.

 Signed-off-by: Mike Turquette mturque...@ti.com
 ---
 Change log:
 v2: fixed missing parentheses in cpumask_test_cpu and improved grammar
     in comments

  include/linux/cpumask.h |   27 ++-
  kernel/cpu.c            |   18 ++
  2 files changed, 40 insertions(+), 5 deletions(-)

 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
 index b24ac56..52e64a7 100644
 --- a/include/linux/cpumask.h
 +++ b/include/linux/cpumask.h
 @@ -39,10 +39,11 @@ extern int nr_cpu_ids;
   * The following particular system cpumasks and operations manage
   * possible, present, active and online cpus.
   *
 - *     cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
 - *     cpu_present_mask - has bit 'cpu' set iff cpu is populated
 - *     cpu_online_mask  - has bit 'cpu' set iff cpu available to scheduler
 - *     cpu_active_mask  - has bit 'cpu' set iff cpu available to migration
 + *     cpu_possible_mask     - has bit 'cpu' set iff cpu is populatable
 + *     cpu_hotpluggable_mask - has bit 'cpu' set iff cpu is hotpluggable
 + *     cpu_present_mask      - has bit 'cpu' set iff cpu is populated
 + *     cpu_online_mask       - has bit 'cpu' set iff cpu available to 
 scheduler
 + *     cpu_active_mask       - has bit 'cpu' set iff cpu available to 
 migration
   *
   *  If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
   *
 @@ -51,7 +52,11 @@ extern int nr_cpu_ids;
   *  life of that system boot.  The cpu_present_mask is dynamic(*),
   *  representing which CPUs are currently plugged in.  And
   *  cpu_online_mask is the dynamic subset of cpu_present_mask,
 - *  indicating those CPUs available for scheduling.
 + *  indicating those CPUs available for scheduling.  The
 + *  cpu_hotpluggable_mask is also fixed at boot time as the set of CPU
 + *  id's which are possible AND can hotplug.  Cleared bits in this mask
 + *  mean that either the CPU is not possible, or it is possible but does
 + *  not support CPU hotplug operations.
   *
   *  If HOTPLUG is enabled, then cpu_possible_mask is forced to have
   *  all NR_CPUS bits set, otherwise it is just the set of CPUs that
 @@ -61,6 +66,9 @@ extern int nr_cpu_ids;
   *  depending on what ACPI reports as currently plugged in, otherwise
   *  cpu_present_mask is just a copy of cpu_possible_mask.
   *
 + *  If HOTPLUG is not enabled then cpu_hotpluggable_mask is the empty
 + *  set.
 + *
   *  (*) Well, cpu_present_mask is dynamic in the hotplug case.  If not
   *      hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.
   *
 @@ -76,6 +84,7 @@ extern int nr_cpu_ids;
   */

  extern const struct cpumask *const cpu_possible_mask;
 +extern const struct cpumask *const cpu_hotpluggable_mask;
  extern const struct cpumask *const cpu_online_mask;
  extern const struct cpumask *const cpu_present_mask;
  extern const struct cpumask *const cpu_active_mask;
 @@ -85,19 +94,23 @@ extern const struct cpumask *const cpu_active_mask;
  #define num_possible_cpus()  cpumask_weight(cpu_possible_mask)
  #define num_present_cpus()   cpumask_weight(cpu_present_mask)
  #define num_active_cpus()    cpumask_weight(cpu_active_mask)
 +#define num_hotpluggable_cpus()      cpumask_weight(cpu_hotpluggable_mask)
  #define cpu_online(cpu)              cpumask_test_cpu((cpu), 
 cpu_online_mask)
  #define cpu_possible(cpu)    cpumask_test_cpu((cpu), cpu_possible_mask)
  #define cpu_present(cpu)     cpumask_test_cpu((cpu), cpu_present_mask)
  #define cpu_active(cpu)              cpumask_test_cpu((cpu), 
 cpu_active_mask)
 +#define cpu_hotpluggable(cpu)        cpumask_test_cpu((cpu, 
 cpu_hotpluggable_mask))

 The bracket should be around cpu, like this (cpu) so that there are no
 side-effects when passing anything to the macro. See the other #defines above.

Wow, not sure how that happened...  will send in V3...

  #else
  

[PATCH v2 1/2] cpumask: introduce cpumask for hotpluggable CPUs

2011-08-10 Thread Mike Turquette
On some platforms it is possible to have some CPUs which support CPU
hotplug and some which do not.  Currently the prescence of an 'online'
sysfs entry in userspace is adequate for applications to know that a CPU
supports hotplug, but there is no convenient way to make the same
determination in the kernel.

To better model this relationship this patch introduces a new cpumask to
track CPUs that support CPU hotplug operations.

This new cpumask is populated at boot-time and remains static for the
life of the machine.  Bits set in the mask indicate a CPU which supports
hotplug, but make no guarantees about whether that CPU is currently
online or not.  Likewise a cleared bit in the mask indicates either a
CPU which cannot hotplug or a lack of a populated CPU.

The purpose of this new cpumask is to aid kernel code which uses CPU to
take CPUs online and offline.  Possible uses are as a thermal event
mitigation technique or as a power capping mechanism.

Signed-off-by: Mike Turquette mturque...@ti.com
---
Change log:
v2: fixed missing parentheses in cpumask_test_cpu and improved grammar
in comments

 include/linux/cpumask.h |   27 ++-
 kernel/cpu.c|   18 ++
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index b24ac56..52e64a7 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -39,10 +39,11 @@ extern int nr_cpu_ids;
  * The following particular system cpumasks and operations manage
  * possible, present, active and online cpus.
  *
- * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
- * cpu_present_mask - has bit 'cpu' set iff cpu is populated
- * cpu_online_mask  - has bit 'cpu' set iff cpu available to scheduler
- * cpu_active_mask  - has bit 'cpu' set iff cpu available to migration
+ * cpu_possible_mask - has bit 'cpu' set iff cpu is populatable
+ * cpu_hotpluggable_mask - has bit 'cpu' set iff cpu is hotpluggable
+ * cpu_present_mask  - has bit 'cpu' set iff cpu is populated
+ * cpu_online_mask   - has bit 'cpu' set iff cpu available to scheduler
+ * cpu_active_mask   - has bit 'cpu' set iff cpu available to migration
  *
  *  If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
  *
@@ -51,7 +52,11 @@ extern int nr_cpu_ids;
  *  life of that system boot.  The cpu_present_mask is dynamic(*),
  *  representing which CPUs are currently plugged in.  And
  *  cpu_online_mask is the dynamic subset of cpu_present_mask,
- *  indicating those CPUs available for scheduling.
+ *  indicating those CPUs available for scheduling.  The
+ *  cpu_hotpluggable_mask is also fixed at boot time as the set of CPU
+ *  id's which are possible AND can hotplug.  Cleared bits in this mask
+ *  mean that either the CPU is not possible, or it is possible but does
+ *  not support CPU hotplug operations.
  *
  *  If HOTPLUG is enabled, then cpu_possible_mask is forced to have
  *  all NR_CPUS bits set, otherwise it is just the set of CPUs that
@@ -61,6 +66,9 @@ extern int nr_cpu_ids;
  *  depending on what ACPI reports as currently plugged in, otherwise
  *  cpu_present_mask is just a copy of cpu_possible_mask.
  *
+ *  If HOTPLUG is not enabled then cpu_hotpluggable_mask is the empty
+ *  set.
+ *
  *  (*) Well, cpu_present_mask is dynamic in the hotplug case.  If not
  *  hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.
  *
@@ -76,6 +84,7 @@ extern int nr_cpu_ids;
  */
 
 extern const struct cpumask *const cpu_possible_mask;
+extern const struct cpumask *const cpu_hotpluggable_mask;
 extern const struct cpumask *const cpu_online_mask;
 extern const struct cpumask *const cpu_present_mask;
 extern const struct cpumask *const cpu_active_mask;
@@ -85,19 +94,23 @@ extern const struct cpumask *const cpu_active_mask;
 #define num_possible_cpus()cpumask_weight(cpu_possible_mask)
 #define num_present_cpus() cpumask_weight(cpu_present_mask)
 #define num_active_cpus()  cpumask_weight(cpu_active_mask)
+#define num_hotpluggable_cpus()cpumask_weight(cpu_hotpluggable_mask)
 #define cpu_online(cpu)cpumask_test_cpu((cpu), cpu_online_mask)
 #define cpu_possible(cpu)  cpumask_test_cpu((cpu), cpu_possible_mask)
 #define cpu_present(cpu)   cpumask_test_cpu((cpu), cpu_present_mask)
 #define cpu_active(cpu)cpumask_test_cpu((cpu), cpu_active_mask)
+#define cpu_hotpluggable(cpu)  cpumask_test_cpu((cpu, cpu_hotpluggable_mask))
 #else
 #define num_online_cpus()  1U
 #define num_possible_cpus()1U
 #define num_present_cpus() 1U
 #define num_active_cpus()  1U
+#define num_hotpluggable_cpus()0
 #define cpu_online(cpu)((cpu) == 0)
 #define cpu_possible(cpu)  ((cpu) == 0)
 #define cpu_present(cpu)   ((cpu) == 0)
 #define cpu_active(cpu)((cpu) == 0)
+#define cpu_hotpluggable(cpu)  0
 #endif
 
 /* verify cpu 

Re: [PATCH v2 1/2] cpumask: introduce cpumask for hotpluggable CPUs

2011-08-10 Thread Daniel Lezcano
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 08/10/2011 10:03 PM, Mike Turquette wrote:
 On some platforms it is possible to have some CPUs which support CPU
 hotplug and some which do not.  Currently the prescence of an 'online'
 sysfs entry in userspace is adequate for applications to know that a CPU
 supports hotplug, but there is no convenient way to make the same
 determination in the kernel.
 
 To better model this relationship this patch introduces a new cpumask to
 track CPUs that support CPU hotplug operations.
 
 This new cpumask is populated at boot-time and remains static for the
 life of the machine.  Bits set in the mask indicate a CPU which supports
 hotplug, but make no guarantees about whether that CPU is currently
 online or not.  Likewise a cleared bit in the mask indicates either a
 CPU which cannot hotplug or a lack of a populated CPU.
 
 The purpose of this new cpumask is to aid kernel code which uses CPU to
 take CPUs online and offline.  Possible uses are as a thermal event
 mitigation technique or as a power capping mechanism.
 
 Signed-off-by: Mike Turquette mturque...@ti.com

Reviewed-by: Daniel Lezcano daniel.lezc...@linaro.org

- -- 
 http://www.linaro.org/ Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ Blog

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOQu/KAAoJEAKBbMCpUGYAxnoH/0+WtrRGq0oOjkU8jIxzAEUP
OW6S7EQT13v97YapaEwUZpHOzrdeEa9bV5sVI3uc3H9n6dnQbh25eMuhiH/dTwF6
LHV1Tdv7/+ghiSc4NJunpXjAsObezUgTV9n2Zoip3kAfhMdV5DntJu0Izkdb5lkA
AD5CqV6oHqC0spa2/nMMeOYsdp3hLP3hA5wCyE8a2rxvbytxl2jRVommXOpF3AnI
s3OS7oyVFLpdvxVdAio1cXvM6vILtJFArAqw88AJUBsUsuehRxeOYVvTR3/z4RZD
LNEH72IkGY/8OVYp9/VoixWgWTUhXUR5BZwAjCP7a+xQk/1qK1LAM+/CXimwND0=
=90gJ
-END PGP SIGNATURE-

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev