ELF loader support for auxvec base platform string
[deliverable/linux.git] / include / linux / cpumask.h
index 47418b1b410395b295ea364620af3bf31c261ac8..1b5c98e7fef79fffd94805cb1d8cfd9fdadb39f5 100644 (file)
  * int next_cpu_nr(cpu, mask)          Next cpu past 'cpu', or nr_cpu_ids
  *
  * cpumask_t cpumask_of_cpu(cpu)       Return cpumask with bit 'cpu' set
+ *ifdef CONFIG_HAS_CPUMASK_OF_CPU
+ * cpumask_of_cpu_ptr_declare(v)       Declares cpumask_t *v
+ * cpumask_of_cpu_ptr_next(v, cpu)     Sets v = &cpumask_of_cpu_map[cpu]
+ * cpumask_of_cpu_ptr(v, cpu)          Combines above two operations
+ *else
+ * cpumask_of_cpu_ptr_declare(v)       Declares cpumask_t _v and *v = &_v
+ * cpumask_of_cpu_ptr_next(v, cpu)     Sets _v = cpumask_of_cpu(cpu)
+ * cpumask_of_cpu_ptr(v, cpu)          Combines above two operations
+ *endif
  * CPU_MASK_ALL                                Initializer - all bits set
  * CPU_MASK_NONE                       Initializer - no bits set
  * unsigned long *cpus_addr(mask)      Array of unsigned long's in mask
  *
+ * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
+ * variables, and CPUMASK_PTR provides pointers to each field.
+ *
+ * The structure should be defined something like this:
+ * struct my_cpumasks {
+ *     cpumask_t mask1;
+ *     cpumask_t mask2;
+ * };
+ *
+ * Usage is then:
+ *     CPUMASK_ALLOC(my_cpumasks);
+ *     CPUMASK_PTR(mask1, my_cpumasks);
+ *     CPUMASK_PTR(mask2, my_cpumasks);
+ *
+ *     --- DO NOT reference cpumask_t pointers until this check ---
+ *     if (my_cpumasks == NULL)
+ *             "kmalloc failed"...
+ *
+ * References are now pointers to the cpumask_t variables (*mask1, ...)
+ *
+ *if NR_CPUS > BITS_PER_LONG
+ *   CPUMASK_ALLOC(m)                  Declares and allocates struct m *m =
+ *                                             kmalloc(sizeof(*m), GFP_KERNEL)
+ *   CPUMASK_FREE(m)                   Macro for kfree(m)
+ *else
+ *   CPUMASK_ALLOC(m)                  Declares struct m _m, *m = &_m
+ *   CPUMASK_FREE(m)                   Nop
+ *endif
+ *   CPUMASK_PTR(v, m)                 Declares cpumask_t *v = &(m->v)
+ * ------------------------------------------------------------------------
+ *
  * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
  * int cpumask_parse_user(ubuf, ulen, mask)    Parse ascii string as cpumask
  * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
@@ -236,11 +276,16 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
 
 #ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
 extern cpumask_t *cpumask_of_cpu_map;
-#define cpumask_of_cpu(cpu)    (cpumask_of_cpu_map[cpu])
-
+#define cpumask_of_cpu(cpu)    (cpumask_of_cpu_map[cpu])
+#define        cpumask_of_cpu_ptr(v, cpu)                                      \
+               const cpumask_t *v = &cpumask_of_cpu(cpu)
+#define        cpumask_of_cpu_ptr_declare(v)                                   \
+               const cpumask_t *v
+#define cpumask_of_cpu_ptr_next(v, cpu)                                        \
+                                       v = &cpumask_of_cpu(cpu)
 #else
 #define cpumask_of_cpu(cpu)                                            \
-(*({                                                                   \
+({                                                                     \
        typeof(_unused_cpumask_arg_) m;                                 \
        if (sizeof(m) == sizeof(unsigned long)) {                       \
                m.bits[0] = 1UL<<(cpu);                                 \
@@ -248,8 +293,16 @@ extern cpumask_t *cpumask_of_cpu_map;
                cpus_clear(m);                                          \
                cpu_set((cpu), m);                                      \
        }                                                               \
-       &m;                                                             \
-}))
+       m;                                                              \
+})
+#define        cpumask_of_cpu_ptr(v, cpu)                                      \
+               cpumask_t _##v = cpumask_of_cpu(cpu);                   \
+               const cpumask_t *v = &_##v
+#define        cpumask_of_cpu_ptr_declare(v)                                   \
+               cpumask_t _##v;                                         \
+               const cpumask_t *v = &_##v
+#define cpumask_of_cpu_ptr_next(v, cpu)                                        \
+                                       _##v = cpumask_of_cpu(cpu)
 #endif
 
 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
@@ -289,6 +342,15 @@ extern cpumask_t cpu_mask_all;
 
 #define cpus_addr(src) ((src).bits)
 
+#if NR_CPUS > BITS_PER_LONG
+#define        CPUMASK_ALLOC(m)        struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
+#define        CPUMASK_FREE(m)         kfree(m)
+#else
+#define        CPUMASK_ALLOC(m)        struct m _m, *m = &_m
+#define        CPUMASK_FREE(m)
+#endif
+#define        CPUMASK_PTR(v, m)       cpumask_t *v = &(m->v)
+
 #define cpumask_scnprintf(buf, len, src) \
                        __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
 static inline int __cpumask_scnprintf(char *buf, int len,
@@ -394,19 +456,16 @@ int __next_cpu_nr(int n, const cpumask_t *srcp);
 
 #endif /* NR_CPUS > 64 */
 
-#define next_cpu_nr(n, src)            next_cpu(n, src)
-#define cpus_weight_nr(cpumask)                cpus_weight(cpumask)
-#define for_each_cpu_mask_nr(cpu, mask)        for_each_cpu_mask(cpu, mask)
-
 /*
  * The following particular system cpumasks and operations manage
- * possible, present and online cpus.  Each of them is a fixed size
+ * possible, present, active and online cpus.  Each of them is a fixed size
  * bitmap of size NR_CPUS.
  *
  *  #ifdef CONFIG_HOTPLUG_CPU
  *     cpu_possible_map - has bit 'cpu' set iff cpu is populatable
  *     cpu_present_map  - has bit 'cpu' set iff cpu is populated
  *     cpu_online_map   - has bit 'cpu' set iff cpu available to scheduler
+ *     cpu_active_map   - has bit 'cpu' set iff cpu available to migration
  *  #else
  *     cpu_possible_map - has bit 'cpu' set iff cpu is populated
  *     cpu_present_map  - copy of cpu_possible_map
@@ -457,6 +516,7 @@ int __next_cpu_nr(int n, const cpumask_t *srcp);
 extern cpumask_t cpu_possible_map;
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_present_map;
+extern cpumask_t cpu_active_map;
 
 #if NR_CPUS > 1
 #define num_online_cpus()      cpus_weight_nr(cpu_online_map)
@@ -465,6 +525,7 @@ extern cpumask_t cpu_present_map;
 #define cpu_online(cpu)                cpu_isset((cpu), cpu_online_map)
 #define cpu_possible(cpu)      cpu_isset((cpu), cpu_possible_map)
 #define cpu_present(cpu)       cpu_isset((cpu), cpu_present_map)
+#define cpu_active(cpu)                cpu_isset((cpu), cpu_active_map)
 #else
 #define num_online_cpus()      1
 #define num_possible_cpus()    1
@@ -472,6 +533,7 @@ extern cpumask_t cpu_present_map;
 #define cpu_online(cpu)                ((cpu) == 0)
 #define cpu_possible(cpu)      ((cpu) == 0)
 #define cpu_present(cpu)       ((cpu) == 0)
+#define cpu_active(cpu)                ((cpu) == 0)
 #endif
 
 #define cpu_is_offline(cpu)    unlikely(!cpu_online(cpu))
This page took 0.033989 seconds and 5 git commands to generate.