[PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask - Kernel

This is a discussion on [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask - Kernel ; [Resubmit: cleanup and rebase on latest tip/master.] Redesign cpumask API to explicitly declare struct cpumask pointers to the cpumask_* operators and add functions to make it easier to support struct cpumask pointers on the stack. This patchset supplies the infrastructure ...

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 20 of 77

Thread: [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask

  1. [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask


    [Resubmit: cleanup and rebase on latest tip/master.]

    Redesign cpumask API to explicitly declare struct cpumask pointers to
    the cpumask_* operators and add functions to make it easier to support
    struct cpumask pointers on the stack.

    This patchset supplies the infrastructure going forward to implement
    this new struct cpumask API. Many more patches (currently 58) have
    been written and tested to verify the functionality of this API. These
    will be submitted as soon as they are thoroughly tested.

    Compiled and tested on x86_64.

    Based on tip/master @ v2.6.27-6973-ga90cd11

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 01/35] cpumask: add for_each_cpu_mask_and function

    Add for_each_cpu_mask_and() function to eliminate need for a common use
    of a temporary cpumask_t variable. When the following procedure is being
    used:

    funcproto(const cpumask_t *mask, ...)
    {
    cpumask_t temp;

    cpus_and(temp, mask, cpu_online_map);
    for_each_cpu_mask(cpu, temp)
    ...
    It then becomes:

    funcproto(cpumask_t *mask, ...)
    {
    for_each_cpu_mask_and(cpu, *mask, cpu_online_map)
    ...

    .... eliminating the need for the temp cpumask.


    Applies to linux-2.6.tip/master.

    Signed-off-by: Mike Travis
    Acked-by: Rusty Russell
    ---
    include/linux/cpumask.h | 33 ++++++++++++++++++++++++---------
    lib/cpumask.c | 9 +++++++++
    2 files changed, 33 insertions(+), 9 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -109,6 +109,7 @@
    *
    * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using NR_CPUS
    * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
    + * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
    *
    * int num_online_cpus() Number of online CPUs
    * int num_possible_cpus() Number of all possible CPUs
    @@ -400,29 +401,41 @@ static inline void __cpus_fold(cpumask_t

    #if NR_CPUS == 1

    -#define nr_cpu_ids 1
    -#define first_cpu(src) ({ (void)(src); 0; })
    -#define next_cpu(n, src) ({ (void)(src); 1; })
    -#define any_online_cpu(mask) 0
    -#define for_each_cpu_mask(cpu, mask) \
    +#define nr_cpu_ids 1
    +#define first_cpu(src) ({ (void)(src); 0; })
    +#define next_cpu(n, src) ({ (void)(src); 1; })
    +#define cpumask_next_and(n, srcp, andp) ({ (void)(srcp), (void)(andp); 1; })
    +#define any_online_cpu(mask) 0
    +
    +#define for_each_cpu_mask(cpu, mask) \
    for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
    +#define for_each_cpu_mask_and(cpu, mask, and) \
    + for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)

    #else /* NR_CPUS > 1 */

    extern int nr_cpu_ids;
    int __first_cpu(const cpumask_t *srcp);
    int __next_cpu(int n, const cpumask_t *srcp);
    +int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
    int __any_online_cpu(const cpumask_t *mask);

    #define first_cpu(src) __first_cpu(&(src))
    #define next_cpu(n, src) __next_cpu((n), &(src))
    #define any_online_cpu(mask) __any_online_cpu(&(mask))
    +
    #define for_each_cpu_mask(cpu, mask) \
    for ((cpu) = -1; \
    (cpu) = next_cpu((cpu), (mask)), \
    - (cpu) < NR_CPUS; )
    + (cpu) < NR_CPUS
    +#define for_each_cpu_mask_and(cpu, mask, and) \
    + for ((cpu) = -1; \
    + (cpu) = cpumask_next_and((cpu), &(mask), &(and)), \
    + (cpu) < nr_cpu_ids
    #endif

    +#define cpumask_first_and(mask, and) cpumask_next_and(-1, (mask), (and))
    +
    #if NR_CPUS <= 64

    #define next_cpu_nr(n, src) next_cpu(n, src)
    @@ -432,12 +445,14 @@ int __any_online_cpu(const cpumask_t *ma
    #else /* NR_CPUS > 64 */

    int __next_cpu_nr(int n, const cpumask_t *srcp);
    -#define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
    -#define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
    +
    +#define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
    +#define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
    +
    #define for_each_cpu_mask_nr(cpu, mask) \
    for ((cpu) = -1; \
    (cpu) = next_cpu_nr((cpu), (mask)), \
    - (cpu) < nr_cpu_ids; )
    + (cpu) < nr_cpu_ids

    #endif /* NR_CPUS > 64 */

    --- linux-2.6.28.orig/lib/cpumask.c
    +++ linux-2.6.28/lib/cpumask.c
    @@ -15,6 +15,15 @@ int __next_cpu(int n, const cpumask_t *s
    }
    EXPORT_SYMBOL(__next_cpu);

    +int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp)
    +{
    + while ((n = next_cpu_nr(n, *srcp)) < nr_cpu_ids)
    + if (cpu_isset(n, *andp))
    + break;
    + return n;
    +}
    +EXPORT_SYMBOL(cpumask_next_and);
    +
    #if NR_CPUS > 64
    int __next_cpu_nr(int n, const cpumask_t *srcp)
    {

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 08/35] cpumask: cpumask_size() From: Mike Travis <travis@sgi.com>

    Dynamic allocation of cpumasks requires the size.

    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 3 +++
    1 file changed, 3 insertions(+)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -64,6 +64,7 @@
    * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
    * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
    *
    + * size_t cpumask_size() Length of cpumask in bytes.
    * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
    * (can be used as an lvalue)
    * CPU_MASK_ALL Initializer - all bits set
    @@ -147,6 +148,8 @@ struct cpumask {
    };
    #define cpumask_bits(maskp) ((maskp)->bits)

    +#define cpumask_size() (BITS_TO_LONGS(NR_CPUS) * sizeof(long))
    +
    /* Deprecated. */
    typedef struct cpumask cpumask_t;
    extern cpumask_t _unused_cpumask_arg_;

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 16/35] percpu: fix percpu accessors to potentially !cpu_possible() cpus From: Rusty Russell <rusty@rustcorp.com.au>

    Percpu areas are only allocated for possible cpus. In general, you
    shouldn't access random cpu's percpu areas: you're corrupting memory.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    arch/m32r/kernel/smpboot.c | 2 +-
    arch/x86/mach-voyager/voyager_smp.c | 2 +-
    drivers/pnp/pnpbios/bioscalls.c | 2 +-
    3 files changed, 3 insertions(+), 3 deletions(-)

    --- linux-2.6.28.orig/arch/m32r/kernel/smpboot.c
    +++ linux-2.6.28/arch/m32r/kernel/smpboot.c
    @@ -592,7 +592,7 @@ int setup_profiling_timer(unsigned int m
    * accounting. At that time they also adjust their APIC timers
    * accordingly.
    */
    - for (i = 0; i < NR_CPUS; ++i)
    + for_each_possible_cpu(i)
    per_cpu(prof_multiplier, i) = multiplier;

    return 0;
    --- linux-2.6.28.orig/arch/x86/mach-voyager/voyager_smp.c
    +++ linux-2.6.28/arch/x86/mach-voyager/voyager_smp.c
    @@ -1216,7 +1216,7 @@ int setup_profiling_timer(unsigned int m
    * new values until the next timer interrupt in which they do process
    * accounting.
    */
    - for (i = 0; i < NR_CPUS; ++i)
    + for_each_possible_cpu(i)
    per_cpu(prof_multiplier, i) = multiplier;

    return 0;
    --- linux-2.6.28.orig/drivers/pnp/pnpbios/bioscalls.c
    +++ linux-2.6.28/drivers/pnp/pnpbios/bioscalls.c
    @@ -481,7 +481,7 @@ void pnpbios_calls_init(union pnp_bios_i

    set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
    _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
    - for (i = 0; i < NR_CPUS; i++) {
    + for_each_possible_cpu(i) {
    struct desc_struct *gdt = get_cpu_gdt_table(i);
    if (!gdt)
    continue;

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 30/35] cpumask: cpu_all_mask and cpu_none_mask. From: Rusty Russell <rusty@rustcorp.com.au>

    Instead of CPU_MASK_ALL_PTR and the SMP-only cpu_mask_all, this makes
    cpu_all_mask and cpu_none_mask which are const cpumask pointers which
    always exist.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 16 ++++++++++------
    init/main.c | 7 +------
    kernel/cpu.c | 3 +++
    kernel/kmod.c | 2 +-
    kernel/kthread.c | 4 ++--
    kernel/sched.c | 2 +-
    6 files changed, 18 insertions(+), 16 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -116,6 +116,7 @@ struct cpumask {
    typedef struct cpumask cpumask_t;
    extern cpumask_t _unused_cpumask_arg_;

    +#define CPU_MASK_ALL_PTR (cpu_all_mask)
    #define CPU_MASK_ALL ((cpumask_t){ CPU_BITS_ALL })
    #define CPU_MASK_NONE ((cpumask_t){ CPU_BITS_NONE })
    #define CPU_MASK_CPU0 ((cpumask_t){ CPU_BITS_CPU0 })
    @@ -174,6 +175,7 @@ extern cpumask_t _unused_cpumask_arg_;
    #define cpu_online_map (*(cpumask_t *)cpu_online_mask)
    #define cpu_present_map (*(cpumask_t *)cpu_present_mask)
    #define cpu_active_map (*(cpumask_t *)cpu_active_mask)
    +#define cpu_mask_all (*(cpumask_t *)cpu_all_mask)
    /* End deprecated region. */

    #if NR_CPUS > 1
    @@ -414,8 +416,6 @@ static inline const struct cpumask *cpum
    [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    }

    -#define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)
    -
    #else

    #define CPU_BITS_ALL \
    @@ -424,10 +424,6 @@ static inline const struct cpumask *cpum
    [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    }

    -/* cpu_mask_all is in init/main.c */
    -extern cpumask_t cpu_mask_all;
    -#define CPU_MASK_ALL_PTR (&cpu_mask_all)
    -
    #endif

    #define CPU_BITS_NONE \
    @@ -560,6 +556,14 @@ extern const struct cpumask *const cpu_o
    extern const struct cpumask *const cpu_present_mask;
    extern const struct cpumask *const cpu_active_mask;

    +/* It's common to want to use cpu_all_mask in struct member initializers,
    + * so it has to refer to an address rather than a pointer. */
    +extern const DECLARE_BITMAP(cpu_all_bits, CONFIG_NR_CPUS);
    +#define cpu_all_mask to_cpumask(cpu_all_bits)
    +
    +/* First bits of cpu_bit_bitmap are in fact unset. */
    +#define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
    +
    #if NR_CPUS > 1
    #define num_online_cpus() cpus_weight(cpu_online_map)
    #define num_possible_cpus() cpus_weight(cpu_possible_map)
    --- linux-2.6.28.orig/init/main.c
    +++ linux-2.6.28/init/main.c
    @@ -368,11 +368,6 @@ static inline void smp_prepare_cpus(unsi

    #else

    -#if NR_CPUS > BITS_PER_LONG
    -cpumask_t cpu_mask_all __read_mostly = CPU_MASK_ALL;
    -EXPORT_SYMBOL(cpu_mask_all);
    -#endif
    -
    /* Setup number of possible processor ids */
    /* nr_cpu_ids is a real variable for SMP. */
    #ifndef nr_cpu_ids
    @@ -863,7 +858,7 @@ static int __init kernel_init(void * unu
    /*
    * init can run on any cpu.
    */
    - set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
    + set_cpus_allowed_ptr(current, cpu_all_mask);
    /*
    * Tell the world that we're going to be the grim
    * reaper of innocent orphaned children.
    --- linux-2.6.28.orig/kernel/cpu.c
    +++ linux-2.6.28/kernel/cpu.c
    @@ -498,6 +498,9 @@ static DECLARE_BITMAP(cpu_active_bits, C
    const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
    EXPORT_SYMBOL(cpu_active_mask);

    +const DECLARE_BITMAP(cpu_all_bits, CONFIG_NR_CPUS) = CPU_BITS_ALL;
    +EXPORT_SYMBOL(cpu_all_bits);
    +
    void set_cpu_possible(unsigned int cpu, bool possible)
    {
    if (possible)
    --- linux-2.6.28.orig/kernel/kmod.c
    +++ linux-2.6.28/kernel/kmod.c
    @@ -166,7 +166,7 @@ static int ____call_usermodehelper(void
    }

    /* We can run anywhere, unlike our parent keventd(). */
    - set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
    + set_cpus_allowed_ptr(current, cpu_all_mask);

    /*
    * Our parent is keventd, which runs with elevated scheduling priority.
    --- linux-2.6.28.orig/kernel/kthread.c
    +++ linux-2.6.28/kernel/kthread.c
    @@ -107,7 +107,7 @@ static void create_kthread(struct kthrea
    */
    sched_setscheduler(create->result, SCHED_NORMAL, &param);
    set_user_nice(create->result, KTHREAD_NICE_LEVEL);
    - set_cpus_allowed_ptr(create->result, CPU_MASK_ALL_PTR);
    + set_cpus_allowed_ptr(create->result, cpu_all_mask);
    }
    complete(&create->done);
    }
    @@ -237,7 +237,7 @@ int kthreadd(void *unused)
    set_task_comm(tsk, "kthreadd");
    ignore_signals(tsk);
    set_user_nice(tsk, KTHREAD_NICE_LEVEL);
    - set_cpus_allowed_ptr(tsk, CPU_MASK_ALL_PTR);
    + set_cpus_allowed_ptr(tsk, cpu_all_mask);

    current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG;

    --- linux-2.6.28.orig/kernel/sched.c
    +++ linux-2.6.28/kernel/sched.c
    @@ -6167,7 +6167,7 @@ static void move_task_off_dead_cpu(int d
    */
    static void migrate_nr_uninterruptible(struct rq *rq_src)
    {
    - struct rq *rq_dest = cpu_rq(any_online_cpu(*CPU_MASK_ALL_PTR));
    + struct rq *rq_dest = cpu_rq(cpumask_any(cpu_online_mask));
    unsigned long flags;

    local_irq_save(flags);

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 11/35] x86: enable MAXSMP

    Set MAXSMP to enable CONFIG_CPUMASK_OFFSTACK which moves cpumask's off
    the stack (and in structs) when using cpumask_var_t.

    Signed-off-by: Mike Travis
    Signed-off-by: Rusty Russell
    ---
    arch/x86/Kconfig | 11 ++++++-----
    1 file changed, 6 insertions(+), 5 deletions(-)

    --- linux-2.6.28.orig/arch/x86/Kconfig
    +++ linux-2.6.28/arch/x86/Kconfig
    @@ -573,6 +573,7 @@ config IOMMU_HELPER
    config MAXSMP
    bool "Configure Maximum number of SMP Processors and NUMA Nodes"
    depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL
    + select CPUMASK_OFFSTACK
    help
    Configure maximum number of CPUS and NUMA Nodes for this
    architecture (up to 4096!).
    @@ -584,16 +585,16 @@ config MAXSMP
    If unsure, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-4096)" if !MAXSMP
    - range 2 4096
    depends on SMP
    + int "Maximum number of CPUs" if SMP && !MAXSMP
    + range 2 512 if SMP && !MAXSMP
    default "4096" if MAXSMP
    - default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000
    + default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000
    default "8"
    help
    This allows you to specify the maximum number of CPUs which this
    - kernel will support. The maximum supported value is 512 and the
    - minimum value which makes sense is 2.
    + kernel will support. The maximum supported value is 512 (4096
    + if MAXSMP set) and the minimum value which makes sense is 2.

    This is purely to save memory - each supported CPU adds
    approximately one kilobyte to the kernel image.

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. [PATCH 33/35] cpumask: smp_call_function_many() From: Rusty Russell <rusty@rustcorp.com.au>

    Transition from cpumask_t-taking smp_call_function_mask() to a new
    smp_call_function_many() which takes a struct cpumask *.

    (Naming is inspired by smp_call_function_single).

    Note that the new one returns void: the old one couldn't fail either
    unless there was a logic bug.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    arch/s390/include/asm/smp.h | 3 --
    arch/s390/kernel/smp.c | 30 +++++++++++---------
    include/linux/smp.h | 13 +++++++-
    kernel/smp.c | 66 ++++++++++++++++++++++++--------------------
    4 files changed, 64 insertions(+), 48 deletions(-)

    --- linux-2.6.28.orig/arch/s390/include/asm/smp.h
    +++ linux-2.6.28/arch/s390/include/asm/smp.h
    @@ -90,9 +90,6 @@ extern int __cpu_up (unsigned int cpu);

    extern struct mutex smp_cpu_state_mutex;
    extern int smp_cpu_polarization[];
    -
    -extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
    - void *info, int wait);
    #endif

    #ifndef CONFIG_SMP
    --- linux-2.6.28.orig/arch/s390/kernel/smp.c
    +++ linux-2.6.28/arch/s390/kernel/smp.c
    @@ -103,7 +103,7 @@ static void do_call_function(void)
    }

    static void __smp_call_function_map(void (*func) (void *info), void *info,
    - int wait, cpumask_t map)
    + int wait, struct cpumask *map)
    {
    struct call_data_struct data;
    int cpu, local = 0;
    @@ -163,14 +163,16 @@ out:
    * You must not call this function with disabled interrupts, from a
    * hardware interrupt handler or from a bottom half.
    */
    +
    +/* protected by call_lock */
    +static DEFINE_BITMAP(smp_call_map, CONFIG_NR_CPUS);
    +
    int smp_call_function(void (*func) (void *info), void *info, int wait)
    {
    - cpumask_t map;
    -
    spin_lock(&call_lock);
    - map = cpu_online_map;
    - cpu_clear(smp_processor_id(), map);
    - __smp_call_function_map(func, info, wait, map);
    + cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
    + cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
    + __smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
    spin_unlock(&call_lock);
    return 0;
    }
    @@ -192,14 +194,15 @@ int smp_call_function_single(int cpu, vo
    int wait)
    {
    spin_lock(&call_lock);
    - __smp_call_function_map(func, info, wait, cpumask_of_cpu(cpu));
    + cpumask_copy(to_cpumask(smp_call_map), cpumask_of(cpu));
    + __smp_call_function_map(func, info, wait, cpumask_of(cpu));
    spin_unlock(&call_lock);
    return 0;
    }
    EXPORT_SYMBOL(smp_call_function_single);

    /**
    - * smp_call_function_mask(): Run a function on a set of other CPUs.
    + * smp_call_function_many(): Run a function on a set of other CPUs.
    * @mask: The set of cpus to run on. Must not include the current cpu.
    * @func: The function to run. This must be fast and non-blocking.
    * @info: An arbitrary pointer to pass to the function.
    @@ -213,16 +216,17 @@ EXPORT_SYMBOL(smp_call_function_single);
    * You must not call this function with disabled interrupts or from a
    * hardware interrupt handler or from a bottom half handler.
    */
    -int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
    - int wait)
    +int smp_call_function_many(const struct cpumask *mask,
    + void (*func)(void *), void *info, bool wait)
    {
    spin_lock(&call_lock);
    - cpu_clear(smp_processor_id(), mask);
    - __smp_call_function_map(func, info, wait, mask);
    + cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
    + cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
    + __smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
    spin_unlock(&call_lock);
    return 0;
    }
    -EXPORT_SYMBOL(smp_call_function_mask);
    +EXPORT_SYMBOL(smp_call_function_many);

    void smp_send_stop(void)
    {
    --- linux-2.6.28.orig/include/linux/smp.h
    +++ linux-2.6.28/include/linux/smp.h
    @@ -64,12 +64,21 @@ extern void smp_cpus_done(unsigned int m
    * Call a function on all other processors
    */
    int smp_call_function(void(*func)(void *info), void *info, int wait);
    -int smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
    - int wait);
    +void smp_call_function_many(const struct cpumask *mask,
    + void(*func)(void *info), void *info, bool wait);
    int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
    int wait);
    void __smp_call_function_single(int cpuid, struct call_single_data *data);

    +/* Use smp_call_function_many, which takes a pointer to the mask. */
    +static inline int __deprecated
    +smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
    + int wait)
    +{
    + smp_call_function_many(&mask, func, info, wait);
    + return 0;
    +}
    +
    /*
    * Generic and arch helpers
    */
    --- linux-2.6.28.orig/kernel/smp.c
    +++ linux-2.6.28/kernel/smp.c
    @@ -24,7 +24,7 @@ struct call_function_data {
    struct call_single_data csd;
    spinlock_t lock;
    unsigned int refs;
    - cpumask_t cpumask;
    + struct cpumask *cpumask;
    struct rcu_head rcu_head;
    };

    @@ -109,13 +109,13 @@ void generic_smp_call_function_interrupt
    list_for_each_entry_rcu(data, &call_function_queue, csd.list) {
    int refs;

    - if (!cpu_isset(cpu, data->cpumask))
    + if (!cpumask_test_cpu(cpu, data->cpumask))
    continue;

    data->csd.func(data->csd.info);

    spin_lock(&data->lock);
    - cpu_clear(cpu, data->cpumask);
    + cpumask_clear_cpu(cpu, data->cpumask);
    WARN_ON(data->refs == 0);
    data->refs--;
    refs = data->refs;
    @@ -273,7 +273,7 @@ static void quiesce_dummy(void *unused)
    /*
    * Ensure stack based data used in call function mask is safe to free.
    *
    - * This is needed by smp_call_function_mask when using on-stack data, because
    + * This is needed by smp_call_function_many when using on-stack data, because
    * a single call function queue is shared by all CPUs, and any CPU may pick up
    * the data item on the queue at any time before it is deleted. So we need to
    * ensure that all CPUs have transitioned through a quiescent state after
    @@ -287,7 +287,7 @@ static void quiesce_dummy(void *unused)
    * If a faster scheme can be made, we could go back to preferring stack based
    * data -- the data allocation/free is non-zero cost.
    */
    -static void smp_call_function_mask_quiesce_stack(const cpumask_t *mask)
    +static void smp_call_function_mask_quiesce_stack(const struct cpumask *mask)
    {
    struct call_single_data data;
    int cpu;
    @@ -295,21 +295,19 @@ static void smp_call_function_mask_quies
    data.func = quiesce_dummy;
    data.info = NULL;

    - for_each_cpu_mask_nr(cpu, *mask) {
    + for_each_cpu(cpu, mask) {
    data.flags = CSD_FLAG_WAIT;
    generic_exec_single(cpu, &data);
    }
    }

    /**
    - * smp_call_function_mask(): Run a function on a set of other CPUs.
    - * @mask: The set of cpus to run on.
    + * smp_call_function_many(): Run a function on a set of other CPUs.
    + * @mask: The set of cpus to run on (only runs on online subset).
    * @func: The function to run. This must be fast and non-blocking.
    * @info: An arbitrary pointer to pass to the function.
    * @wait: If true, wait (atomically) until function has completed on other CPUs.
    *
    - * Returns 0 on success, else a negative status code.
    - *
    * If @wait is true, then returns once @func has returned. Note that @wait
    * will be implicitly turned on in case of allocation failures, since
    * we fall back to on-stack allocation.
    @@ -318,11 +316,13 @@ static void smp_call_function_mask_quies
    * hardware interrupt handler or from a bottom half handler. Preemption
    * must be disabled when calling this function.
    */
    -int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
    - int wait)
    +void smp_call_function_many(const struct cpumask *mask,
    + void (*func)(void *), void *info,
    + bool wait)
    {
    struct call_function_data d;
    struct call_function_data *data = NULL;
    + cpumask_var_t allbutself;
    unsigned long flags;
    int cpu, num_cpus;
    int slowpath = 0;
    @@ -330,20 +330,28 @@ int smp_call_function_mask(cpumask_t mas
    /* Can deadlock when called with interrupts disabled */
    WARN_ON(irqs_disabled());

    - cpu = smp_processor_id();
    - cpus_and(mask, mask, cpu_online_map);
    - cpu_clear(cpu, mask);
    - num_cpus = cpus_weight(mask);
    + if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) {
    + /* Slow path. */
    + for_each_online_cpu(cpu) {
    + if (cpumask_test_cpu(cpu, mask))
    + smp_call_function_single(cpu, func, info, wait);
    + }
    + return;
    + }
    + cpumask_and(allbutself, cpu_online_mask, mask);
    + cpumask_clear_cpu(smp_processor_id(), allbutself);
    + num_cpus = cpumask_weight(allbutself);

    /*
    * If zero CPUs, return. If just a single CPU, turn this request
    * into a targetted single call instead since it's faster.
    */
    if (!num_cpus)
    - return 0;
    + return;
    else if (num_cpus == 1) {
    - cpu = first_cpu(mask);
    - return smp_call_function_single(cpu, func, info, wait);
    + cpu = cpumask_first(allbutself);
    + smp_call_function_single(cpu, func, info, wait);
    + goto out;
    }

    data = kmalloc(sizeof(*data), GFP_ATOMIC);
    @@ -362,25 +370,25 @@ int smp_call_function_mask(cpumask_t mas
    data->csd.func = func;
    data->csd.info = info;
    data->refs = num_cpus;
    - data->cpumask = mask;
    + data->cpumask = allbutself;

    spin_lock_irqsave(&call_function_lock, flags);
    list_add_tail_rcu(&data->csd.list, &call_function_queue);
    spin_unlock_irqrestore(&call_function_lock, flags);

    /* Send a message to all CPUs in the map */
    - arch_send_call_function_ipi(mask);
    + arch_send_call_function_ipi((cpumask_t)*allbutself );

    /* optionally wait for the CPUs to complete */
    if (wait) {
    csd_flag_wait(&data->csd);
    if (unlikely(slowpath))
    - smp_call_function_mask_quiesce_stack(&mask);
    + smp_call_function_mask_quiesce_stack(allbutself);
    }
    -
    - return 0;
    +out:
    + free_cpumask_var(allbutself);
    }
    -EXPORT_SYMBOL(smp_call_function_mask);
    +EXPORT_SYMBOL(smp_call_function_many);

    /**
    * smp_call_function(): Run a function on all other CPUs.
    @@ -388,7 +396,7 @@ EXPORT_SYMBOL(smp_call_function_mask);
    * @info: An arbitrary pointer to pass to the function.
    * @wait: If true, wait (atomically) until function has completed on other CPUs.
    *
    - * Returns 0 on success, else a negative status code.
    + * Returns 0.
    *
    * If @wait is true, then returns once @func has returned; otherwise
    * it returns just before the target cpu calls @func. In case of allocation
    @@ -399,12 +407,10 @@ EXPORT_SYMBOL(smp_call_function_mask);
    */
    int smp_call_function(void (*func)(void *), void *info, int wait)
    {
    - int ret;
    -
    preempt_disable();
    - ret = smp_call_function_mask(cpu_online_map, func, info, wait);
    + smp_call_function_many(cpu_online_mask, func, info, wait);
    preempt_enable();
    - return ret;
    + return 0;
    }
    EXPORT_SYMBOL(smp_call_function);


    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. [PATCH 02/35] x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers

    Change genapic interfaces to accept cpumask_t pointers where possible.

    Modify external callers to use cpumask_t pointers in function calls.

    Create new send_IPI_mask_allbutself which is the same as the
    send_IPI_mask functions but removes smp_processor_id() from list.
    This removes another common need for a temporary cpumask_t variable.

    Functions that used a temp cpumask_t variable for:

    cpumask_t allbutme = cpu_online_map;

    cpu_clear(smp_processor_id(), allbutme);
    if (!cpus_empty(allbutme))
    ...
    becomes:

    if (!cpus_equal(cpu_online_map, cpumask_of_cpu(cpu)))
    ...

    Other minor code optimizations (like using cpus_clear instead of
    CPU_MASK_NONE, etc.)


    Applies to linux-2.6.tip/master.

    Signed-off-by: Mike Travis
    Acked-by: Rusty Russell
    ---
    arch/x86/kernel/apic.c | 2
    arch/x86/kernel/crash.c | 5 -
    arch/x86/kernel/genapic_flat_64.c | 76 +++++++++++++------
    arch/x86/kernel/genx2apic_cluster.c | 60 ++++++++++-----
    arch/x86/kernel/genx2apic_phys.c | 55 +++++++++-----
    arch/x86/kernel/genx2apic_uv_x.c | 43 ++++++-----
    arch/x86/kernel/io_apic.c | 118 ++++++++++++++-----------------
    arch/x86/kernel/ipi.c | 26 ++++--
    arch/x86/kernel/smp.c | 6 -
    arch/x86/kernel/tlb_32.c | 2
    arch/x86/kernel/tlb_64.c | 2
    arch/x86/mach-generic/bigsmp.c | 5 -
    arch/x86/mach-generic/es7000.c | 5 -
    arch/x86/mach-generic/numaq.c | 5 -
    arch/x86/mach-generic/summit.c | 5 -
    arch/x86/xen/smp.c | 15 +--
    include/asm-x86/bigsmp/apic.h | 14 +--
    include/asm-x86/bigsmp/ipi.h | 9 +-
    include/asm-x86/es7000/apic.h | 22 ++---
    include/asm-x86/es7000/ipi.h | 9 +-
    include/asm-x86/genapic_32.h | 11 +-
    include/asm-x86/genapic_64.h | 11 +-
    include/asm-x86/ipi.h | 21 ++++-
    include/asm-x86/mach-default/mach_apic.h | 17 ++--
    include/asm-x86/mach-default/mach_ipi.h | 18 ++--
    include/asm-x86/numaq/apic.h | 4 -
    include/asm-x86/numaq/ipi.h | 9 +-
    include/asm-x86/summit/apic.h | 12 +--
    include/asm-x86/summit/ipi.h | 9 +-
    29 files changed, 347 insertions(+), 249 deletions(-)

    --- linux-2.6.28.orig/arch/x86/kernel/apic.c
    +++ linux-2.6.28/arch/x86/kernel/apic.c
    @@ -456,7 +456,7 @@ static void lapic_timer_setup(enum clock
    static void lapic_timer_broadcast(cpumask_t mask)
    {
    #ifdef CONFIG_SMP
    - send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
    + send_IPI_mask(&mask, LOCAL_TIMER_VECTOR);
    #endif
    }

    --- linux-2.6.28.orig/arch/x86/kernel/crash.c
    +++ linux-2.6.28/arch/x86/kernel/crash.c
    @@ -77,10 +77,7 @@ static int crash_nmi_callback(struct not

    static void smp_send_nmi_allbutself(void)
    {
    - cpumask_t mask = cpu_online_map;
    - cpu_clear(safe_smp_processor_id(), mask);
    - if (!cpus_empty(mask))
    - send_IPI_mask(mask, NMI_VECTOR);
    + send_IPI_allbutself(NMI_VECTOR);
    }

    static struct notifier_block crash_nmi_nb = {
    --- linux-2.6.28.orig/arch/x86/kernel/genapic_flat_64.c
    +++ linux-2.6.28/arch/x86/kernel/genapic_flat_64.c
    @@ -30,12 +30,12 @@ static int __init flat_acpi_madt_oem_che
    return 1;
    }

    -static cpumask_t flat_target_cpus(void)
    +static const cpumask_t *flat_target_cpus(void)
    {
    - return cpu_online_map;
    + return &cpu_online_map;
    }

    -static cpumask_t flat_vector_allocation_domain(int cpu)
    +static void flat_vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    /* Careful. Some cpus do not strictly honor the set of cpus
    * specified in the interrupt destination when using lowest
    @@ -45,8 +45,7 @@ static cpumask_t flat_vector_allocation_
    * deliver interrupts to the wrong hyperthread when only one
    * hyperthread was specified in the interrupt desitination.
    */
    - cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
    - return domain;
    + *retmask = (cpumask_t) { {[0] = APIC_ALL_CPUS, } };
    }

    /*
    @@ -69,9 +68,8 @@ static void flat_init_apic_ldr(void)
    apic_write(APIC_LDR, val);
    }

    -static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
    +static inline void _flat_send_IPI_mask(unsigned long mask, int vector)
    {
    - unsigned long mask = cpus_addr(cpumask)[0];
    unsigned long flags;

    local_irq_save(flags);
    @@ -79,20 +77,40 @@ static void flat_send_IPI_mask(cpumask_t
    local_irq_restore(flags);
    }

    +static void flat_send_IPI_mask(const cpumask_t *cpumask, int vector)
    +{
    + unsigned long mask = cpus_addr(*cpumask)[0];
    +
    + _flat_send_IPI_mask(mask, vector);
    +}
    +
    +static void flat_send_IPI_mask_allbutself(const cpumask_t *cpumask, int vector)
    +{
    + unsigned long mask = cpus_addr(*cpumask)[0];
    + int cpu = smp_processor_id();
    +
    + if (cpu < BITS_PER_LONG)
    + clear_bit(cpu, &mask);
    + _flat_send_IPI_mask(mask, vector);
    +}
    +
    static void flat_send_IPI_allbutself(int vector)
    {
    + int cpu = smp_processor_id();
    #ifdef CONFIG_HOTPLUG_CPU
    int hotplug = 1;
    #else
    int hotplug = 0;
    #endif
    if (hotplug || vector == NMI_VECTOR) {
    - cpumask_t allbutme = cpu_online_map;
    + if (!cpus_equal(cpu_online_map, cpumask_of_cpu(cpu))) {
    + unsigned long mask = cpus_addr(cpu_online_map)[0];

    - cpu_clear(smp_processor_id(), allbutme);
    + if (cpu < BITS_PER_LONG)
    + clear_bit(cpu, &mask);

    - if (!cpus_empty(allbutme))
    - flat_send_IPI_mask(allbutme, vector);
    + _flat_send_IPI_mask(mask, vector);
    + }
    } else if (num_online_cpus() > 1) {
    __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
    }
    @@ -101,7 +119,7 @@ static void flat_send_IPI_allbutself(int
    static void flat_send_IPI_all(int vector)
    {
    if (vector == NMI_VECTOR)
    - flat_send_IPI_mask(cpu_online_map, vector);
    + flat_send_IPI_mask(&cpu_online_map, vector);
    else
    __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
    }
    @@ -135,9 +153,9 @@ static int flat_apic_id_registered(void)
    return physid_isset(read_xapic_id(), phys_cpu_present_map);
    }

    -static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
    +static unsigned int flat_cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    - return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
    + return cpus_addr(*cpumask)[0] & APIC_ALL_CPUS;
    }

    static unsigned int phys_pkg_id(int index_msb)
    @@ -157,6 +175,7 @@ struct genapic apic_flat = {
    .send_IPI_all = flat_send_IPI_all,
    .send_IPI_allbutself = flat_send_IPI_allbutself,
    .send_IPI_mask = flat_send_IPI_mask,
    + .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,
    .send_IPI_self = apic_send_IPI_self,
    .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
    .phys_pkg_id = phys_pkg_id,
    @@ -188,35 +207,39 @@ static int __init physflat_acpi_madt_oem
    return 0;
    }

    -static cpumask_t physflat_target_cpus(void)
    +static const cpumask_t *physflat_target_cpus(void)
    {
    - return cpu_online_map;
    + return &cpu_online_map;
    }

    -static cpumask_t physflat_vector_allocation_domain(int cpu)
    +static void physflat_vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    - return cpumask_of_cpu(cpu);
    + cpus_clear(*retmask);
    + cpu_set(cpu, *retmask);
    }

    -static void physflat_send_IPI_mask(cpumask_t cpumask, int vector)
    +static void physflat_send_IPI_mask(const cpumask_t *cpumask, int vector)
    {
    send_IPI_mask_sequence(cpumask, vector);
    }

    -static void physflat_send_IPI_allbutself(int vector)
    +static void physflat_send_IPI_mask_allbutself(const cpumask_t *cpumask,
    + int vector)
    {
    - cpumask_t allbutme = cpu_online_map;
    + send_IPI_mask_allbutself(cpumask, vector);
    +}

    - cpu_clear(smp_processor_id(), allbutme);
    - physflat_send_IPI_mask(allbutme, vector);
    +static void physflat_send_IPI_allbutself(int vector)
    +{
    + send_IPI_mask_allbutself(&cpu_online_map, vector);
    }

    static void physflat_send_IPI_all(int vector)
    {
    - physflat_send_IPI_mask(cpu_online_map, vector);
    + physflat_send_IPI_mask(&cpu_online_map, vector);
    }

    -static unsigned int physflat_cpu_mask_to_apicid(cpumask_t cpumask)
    +static unsigned int physflat_cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int cpu;

    @@ -224,7 +247,7 @@ static unsigned int physflat_cpu_mask_to
    * We're using fixed IRQ delivery, can only return one phys APIC ID.
    * May as well be the first.
    */
    - cpu = first_cpu(cpumask);
    + cpu = first_cpu(*cpumask);
    if ((unsigned)cpu < nr_cpu_ids)
    return per_cpu(x86_cpu_to_apicid, cpu);
    else
    @@ -243,6 +266,7 @@ struct genapic apic_physflat = {
    .send_IPI_all = physflat_send_IPI_all,
    .send_IPI_allbutself = physflat_send_IPI_allbutself,
    .send_IPI_mask = physflat_send_IPI_mask,
    + .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
    .send_IPI_self = apic_send_IPI_self,
    .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
    .phys_pkg_id = phys_pkg_id,
    --- linux-2.6.28.orig/arch/x86/kernel/genx2apic_cluster.c
    +++ linux-2.6.28/arch/x86/kernel/genx2apic_cluster.c
    @@ -22,19 +22,18 @@ static int __init x2apic_acpi_madt_oem_c

    /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */

    -static cpumask_t x2apic_target_cpus(void)
    +static const cpumask_t *x2apic_target_cpus(void)
    {
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    }

    /*
    * for now each logical cpu is in its own vector allocation domain.
    */
    -static cpumask_t x2apic_vector_allocation_domain(int cpu)
    +static void x2apic_vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    - cpumask_t domain = CPU_MASK_NONE;
    - cpu_set(cpu, domain);
    - return domain;
    + cpus_clear(*retmask);
    + cpu_set(cpu, *retmask);
    }

    static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
    @@ -56,32 +55,52 @@ static void __x2apic_send_IPI_dest(unsig
    * at once. We have 16 cpu's in a cluster. This will minimize IPI register
    * writes.
    */
    -static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
    +static void x2apic_send_IPI_mask(const cpumask_t *mask, int vector)
    {
    unsigned long flags;
    unsigned long query_cpu;

    local_irq_save(flags);
    - for_each_cpu_mask(query_cpu, mask) {
    - __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_logical_ apicid, query_cpu),
    - vector, APIC_DEST_LOGICAL);
    - }
    + for_each_cpu_mask_and(query_cpu, *mask, cpu_online_map)
    + __x2apic_send_IPI_dest(
    + per_cpu(x86_cpu_to_logical_apicid, query_cpu),
    + vector, APIC_DEST_LOGICAL);
    local_irq_restore(flags);
    }

    -static void x2apic_send_IPI_allbutself(int vector)
    +static void x2apic_send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
    {
    - cpumask_t mask = cpu_online_map;
    + unsigned long flags;
    + unsigned long query_cpu;
    + unsigned long this_cpu = smp_processor_id();

    - cpu_clear(smp_processor_id(), mask);
    + local_irq_save(flags);
    + for_each_cpu_mask_and(query_cpu, *mask, cpu_online_map)
    + if (query_cpu != this_cpu)
    + __x2apic_send_IPI_dest(
    + per_cpu(x86_cpu_to_logical_apicid, query_cpu),
    + vector, APIC_DEST_LOGICAL);
    + local_irq_restore(flags);
    +}

    - if (!cpus_empty(mask))
    - x2apic_send_IPI_mask(mask, vector);
    +static void x2apic_send_IPI_allbutself(int vector)
    +{
    + unsigned long flags;
    + unsigned long query_cpu;
    + unsigned long this_cpu = smp_processor_id();
    +
    + local_irq_save(flags);
    + for_each_online_cpu(query_cpu)
    + if (query_cpu != this_cpu)
    + __x2apic_send_IPI_dest(
    + per_cpu(x86_cpu_to_logical_apicid, query_cpu),
    + vector, APIC_DEST_LOGICAL);
    + local_irq_restore(flags);
    }

    static void x2apic_send_IPI_all(int vector)
    {
    - x2apic_send_IPI_mask(cpu_online_map, vector);
    + x2apic_send_IPI_mask(&cpu_online_map, vector);
    }

    static int x2apic_apic_id_registered(void)
    @@ -89,7 +108,7 @@ static int x2apic_apic_id_registered(voi
    return 1;
    }

    -static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
    +static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int cpu;

    @@ -97,8 +116,8 @@ static unsigned int x2apic_cpu_mask_to_a
    * We're using fixed IRQ delivery, can only return one phys APIC ID.
    * May as well be the first.
    */
    - cpu = first_cpu(cpumask);
    - if ((unsigned)cpu < NR_CPUS)
    + cpu = first_cpu(*cpumask);
    + if ((unsigned)cpu < nr_cpu_ids)
    return per_cpu(x86_cpu_to_logical_apicid, cpu);
    else
    return BAD_APICID;
    @@ -150,6 +169,7 @@ struct genapic apic_x2apic_cluster = {
    .send_IPI_all = x2apic_send_IPI_all,
    .send_IPI_allbutself = x2apic_send_IPI_allbutself,
    .send_IPI_mask = x2apic_send_IPI_mask,
    + .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
    .send_IPI_self = x2apic_send_IPI_self,
    .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
    .phys_pkg_id = phys_pkg_id,
    --- linux-2.6.28.orig/arch/x86/kernel/genx2apic_phys.c
    +++ linux-2.6.28/arch/x86/kernel/genx2apic_phys.c
    @@ -29,16 +29,15 @@ static int __init x2apic_acpi_madt_oem_c

    /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */

    -static cpumask_t x2apic_target_cpus(void)
    +static const cpumask_t *x2apic_target_cpus(void)
    {
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    }

    -static cpumask_t x2apic_vector_allocation_domain(int cpu)
    +static void x2apic_vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    - cpumask_t domain = CPU_MASK_NONE;
    - cpu_set(cpu, domain);
    - return domain;
    + cpus_clear(*retmask);
    + cpu_set(cpu, *retmask);
    }

    static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
    @@ -54,32 +53,51 @@ static void __x2apic_send_IPI_dest(unsig
    x2apic_icr_write(cfg, apicid);
    }

    -static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
    +static void x2apic_send_IPI_mask(const cpumask_t *mask, int vector)
    {
    unsigned long flags;
    unsigned long query_cpu;

    local_irq_save(flags);
    - for_each_cpu_mask(query_cpu, mask) {
    + for_each_cpu_mask_and(query_cpu, *mask, cpu_online_map)
    __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
    vector, APIC_DEST_PHYSICAL);
    - }
    local_irq_restore(flags);
    }

    -static void x2apic_send_IPI_allbutself(int vector)
    +static void x2apic_send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
    {
    - cpumask_t mask = cpu_online_map;
    + unsigned long flags;
    + unsigned long query_cpu;
    + unsigned long this_cpu = smp_processor_id();

    - cpu_clear(smp_processor_id(), mask);
    + local_irq_save(flags);
    + for_each_cpu_mask_and(query_cpu, *mask, cpu_online_map)
    + if (query_cpu != this_cpu)
    + __x2apic_send_IPI_dest(
    + per_cpu(x86_cpu_to_apicid, query_cpu),
    + vector, APIC_DEST_PHYSICAL);
    + local_irq_restore(flags);
    +}

    - if (!cpus_empty(mask))
    - x2apic_send_IPI_mask(mask, vector);
    +static void x2apic_send_IPI_allbutself(int vector)
    +{
    + unsigned long flags;
    + unsigned long query_cpu;
    + unsigned long this_cpu = smp_processor_id();
    +
    + local_irq_save(flags);
    + for_each_online_cpu(query_cpu)
    + if (query_cpu != this_cpu)
    + __x2apic_send_IPI_dest(
    + per_cpu(x86_cpu_to_apicid, query_cpu),
    + vector, APIC_DEST_PHYSICAL);
    + local_irq_restore(flags);
    }

    static void x2apic_send_IPI_all(int vector)
    {
    - x2apic_send_IPI_mask(cpu_online_map, vector);
    + x2apic_send_IPI_mask(&cpu_online_map, vector);
    }

    static int x2apic_apic_id_registered(void)
    @@ -87,7 +105,7 @@ static int x2apic_apic_id_registered(voi
    return 1;
    }

    -static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
    +static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int cpu;

    @@ -95,8 +113,8 @@ static unsigned int x2apic_cpu_mask_to_a
    * We're using fixed IRQ delivery, can only return one phys APIC ID.
    * May as well be the first.
    */
    - cpu = first_cpu(cpumask);
    - if ((unsigned)cpu < NR_CPUS)
    + cpu = first_cpu(*cpumask);
    + if ((unsigned)cpu < nr_cpu_ids)
    return per_cpu(x86_cpu_to_apicid, cpu);
    else
    return BAD_APICID;
    @@ -145,6 +163,7 @@ struct genapic apic_x2apic_phys = {
    .send_IPI_all = x2apic_send_IPI_all,
    .send_IPI_allbutself = x2apic_send_IPI_allbutself,
    .send_IPI_mask = x2apic_send_IPI_mask,
    + .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
    .send_IPI_self = x2apic_send_IPI_self,
    .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
    .phys_pkg_id = phys_pkg_id,
    --- linux-2.6.28.orig/arch/x86/kernel/genx2apic_uv_x.c
    +++ linux-2.6.28/arch/x86/kernel/genx2apic_uv_x.c
    @@ -76,16 +76,15 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);

    /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */

    -static cpumask_t uv_target_cpus(void)
    +static const cpumask_t *uv_target_cpus(void)
    {
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    }

    -static cpumask_t uv_vector_allocation_domain(int cpu)
    +static void uv_vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    - cpumask_t domain = CPU_MASK_NONE;
    - cpu_set(cpu, domain);
    - return domain;
    + cpus_clear(*retmask);
    + cpu_set(cpu, *retmask);
    }

    int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip)
    @@ -124,28 +123,37 @@ static void uv_send_IPI_one(int cpu, int
    uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
    }

    -static void uv_send_IPI_mask(cpumask_t mask, int vector)
    +static void uv_send_IPI_mask(const cpumask_t *mask, int vector)
    {
    unsigned int cpu;

    - for_each_possible_cpu(cpu)
    - if (cpu_isset(cpu, mask))
    + for_each_cpu_mask_and(cpu, *mask, cpu_online_map)
    + uv_send_IPI_one(cpu, vector);
    +}
    +
    +static void uv_send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
    +{
    + unsigned int cpu;
    + unsigned int this_cpu = smp_processor_id();
    +
    + for_each_cpu_mask_and(cpu, *mask, cpu_online_map)
    + if (cpu != this_cpu)
    uv_send_IPI_one(cpu, vector);
    }

    static void uv_send_IPI_allbutself(int vector)
    {
    - cpumask_t mask = cpu_online_map;
    -
    - cpu_clear(smp_processor_id(), mask);
    + unsigned int cpu;
    + unsigned int this_cpu = smp_processor_id();

    - if (!cpus_empty(mask))
    - uv_send_IPI_mask(mask, vector);
    + for_each_online_cpu(cpu)
    + if (cpu != this_cpu)
    + uv_send_IPI_one(cpu, vector);
    }

    static void uv_send_IPI_all(int vector)
    {
    - uv_send_IPI_mask(cpu_online_map, vector);
    + uv_send_IPI_mask(&cpu_online_map, vector);
    }

    static int uv_apic_id_registered(void)
    @@ -157,7 +165,7 @@ static void uv_init_apic_ldr(void)
    {
    }

    -static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
    +static unsigned int uv_cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int cpu;

    @@ -165,7 +173,7 @@ static unsigned int uv_cpu_mask_to_apici
    * We're using fixed IRQ delivery, can only return one phys APIC ID.
    * May as well be the first.
    */
    - cpu = first_cpu(cpumask);
    + cpu = first_cpu(*cpumask);
    if ((unsigned)cpu < nr_cpu_ids)
    return per_cpu(x86_cpu_to_apicid, cpu);
    else
    @@ -219,6 +227,7 @@ struct genapic apic_x2apic_uv_x = {
    .send_IPI_all = uv_send_IPI_all,
    .send_IPI_allbutself = uv_send_IPI_allbutself,
    .send_IPI_mask = uv_send_IPI_mask,
    + .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself,
    .send_IPI_self = uv_send_IPI_self,
    .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
    .phys_pkg_id = phys_pkg_id,
    --- linux-2.6.28.orig/arch/x86/kernel/io_apic.c
    +++ linux-2.6.28/arch/x86/kernel/io_apic.c
    @@ -359,7 +359,7 @@ static void __target_IO_APIC_irq(unsigne
    }
    }

    -static int assign_irq_vector(int irq, cpumask_t mask);
    +static int assign_irq_vector(int irq, const cpumask_t *mask);

    static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
    {
    @@ -373,12 +373,12 @@ static void set_ioapic_affinity_irq(unsi
    if (cpus_empty(tmp))
    return;

    - cfg = irq_cfg(irq);
    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    + cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);
    /*
    * Only the high 8 bits are valid.
    */
    @@ -1034,7 +1034,7 @@ void unlock_vector_lock(void)
    spin_unlock(&vector_lock);
    }

    -static int __assign_irq_vector(int irq, cpumask_t mask)
    +static int __assign_irq_vector(int irq, const cpumask_t *mask)
    {
    /*
    * NOTE! The local APIC isn't very good at handling
    @@ -1051,37 +1051,33 @@ static int __assign_irq_vector(int irq,
    unsigned int old_vector;
    int cpu;
    struct irq_cfg *cfg;
    + cpumask_t tmp_mask;

    cfg = irq_cfg(irq);
    -
    - /* Only try and allocate irqs on cpus that are present */
    - cpus_and(mask, mask, cpu_online_map);
    -
    if ((cfg->move_in_progress) || cfg->move_cleanup_count)
    return -EBUSY;

    old_vector = cfg->vector;
    if (old_vector) {
    - cpumask_t tmp;
    - cpus_and(tmp, cfg->domain, mask);
    - if (!cpus_empty(tmp))
    + cpus_and(tmp_mask, *mask, cpu_online_map);
    + cpus_and(tmp_mask, cfg->domain, tmp_mask);
    + if (!cpus_empty(tmp_mask))
    return 0;
    }

    - for_each_cpu_mask_nr(cpu, mask) {
    - cpumask_t domain, new_mask;
    + /* Only try and allocate irqs on cpus that are present */
    + for_each_cpu_mask_and(cpu, *mask, cpu_online_map) {
    int new_cpu;
    int vector, offset;

    - domain = vector_allocation_domain(cpu);
    - cpus_and(new_mask, domain, cpu_online_map);
    + vector_allocation_domain(cpu, &tmp_mask);

    vector = current_vector;
    offset = current_offset;
    next:
    vector += 8;
    if (vector >= first_system_vector) {
    - /* If we run out of vectors on large boxen, must share them. */
    + /* If out of vectors on large boxen, must share them. */
    offset = (offset + 1) % 8;
    vector = FIRST_DEVICE_VECTOR + offset;
    }
    @@ -1094,7 +1090,7 @@ next:
    if (vector == SYSCALL_VECTOR)
    goto next;
    #endif
    - for_each_cpu_mask_nr(new_cpu, new_mask)
    + for_each_cpu_mask_and(new_cpu, tmp_mask, cpu_online_map)
    if (per_cpu(vector_irq, new_cpu)[vector] != -1)
    goto next;
    /* Found one! */
    @@ -1104,16 +1100,16 @@ next:
    cfg->move_in_progress = 1;
    cfg->old_domain = cfg->domain;
    }
    - for_each_cpu_mask_nr(new_cpu, new_mask)
    + for_each_cpu_mask_and(new_cpu, tmp_mask, cpu_online_map)
    per_cpu(vector_irq, new_cpu)[vector] = irq;
    cfg->vector = vector;
    - cfg->domain = domain;
    + cfg->domain = tmp_mask;
    return 0;
    }
    return -ENOSPC;
    }

    -static int assign_irq_vector(int irq, cpumask_t mask)
    +static int assign_irq_vector(int irq, const cpumask_t *mask)
    {
    int err;
    unsigned long flags;
    @@ -1309,8 +1305,8 @@ static void setup_IO_APIC_irq(int apic,

    cfg = irq_cfg(irq);

    - mask = TARGET_CPUS;
    - if (assign_irq_vector(irq, mask))
    + mask = *TARGET_CPUS;
    + if (assign_irq_vector(irq, &mask))
    return;

    cpus_and(mask, cfg->domain, mask);
    @@ -1323,7 +1319,7 @@ static void setup_IO_APIC_irq(int apic,


    if (setup_ioapic_entry(mp_ioapics[apic].mp_apicid, irq, &entry,
    - cpu_mask_to_apicid(mask), trigger, polarity,
    + cpu_mask_to_apicid(&mask), trigger, polarity,
    cfg->vector)) {
    printk("Failed to setup ioapic entry for ioapic %d, pin %d\n",
    mp_ioapics[apic].mp_apicid, pin);
    @@ -2029,7 +2025,7 @@ static int ioapic_retrigger_irq(unsigned
    unsigned long flags;

    spin_lock_irqsave(&vector_lock, flags);
    - send_IPI_mask(cpumask_of_cpu(first_cpu(cfg->domain)), cfg->vector);
    + send_IPI_mask(&cpumask_of_cpu(first_cpu(cfg->domain)), cfg->vector);
    spin_unlock_irqrestore(&vector_lock, flags);

    return 1;
    @@ -2078,18 +2074,18 @@ static DECLARE_DELAYED_WORK(ir_migration
    * as simple as edge triggered migration and we can do the irq migration
    * with a simple atomic update to IO-APIC RTE.
    */
    -static void migrate_ioapic_irq(int irq, cpumask_t mask)
    +static void migrate_ioapic_irq(int irq, const cpumask_t *mask)
    {
    struct irq_cfg *cfg;
    struct irq_desc *desc;
    - cpumask_t tmp, cleanup_mask;
    + cpumask_t tmpmask;
    struct irte irte;
    int modify_ioapic_rte;
    unsigned int dest;
    unsigned long flags;

    - cpus_and(tmp, mask, cpu_online_map);
    - if (cpus_empty(tmp))
    + cpus_and(tmpmask, *mask, cpu_online_map);
    + if (cpus_empty(tmpmask))
    return;

    if (get_irte(irq, &irte))
    @@ -2099,8 +2095,8 @@ static void migrate_ioapic_irq(int irq,
    return;

    cfg = irq_cfg(irq);
    - cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + cpus_and(tmpmask, cfg->domain, *mask);
    + dest = cpu_mask_to_apicid(&tmpmask);

    desc = irq_to_desc(irq);
    modify_ioapic_rte = desc->status & IRQ_LEVEL;
    @@ -2119,13 +2115,13 @@ static void migrate_ioapic_irq(int irq,
    modify_irte(irq, &irte);

    if (cfg->move_in_progress) {
    - cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
    - cfg->move_cleanup_count = cpus_weight(cleanup_mask);
    - send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
    + cpus_and(tmpmask, cfg->old_domain, cpu_online_map);
    + cfg->move_cleanup_count = cpus_weight(tmpmask);
    + send_IPI_mask(&tmpmask, IRQ_MOVE_CLEANUP_VECTOR);
    cfg->move_in_progress = 0;
    }

    - desc->affinity = mask;
    + desc->affinity = *mask;
    }

    static int migrate_irq_remapped_level(int irq)
    @@ -2147,7 +2143,7 @@ static int migrate_irq_remapped_level(in
    }

    /* everthing is clear. we have right of way */
    - migrate_ioapic_irq(irq, desc->pending_mask);
    + migrate_ioapic_irq(irq, &desc->pending_mask);

    ret = 0;
    desc->status &= ~IRQ_MOVE_PENDING;
    @@ -2195,7 +2191,7 @@ static void set_ir_ioapic_affinity_irq(u
    return;
    }

    - migrate_ioapic_irq(irq, mask);
    + migrate_ioapic_irq(irq, &mask);
    }
    #endif

    @@ -2251,7 +2247,7 @@ static void irq_complete_move(unsigned i

    cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
    cfg->move_cleanup_count = cpus_weight(cleanup_mask);
    - send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
    + send_IPI_mask(&cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
    cfg->move_in_progress = 0;
    }
    }
    @@ -2952,14 +2948,14 @@ static int msi_compose_msg(struct pci_de
    unsigned dest;
    cpumask_t tmp;

    - tmp = TARGET_CPUS;
    - err = assign_irq_vector(irq, tmp);
    + tmp = *TARGET_CPUS;
    + err = assign_irq_vector(irq, &tmp);
    if (err)
    return err;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, tmp);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    #ifdef CONFIG_INTR_REMAP
    if (irq_remapped(irq)) {
    @@ -3025,12 +3021,12 @@ static void set_msi_irq_affinity(unsigne
    if (cpus_empty(tmp))
    return;

    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    read_msi_msg(irq, &msg);

    @@ -3064,12 +3060,12 @@ static void ir_set_msi_irq_affinity(unsi
    if (get_irte(irq, &irte))
    return;

    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    irte.vector = cfg->vector;
    irte.dest_id = IRTE_DEST(dest);
    @@ -3087,7 +3083,7 @@ static void ir_set_msi_irq_affinity(unsi
    if (cfg->move_in_progress) {
    cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
    cfg->move_cleanup_count = cpus_weight(cleanup_mask);
    - send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
    + send_IPI_mask(&cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
    cfg->move_in_progress = 0;
    }

    @@ -3306,12 +3302,12 @@ static void dmar_msi_set_affinity(unsign
    if (cpus_empty(tmp))
    return;

    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    dmar_msi_read(irq, &msg);

    @@ -3367,12 +3363,12 @@ static void hpet_msi_set_affinity(unsign
    if (cpus_empty(tmp))
    return;

    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    hpet_msi_read(irq, &msg);

    @@ -3448,12 +3444,12 @@ static void set_ht_irq_affinity(unsigned
    if (cpus_empty(tmp))
    return;

    - if (assign_irq_vector(irq, mask))
    + if (assign_irq_vector(irq, &mask))
    return;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, mask);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    target_ht_irq(irq, dest, cfg->vector);
    desc = irq_to_desc(irq);
    @@ -3478,15 +3474,15 @@ int arch_setup_ht_irq(unsigned int irq,
    int err;
    cpumask_t tmp;

    - tmp = TARGET_CPUS;
    - err = assign_irq_vector(irq, tmp);
    + tmp = *TARGET_CPUS;
    + err = assign_irq_vector(irq, &tmp);
    if (!err) {
    struct ht_irq_msg msg;
    unsigned dest;

    cfg = irq_cfg(irq);
    cpus_and(tmp, cfg->domain, tmp);
    - dest = cpu_mask_to_apicid(tmp);
    + dest = cpu_mask_to_apicid(&tmp);

    msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);

    @@ -3522,7 +3518,7 @@ int arch_setup_ht_irq(unsigned int irq,
    int arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
    unsigned long mmr_offset)
    {
    - const cpumask_t *eligible_cpu = get_cpu_mask(cpu);
    + const cpumask_t *eligible_cpu = &cpumask_of_cpu(cpu);
    struct irq_cfg *cfg;
    int mmr_pnode;
    unsigned long mmr_value;
    @@ -3530,8 +3526,8 @@ int arch_enable_uv_irq(char *irq_name, u
    unsigned long flags;
    int err;

    - err = assign_irq_vector(irq, *eligible_cpu);
    - if (err != 0)
    + err = assign_irq_vector(irq, eligible_cpu);
    + if (err)
    return err;

    spin_lock_irqsave(&vector_lock, flags);
    @@ -3551,7 +3547,7 @@ int arch_enable_uv_irq(char *irq_name, u
    entry->polarity = 0;
    entry->trigger = 0;
    entry->mask = 0;
    - entry->dest = cpu_mask_to_apicid(*eligible_cpu);
    + entry->dest = cpu_mask_to_apicid(eligible_cpu);

    mmr_pnode = uv_blade_to_pnode(mmr_blade);
    uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
    @@ -3782,10 +3778,10 @@ void __init setup_ioapic_dest(void)
    irq_polarity(irq_entry));
    #ifdef CONFIG_INTR_REMAP
    else if (intr_remapping_enabled)
    - set_ir_ioapic_affinity_irq(irq, TARGET_CPUS);
    + set_ir_ioapic_affinity_irq(irq, *TARGET_CPUS);
    #endif
    else
    - set_ioapic_affinity_irq(irq, TARGET_CPUS);
    + set_ioapic_affinity_irq(irq, *TARGET_CPUS);
    }

    }
    --- linux-2.6.28.orig/arch/x86/kernel/ipi.c
    +++ linux-2.6.28/arch/x86/kernel/ipi.c
    @@ -116,9 +116,9 @@ static inline void __send_IPI_dest_field
    /*
    * This is only used on smaller machines.
    */
    -void send_IPI_mask_bitmask(cpumask_t cpumask, int vector)
    +void send_IPI_mask_bitmask(const cpumask_t *cpumask, int vector)
    {
    - unsigned long mask = cpus_addr(cpumask)[0];
    + unsigned long mask = cpus_addr(*cpumask)[0];
    unsigned long flags;

    local_irq_save(flags);
    @@ -127,7 +127,7 @@ void send_IPI_mask_bitmask(cpumask_t cpu
    local_irq_restore(flags);
    }

    -void send_IPI_mask_sequence(cpumask_t mask, int vector)
    +void send_IPI_mask_sequence(const cpumask_t *mask, int vector)
    {
    unsigned long flags;
    unsigned int query_cpu;
    @@ -139,12 +139,24 @@ void send_IPI_mask_sequence(cpumask_t ma
    */

    local_irq_save(flags);
    - for_each_possible_cpu(query_cpu) {
    - if (cpu_isset(query_cpu, mask)) {
    + for_each_cpu_mask_nr(query_cpu, *mask)
    + __send_IPI_dest_field(cpu_to_logical_apicid(query_ cpu), vector);
    + local_irq_restore(flags);
    +}
    +
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
    +{
    + unsigned long flags;
    + unsigned int query_cpu;
    + unsigned int this_cpu = smp_processor_id();
    +
    + /* See Hack comment above */
    +
    + local_irq_save(flags);
    + for_each_cpu_mask_nr(query_cpu, *mask)
    + if (query_cpu != this_cpu)
    __send_IPI_dest_field(cpu_to_logical_apicid(query_ cpu),
    vector);
    - }
    - }
    local_irq_restore(flags);
    }

    --- linux-2.6.28.orig/arch/x86/kernel/smp.c
    +++ linux-2.6.28/arch/x86/kernel/smp.c
    @@ -118,12 +118,12 @@ static void native_smp_send_reschedule(i
    WARN_ON(1);
    return;
    }
    - send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
    + send_IPI_mask(&cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
    }

    void native_send_call_func_single_ipi(int cpu)
    {
    - send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_SINGLE_VECTOR);
    + send_IPI_mask(&cpumask_of_cpu(cpu), CALL_FUNCTION_SINGLE_VECTOR);
    }

    void native_send_call_func_ipi(const cpumask_t *mask)
    @@ -137,7 +137,7 @@ void native_send_call_func_ipi(const cpu
    cpus_equal(cpu_online_map, cpu_callout_map))
    send_IPI_allbutself(CALL_FUNCTION_VECTOR);
    else
    - send_IPI_mask(*mask, CALL_FUNCTION_VECTOR);
    + send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
    }

    static void stop_this_cpu(void *dummy)
    --- linux-2.6.28.orig/arch/x86/kernel/tlb_32.c
    +++ linux-2.6.28/arch/x86/kernel/tlb_32.c
    @@ -158,7 +158,7 @@ void native_flush_tlb_others(const cpuma
    * We have to send the IPI only to
    * CPUs affected.
    */
    - send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR);
    + send_IPI_mask(&cpumask, INVALIDATE_TLB_VECTOR);

    while (!cpus_empty(flush_cpumask))
    /* nothing. lockup detection does not belong here */
    --- linux-2.6.28.orig/arch/x86/kernel/tlb_64.c
    +++ linux-2.6.28/arch/x86/kernel/tlb_64.c
    @@ -186,7 +186,7 @@ void native_flush_tlb_others(const cpuma
    * We have to send the IPI only to
    * CPUs affected.
    */
    - send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR_START + sender);
    + send_IPI_mask(&cpumask, INVALIDATE_TLB_VECTOR_START + sender);

    while (!cpus_empty(f->flush_cpumask))
    cpu_relax();
    --- linux-2.6.28.orig/arch/x86/mach-generic/bigsmp.c
    +++ linux-2.6.28/arch/x86/mach-generic/bigsmp.c
    @@ -41,9 +41,10 @@ static const struct dmi_system_id bigsmp
    { }
    };

    -static cpumask_t vector_allocation_domain(int cpu)
    +static void vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    - return cpumask_of_cpu(cpu);
    + cpus_clear(*retmask);
    + cpu_set(cpu, *retmask);
    }

    static int probe_bigsmp(void)
    --- linux-2.6.28.orig/arch/x86/mach-generic/es7000.c
    +++ linux-2.6.28/arch/x86/mach-generic/es7000.c
    @@ -75,7 +75,7 @@ static int __init acpi_madt_oem_check(ch
    }
    #endif

    -static cpumask_t vector_allocation_domain(int cpu)
    +static void vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    /* Careful. Some cpus do not strictly honor the set of cpus
    * specified in the interrupt destination when using lowest
    @@ -85,8 +85,7 @@ static cpumask_t vector_allocation_domai
    * deliver interrupts to the wrong hyperthread when only one
    * hyperthread was specified in the interrupt desitination.
    */
    - cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
    - return domain;
    + *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
    }

    struct genapic __initdata_refok apic_es7000 = APIC_INIT("es7000", probe_es7000);
    --- linux-2.6.28.orig/arch/x86/mach-generic/numaq.c
    +++ linux-2.6.28/arch/x86/mach-generic/numaq.c
    @@ -38,7 +38,7 @@ static int acpi_madt_oem_check(char *oem
    return 0;
    }

    -static cpumask_t vector_allocation_domain(int cpu)
    +static void vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    /* Careful. Some cpus do not strictly honor the set of cpus
    * specified in the interrupt destination when using lowest
    @@ -48,8 +48,7 @@ static cpumask_t vector_allocation_domai
    * deliver interrupts to the wrong hyperthread when only one
    * hyperthread was specified in the interrupt desitination.
    */
    - cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
    - return domain;
    + *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
    }

    struct genapic apic_numaq = APIC_INIT("NUMAQ", probe_numaq);
    --- linux-2.6.28.orig/arch/x86/mach-generic/summit.c
    +++ linux-2.6.28/arch/x86/mach-generic/summit.c
    @@ -23,7 +23,7 @@ static int probe_summit(void)
    return 0;
    }

    -static cpumask_t vector_allocation_domain(int cpu)
    +static void vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    /* Careful. Some cpus do not strictly honor the set of cpus
    * specified in the interrupt destination when using lowest
    @@ -33,8 +33,7 @@ static cpumask_t vector_allocation_domai
    * deliver interrupts to the wrong hyperthread when only one
    * hyperthread was specified in the interrupt desitination.
    */
    - cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
    - return domain;
    + *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
    }

    struct genapic apic_summit = APIC_INIT("summit", probe_summit);
    --- linux-2.6.28.orig/arch/x86/xen/smp.c
    +++ linux-2.6.28/arch/x86/xen/smp.c
    @@ -158,7 +158,7 @@ static void __init xen_fill_possible_map
    {
    int i, rc;

    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
    if (rc >= 0) {
    num_processors++;
    @@ -196,7 +196,7 @@ static void __init xen_smp_prepare_cpus(

    /* Restrict the possible_map according to max_cpus. */
    while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) {
    - for (cpu = NR_CPUS - 1; !cpu_possible(cpu); cpu--)
    + for (cpu = nr_cpu_ids - 1; !cpu_possible(cpu); cpu--)
    continue;
    cpu_clear(cpu, cpu_possible_map);
    }
    @@ -408,13 +408,11 @@ static void xen_smp_send_reschedule(int
    xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR);
    }

    -static void xen_send_IPI_mask(cpumask_t mask, enum ipi_vector vector)
    +static void xen_send_IPI_mask(const cpumask_t *mask, enum ipi_vector vector)
    {
    unsigned cpu;

    - cpus_and(mask, mask, cpu_online_map);
    -
    - for_each_cpu_mask_nr(cpu, mask)
    + for_each_cpu_mask_and(cpu, *mask, cpu_online_map)
    xen_send_IPI_one(cpu, vector);
    }

    @@ -422,7 +420,7 @@ static void xen_smp_send_call_function_i
    {
    int cpu;

    - xen_send_IPI_mask(*mask, XEN_CALL_FUNCTION_VECTOR);
    + xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);

    /* Make sure other vcpus get a chance to run if they need to. */
    for_each_cpu_mask_nr(cpu, *mask) {
    @@ -435,7 +433,8 @@ static void xen_smp_send_call_function_i

    static void xen_smp_send_call_function_single_ipi(int cpu)
    {
    - xen_send_IPI_mask(cpumask_of_cpu(cpu), XEN_CALL_FUNCTION_SINGLE_VECTOR);
    + xen_send_IPI_mask(&cpumask_of_cpu(cpu),
    + XEN_CALL_FUNCTION_SINGLE_VECTOR);
    }

    static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)
    --- linux-2.6.28.orig/include/asm-x86/bigsmp/apic.h
    +++ linux-2.6.28/include/asm-x86/bigsmp/apic.h
    @@ -9,12 +9,12 @@ static inline int apic_id_registered(voi
    return (1);
    }

    -static inline cpumask_t target_cpus(void)
    +static inline const cpumask_t *target_cpus(void)
    {
    #ifdef CONFIG_SMP
    - return cpu_online_map;
    + return &cpu_online_map;
    #else
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    #endif
    }

    @@ -81,7 +81,7 @@ static inline int apicid_to_node(int log

    static inline int cpu_present_to_apicid(int mps_cpu)
    {
    - if (mps_cpu < NR_CPUS)
    + if (mps_cpu < nr_cpu_ids)
    return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);

    return BAD_APICID;
    @@ -96,7 +96,7 @@ extern u8 cpu_2_logical_apicid[];
    /* Mapping from cpu number to logical apicid */
    static inline int cpu_to_logical_apicid(int cpu)
    {
    - if (cpu >= NR_CPUS)
    + if (cpu >= nr_cpu_ids)
    return BAD_APICID;
    return cpu_physical_id(cpu);
    }
    @@ -121,12 +121,12 @@ static inline int check_phys_apicid_pres
    }

    /* As we are using single CPU as destination, pick only one CPU here */
    -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
    +static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int cpu;
    int apicid;

    - cpu = first_cpu(cpumask);
    + cpu = first_cpu(*cpumask);
    apicid = cpu_to_logical_apicid(cpu);
    return apicid;
    }
    --- linux-2.6.28.orig/include/asm-x86/bigsmp/ipi.h
    +++ linux-2.6.28/include/asm-x86/bigsmp/ipi.h
    @@ -1,9 +1,10 @@
    #ifndef __ASM_MACH_IPI_H
    #define __ASM_MACH_IPI_H

    -void send_IPI_mask_sequence(cpumask_t mask, int vector);
    +void send_IPI_mask_sequence(const cpumask_t *mask, int vector);
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);

    -static inline void send_IPI_mask(cpumask_t mask, int vector)
    +static inline void send_IPI_mask(const cpumask_t *mask, int vector)
    {
    send_IPI_mask_sequence(mask, vector);
    }
    @@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(i
    cpu_clear(smp_processor_id(), mask);

    if (!cpus_empty(mask))
    - send_IPI_mask(mask, vector);
    + send_IPI_mask(&mask, vector);
    }

    static inline void send_IPI_all(int vector)
    {
    - send_IPI_mask(cpu_online_map, vector);
    + send_IPI_mask(&cpu_online_map, vector);
    }

    #endif /* __ASM_MACH_IPI_H */
    --- linux-2.6.28.orig/include/asm-x86/es7000/apic.h
    +++ linux-2.6.28/include/asm-x86/es7000/apic.h
    @@ -9,12 +9,12 @@ static inline int apic_id_registered(voi
    return (1);
    }

    -static inline cpumask_t target_cpus(void)
    +static inline const cpumask_t *target_cpus(void)
    {
    #if defined CONFIG_ES7000_CLUSTERED_APIC
    - return CPU_MASK_ALL;
    + return &CPU_MASK_ALL;
    #else
    - return cpumask_of_cpu(smp_processor_id());
    + return &cpumask_of_cpu(smp_processor_id());
    #endif
    }

    @@ -98,7 +98,7 @@ static inline int cpu_present_to_apicid(
    {
    if (!mps_cpu)
    return boot_cpu_physical_apicid;
    - else if (mps_cpu < NR_CPUS)
    + else if (mps_cpu < nr_cpu_ids)
    return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
    else
    return BAD_APICID;
    @@ -118,9 +118,9 @@ extern u8 cpu_2_logical_apicid[];
    static inline int cpu_to_logical_apicid(int cpu)
    {
    #ifdef CONFIG_SMP
    - if (cpu >= NR_CPUS)
    - return BAD_APICID;
    - return (int)cpu_2_logical_apicid[cpu];
    + if (cpu >= nr_cpu_ids)
    + return BAD_APICID;
    + return (int)cpu_2_logical_apicid[cpu];
    #else
    return logical_smp_processor_id();
    #endif
    @@ -144,14 +144,14 @@ static inline int check_phys_apicid_pres
    return (1);
    }

    -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
    +static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int num_bits_set;
    int cpus_found = 0;
    int cpu;
    int apicid;

    - num_bits_set = cpus_weight(cpumask);
    + num_bits_set = cpus_weight(*cpumask);
    /* Return id to all */
    if (num_bits_set == NR_CPUS)
    #if defined CONFIG_ES7000_CLUSTERED_APIC
    @@ -163,10 +163,10 @@ static inline unsigned int cpu_mask_to_a
    * The cpus in the mask must all be on the apic cluster. If are not
    * on the same apicid cluster return default value of TARGET_CPUS.
    */
    - cpu = first_cpu(cpumask);
    + cpu = first_cpu(*cpumask);
    apicid = cpu_to_logical_apicid(cpu);
    while (cpus_found < num_bits_set) {
    - if (cpu_isset(cpu, cpumask)) {
    + if (cpu_isset(cpu, *cpumask)) {
    int new_apicid = cpu_to_logical_apicid(cpu);
    if (apicid_cluster(apicid) !=
    apicid_cluster(new_apicid)){
    --- linux-2.6.28.orig/include/asm-x86/es7000/ipi.h
    +++ linux-2.6.28/include/asm-x86/es7000/ipi.h
    @@ -1,9 +1,10 @@
    #ifndef __ASM_ES7000_IPI_H
    #define __ASM_ES7000_IPI_H

    -void send_IPI_mask_sequence(cpumask_t mask, int vector);
    +void send_IPI_mask_sequence(const cpumask_t *mask, int vector);
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);

    -static inline void send_IPI_mask(cpumask_t mask, int vector)
    +static inline void send_IPI_mask(const cpumask_t *mask, int vector)
    {
    send_IPI_mask_sequence(mask, vector);
    }
    @@ -13,12 +14,12 @@ static inline void send_IPI_allbutself(i
    cpumask_t mask = cpu_online_map;
    cpu_clear(smp_processor_id(), mask);
    if (!cpus_empty(mask))
    - send_IPI_mask(mask, vector);
    + send_IPI_mask(&mask, vector);
    }

    static inline void send_IPI_all(int vector)
    {
    - send_IPI_mask(cpu_online_map, vector);
    + send_IPI_mask(&cpu_online_map, vector);
    }

    #endif /* __ASM_ES7000_IPI_H */
    --- linux-2.6.28.orig/include/asm-x86/genapic_32.h
    +++ linux-2.6.28/include/asm-x86/genapic_32.h
    @@ -23,7 +23,7 @@ struct genapic {
    int (*probe)(void);

    int (*apic_id_registered)(void);
    - cpumask_t (*target_cpus)(void);
    + const cpumask_t *(*target_cpus)(void);
    int int_delivery_mode;
    int int_dest_mode;
    int ESR_DISABLE;
    @@ -56,12 +56,13 @@ struct genapic {

    unsigned (*get_apic_id)(unsigned long x);
    unsigned long apic_id_mask;
    - unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
    - cpumask_t (*vector_allocation_domain)(int cpu);
    + unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask);
    + void (*vector_allocation_domain)(int cpu, cpumask_t *retmask);

    #ifdef CONFIG_SMP
    /* ipi */
    - void (*send_IPI_mask)(cpumask_t mask, int vector);
    + void (*send_IPI_mask)(const cpumask_t *mask, int vector);
    + void (*send_IPI_mask_allbutself)(const cpumask_t *mask, int vector);
    void (*send_IPI_allbutself)(int vector);
    void (*send_IPI_all)(int vector);
    #endif
    @@ -105,7 +106,7 @@ struct genapic {
    APICFUNC(get_apic_id) \
    .apic_id_mask = APIC_ID_MASK, \
    APICFUNC(cpu_mask_to_apicid) \
    - APICFUNC(vector_allocation_domain) \
    + APICFUNC(vector_allocation_domain) \
    APICFUNC(acpi_madt_oem_check) \
    IPIFUNC(send_IPI_mask) \
    IPIFUNC(send_IPI_allbutself) \
    --- linux-2.6.28.orig/include/asm-x86/genapic_64.h
    +++ linux-2.6.28/include/asm-x86/genapic_64.h
    @@ -1,6 +1,8 @@
    #ifndef ASM_X86__GENAPIC_64_H
    #define ASM_X86__GENAPIC_64_H

    +#include
    +
    /*
    * Copyright 2004 James Cleverdon, IBM.
    * Subject to the GNU Public License, v.2
    @@ -18,16 +20,17 @@ struct genapic {
    u32 int_delivery_mode;
    u32 int_dest_mode;
    int (*apic_id_registered)(void);
    - cpumask_t (*target_cpus)(void);
    - cpumask_t (*vector_allocation_domain)(int cpu);
    + const cpumask_t *(*target_cpus)(void);
    + void (*vector_allocation_domain)(int cpu, cpumask_t *retmask);
    void (*init_apic_ldr)(void);
    /* ipi */
    - void (*send_IPI_mask)(cpumask_t mask, int vector);
    + void (*send_IPI_mask)(const cpumask_t *mask, int vector);
    + void (*send_IPI_mask_allbutself)(const cpumask_t *mask, int vector);
    void (*send_IPI_allbutself)(int vector);
    void (*send_IPI_all)(int vector);
    void (*send_IPI_self)(int vector);
    /* */
    - unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
    + unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask);
    unsigned int (*phys_pkg_id)(int index_msb);
    unsigned int (*get_apic_id)(unsigned long x);
    unsigned long (*set_apic_id)(unsigned int id);
    --- linux-2.6.28.orig/include/asm-x86/ipi.h
    +++ linux-2.6.28/include/asm-x86/ipi.h
    @@ -117,7 +117,7 @@ static inline void __send_IPI_dest_field
    native_apic_mem_write(APIC_ICR, cfg);
    }

    -static inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
    +static inline void send_IPI_mask_sequence(const cpumask_t *mask, int vector)
    {
    unsigned long flags;
    unsigned long query_cpu;
    @@ -128,11 +128,28 @@ static inline void send_IPI_mask_sequenc
    * - mbligh
    */
    local_irq_save(flags);
    - for_each_cpu_mask_nr(query_cpu, mask) {
    + for_each_cpu_mask_nr(query_cpu, *mask) {
    __send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, query_cpu),
    vector, APIC_DEST_PHYSICAL);
    }
    local_irq_restore(flags);
    }

    +static inline void send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
    +{
    + unsigned long flags;
    + unsigned int query_cpu;
    + unsigned int this_cpu = smp_processor_id();
    +
    + /* See Hack comment above */
    +
    + local_irq_save(flags);
    + for_each_cpu_mask_nr(query_cpu, *mask)
    + if (query_cpu != this_cpu)
    + __send_IPI_dest_field(
    + per_cpu(x86_cpu_to_apicid, query_cpu),
    + vector, APIC_DEST_PHYSICAL);
    + local_irq_restore(flags);
    +}
    +
    #endif /* ASM_X86__IPI_H */
    --- linux-2.6.28.orig/include/asm-x86/mach-default/mach_apic.h
    +++ linux-2.6.28/include/asm-x86/mach-default/mach_apic.h
    @@ -8,12 +8,12 @@

    #define APIC_DFR_VALUE (APIC_DFR_FLAT)

    -static inline cpumask_t target_cpus(void)
    +static inline const cpumask_t *target_cpus(void)
    {
    #ifdef CONFIG_SMP
    - return cpu_online_map;
    + return &cpu_online_map;
    #else
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    #endif
    }

    @@ -59,9 +59,9 @@ static inline int apic_id_registered(voi
    return physid_isset(read_apic_id(), phys_cpu_present_map);
    }

    -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
    +static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    - return cpus_addr(cpumask)[0];
    + return cpus_addr(*cpumask)[0];
    }

    static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
    @@ -86,7 +86,7 @@ static inline int apicid_to_node(int log
    #endif
    }

    -static inline cpumask_t vector_allocation_domain(int cpu)
    +static inline void vector_allocation_domain(int cpu, cpumask_t *retmask)
    {
    /* Careful. Some cpus do not strictly honor the set of cpus
    * specified in the interrupt destination when using lowest
    @@ -96,8 +96,7 @@ static inline cpumask_t vector_allocatio
    * deliver interrupts to the wrong hyperthread when only one
    * hyperthread was specified in the interrupt desitination.
    */
    - cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
    - return domain;
    + *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
    }
    #endif

    @@ -129,7 +128,7 @@ static inline int cpu_to_logical_apicid(

    static inline int cpu_present_to_apicid(int mps_cpu)
    {
    - if (mps_cpu < NR_CPUS && cpu_present(mps_cpu))
    + if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
    return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
    else
    return BAD_APICID;
    --- linux-2.6.28.orig/include/asm-x86/mach-default/mach_ipi.h
    +++ linux-2.6.28/include/asm-x86/mach-default/mach_ipi.h
    @@ -4,7 +4,8 @@
    /* Avoid include hell */
    #define NMI_VECTOR 0x02

    -void send_IPI_mask_bitmask(cpumask_t mask, int vector);
    +void send_IPI_mask_bitmask(const cpumask_t *mask, int vector);
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);
    void __send_IPI_shortcut(unsigned int shortcut, int vector);

    extern int no_broadcast;
    @@ -12,28 +13,27 @@ extern int no_broadcast;
    #ifdef CONFIG_X86_64
    #include
    #define send_IPI_mask (genapic->send_IPI_mask)
    +#define send_IPI_mask_allbutself (genapic->send_IPI_mask_allbutself)
    #else
    -static inline void send_IPI_mask(cpumask_t mask, int vector)
    +static inline void send_IPI_mask(const cpumask_t *mask, int vector)
    {
    send_IPI_mask_bitmask(mask, vector);
    }
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);
    #endif

    static inline void __local_send_IPI_allbutself(int vector)
    {
    - if (no_broadcast || vector == NMI_VECTOR) {
    - cpumask_t mask = cpu_online_map;
    -
    - cpu_clear(smp_processor_id(), mask);
    - send_IPI_mask(mask, vector);
    - } else
    + if (no_broadcast || vector == NMI_VECTOR)
    + send_IPI_mask_allbutself(&cpu_online_map, vector);
    + else
    __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
    }

    static inline void __local_send_IPI_all(int vector)
    {
    if (no_broadcast || vector == NMI_VECTOR)
    - send_IPI_mask(cpu_online_map, vector);
    + send_IPI_mask(&cpu_online_map, vector);
    else
    __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
    }
    --- linux-2.6.28.orig/include/asm-x86/numaq/apic.h
    +++ linux-2.6.28/include/asm-x86/numaq/apic.h
    @@ -7,7 +7,7 @@

    #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)

    -static inline cpumask_t target_cpus(void)
    +static inline const cpumask_t *target_cpus(void)
    {
    return CPU_MASK_ALL;
    }
    @@ -122,7 +122,7 @@ static inline void enable_apic_mode(void
    * We use physical apicids here, not logical, so just return the default
    * physical broadcast to stop people from breaking us
    */
    -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
    +static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    return (int) 0xF;
    }
    --- linux-2.6.28.orig/include/asm-x86/numaq/ipi.h
    +++ linux-2.6.28/include/asm-x86/numaq/ipi.h
    @@ -1,9 +1,10 @@
    #ifndef __ASM_NUMAQ_IPI_H
    #define __ASM_NUMAQ_IPI_H

    -void send_IPI_mask_sequence(cpumask_t, int vector);
    +void send_IPI_mask_sequence(const cpumask_t *mask, int vector);
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);

    -static inline void send_IPI_mask(cpumask_t mask, int vector)
    +static inline void send_IPI_mask(const cpumask_t *mask, int vector)
    {
    send_IPI_mask_sequence(mask, vector);
    }
    @@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(i
    cpu_clear(smp_processor_id(), mask);

    if (!cpus_empty(mask))
    - send_IPI_mask(mask, vector);
    + send_IPI_mask(&mask, vector);
    }

    static inline void send_IPI_all(int vector)
    {
    - send_IPI_mask(cpu_online_map, vector);
    + send_IPI_mask(&cpu_online_map, vector);
    }

    #endif /* __ASM_NUMAQ_IPI_H */
    --- linux-2.6.28.orig/include/asm-x86/summit/apic.h
    +++ linux-2.6.28/include/asm-x86/summit/apic.h
    @@ -14,13 +14,13 @@

    #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)

    -static inline cpumask_t target_cpus(void)
    +static inline const cpumask_t *target_cpus(void)
    {
    /* CPU_MASK_ALL (0xff) has undefined behaviour with
    * dest_LowestPrio mode logical clustered apic interrupt routing
    * Just start on cpu 0. IRQ balancing will spread load
    */
    - return cpumask_of_cpu(0);
    + return &cpumask_of_cpu(0);
    }

    #define INT_DELIVERY_MODE (dest_LowestPrio)
    @@ -137,14 +137,14 @@ static inline void enable_apic_mode(void
    {
    }

    -static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
    +static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
    {
    int num_bits_set;
    int cpus_found = 0;
    int cpu;
    int apicid;

    - num_bits_set = cpus_weight(cpumask);
    + num_bits_set = cpus_weight(*cpumask);
    /* Return id to all */
    if (num_bits_set == NR_CPUS)
    return (int) 0xFF;
    @@ -152,10 +152,10 @@ static inline unsigned int cpu_mask_to_a
    * The cpus in the mask must all be on the apic cluster. If are not
    * on the same apicid cluster return default value of TARGET_CPUS.
    */
    - cpu = first_cpu(cpumask);
    + cpu = first_cpu(*cpumask);
    apicid = cpu_to_logical_apicid(cpu);
    while (cpus_found < num_bits_set) {
    - if (cpu_isset(cpu, cpumask)) {
    + if (cpu_isset(cpu, *cpumask)) {
    int new_apicid = cpu_to_logical_apicid(cpu);
    if (apicid_cluster(apicid) !=
    apicid_cluster(new_apicid)){
    --- linux-2.6.28.orig/include/asm-x86/summit/ipi.h
    +++ linux-2.6.28/include/asm-x86/summit/ipi.h
    @@ -1,9 +1,10 @@
    #ifndef __ASM_SUMMIT_IPI_H
    #define __ASM_SUMMIT_IPI_H

    -void send_IPI_mask_sequence(cpumask_t mask, int vector);
    +void send_IPI_mask_sequence(const cpumask_t *mask, int vector);
    +void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);

    -static inline void send_IPI_mask(cpumask_t mask, int vector)
    +static inline void send_IPI_mask(const cpumask_t *mask, int vector)
    {
    send_IPI_mask_sequence(mask, vector);
    }
    @@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(i
    cpu_clear(smp_processor_id(), mask);

    if (!cpus_empty(mask))
    - send_IPI_mask(mask, vector);
    + send_IPI_mask(&mask, vector);
    }

    static inline void send_IPI_all(int vector)
    {
    - send_IPI_mask(cpu_online_map, vector);
    + send_IPI_mask(&cpu_online_map, vector);
    }

    #endif /* __ASM_SUMMIT_IPI_H */

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. [PATCH 26/35] cpumask: to_cpumask() From: Rusty Russell <rusty@rustcorp.com.au>

    There are times when we really want a static cpumask. Yet we don't
    want to expose the struct cpumask definition, to avoid casual on-stack
    usage and assignment.

    So this macro allows you to do DECLARE_BITMAP(map, CONFIG_NR_CPUS); then use
    to_cpumask() to turn it into a cpumask as needed.

    Ugly? Yes, but as we move to fewer static cpumasks these calls vanish.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 14 ++++++++++++++
    1 file changed, 14 insertions(+)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -57,6 +57,9 @@
    * CPU_MASK_NONE Initializer - no bits set
    * unsigned long *cpumask_bits(mask) Array of unsigned long's in mask
    *
    + * struct cpumask *to_cpumask(const unsigned long[])
    + * Convert a bitmap to a cpumask.
    + *
    * ------------------------------------------------------------------------
    *
    * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
    @@ -365,6 +368,17 @@ static inline void cpumask_copy(struct c
    #define cpumask_any(srcp) cpumask_first(srcp)
    #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))

    +/* Used for static bitmaps of CONFIG_NR_CPUS bits. Must be a constant to use
    + * as an initializer. */
    +#define to_cpumask(bitmap) \
    + ((struct cpumask *)(1 ? (bitmap) \
    + : (void *)sizeof(__check_is_bitmap(bitmap))))
    +
    +static inline int __check_is_bitmap(const unsigned long *bitmap)
    +{
    + return 1;
    +}
    +
    /*
    * Special-case data structure for "single bit set only" constant CPU masks.
    *

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. [PATCH 27/35] cpumask: accessors to manipulate possible/present/online/active maps From: Rusty Russell <rusty@rustcorp.com.au>

    Since we are moving to const cpumask pointers for the maps, we need a
    way to legitimately access them. Simple accessors work well.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 9 +++++++++
    kernel/cpu.c | 41 +++++++++++++++++++++++++++++++++++++++++
    2 files changed, 50 insertions(+)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -586,6 +586,15 @@ extern cpumask_t cpu_active_map;
    #define cpu_active(cpu) ((cpu) == 0)
    #endif

    +/* Wrappers to manipulate otherwise-constant masks. */
    +void set_cpu_possible(unsigned int cpu, bool possible);
    +void set_cpu_present(unsigned int cpu, bool present);
    +void set_cpu_online(unsigned int cpu, bool online);
    +void set_cpu_active(unsigned int cpu, bool active);
    +void init_cpu_present(const struct cpumask *src);
    +void init_cpu_possible(const struct cpumask *src);
    +void init_cpu_online(const struct cpumask *src);
    +
    #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))

    #define for_each_possible_cpu(cpu) for_each_cpu((cpu), &cpu_possible_map)
    --- linux-2.6.28.orig/kernel/cpu.c
    +++ linux-2.6.28/kernel/cpu.c
    @@ -500,3 +500,44 @@ const unsigned long cpu_bit_bitmap[BITS_
    #endif
    };
    EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
    +
    +void set_cpu_possible(unsigned int cpu, bool possible)
    +{
    + if (possible)
    + cpumask_set_cpu(cpu, &cpu_possible_map);
    + else
    + cpumask_clear_cpu(cpu, &cpu_possible_map);
    +}
    +void set_cpu_present(unsigned int cpu, bool present)
    +{
    + if (present)
    + cpumask_set_cpu(cpu, &cpu_present_map);
    + else
    + cpumask_clear_cpu(cpu, &cpu_present_map);
    +}
    +void set_cpu_online(unsigned int cpu, bool online)
    +{
    + if (online)
    + cpumask_set_cpu(cpu, &cpu_online_map);
    + else
    + cpumask_clear_cpu(cpu, &cpu_online_map);
    +}
    +void set_cpu_active(unsigned int cpu, bool active)
    +{
    + if (active)
    + cpumask_set_cpu(cpu, &cpu_active_map);
    + else
    + cpumask_clear_cpu(cpu, &cpu_active_map);
    +}
    +void init_cpu_present(const struct cpumask *src)
    +{
    + cpumask_copy(&cpu_present_map, src);
    +}
    +void init_cpu_possible(const struct cpumask *src)
    +{
    + cpumask_copy(&cpu_possible_map, src);
    +}
    +void init_cpu_online(const struct cpumask *src)
    +{
    + cpumask_copy(&cpu_online_map, src);
    +}

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. [PATCH 19/35] cpumask: cpumask_of(): cpumask_of_cpu() which returns a pointer. From: Rusty Russell <rusty@rustcorp.com.au>

    This deprecates cpumask_of_cpu(), which returns a cpumask_t
    (cpumask_of() returns a const pointer, instead).

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 16 ++++------------
    1 file changed, 4 insertions(+), 12 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -52,8 +52,7 @@
    * void cpumask_copy(dmask, smask) dmask = smask
    *
    * size_t cpumask_size() Length of cpumask in bytes.
    - * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
    - * (can be used as an lvalue)
    + * const struct cpumask *cpumask_of(cpu) Return cpumask with bit 'cpu' set
    * CPU_MASK_ALL Initializer - all bits set
    * CPU_MASK_NONE Initializer - no bits set
    * unsigned long *cpumask_bits(mask) Array of unsigned long's in mask
    @@ -175,6 +174,7 @@ extern cpumask_t _unused_cpumask_arg_;
    #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)
    +#define cpumask_of_cpu(cpu) (*cpumask_of(cpu))
    /* End deprecated region. */

    #if NR_CPUS > 1
    @@ -385,21 +385,13 @@ static inline void cpumask_copy(struct c
    extern const unsigned long
    cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];

    -static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
    +static inline const struct cpumask *cpumask_of(unsigned int cpu)
    {
    const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
    p -= cpu / BITS_PER_LONG;
    - return (const cpumask_t *)p;
    + return (const struct cpumask *)p;
    }

    -/*
    - * In cases where we take the address of the cpumask immediately,
    - * gcc optimizes it out (it's a constant) and there's no huge stack
    - * variable created:
    - */
    -#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
    -
    -
    #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)

    #if NR_CPUS <= BITS_PER_LONG

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. [PATCH 07/35] cpumask: change cpumask/list_scnprintf, cpumask/list_parse to take pointers. From: Rusty Russell <rusty@rustcorp.com.au>

    We want to move cpumasks off the stack: no local decls, no passing by
    copy.

    Most cpumask functions started with cpus_: these have been replaced by
    cpumask_ ones which take struct cpumask pointers as expected, and macro
    stubs used for the transition.

    These four functions don't have good replacement names; fortunately
    they're rarely used, so we just change them over.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    arch/ia64/kernel/topology.c | 2 +-
    arch/mips/kernel/smp-cmp.c | 4 ++--
    arch/powerpc/platforms/pseries/xics.c | 2 +-
    arch/x86/kernel/cpu/intel_cacheinfo.c | 4 ++--
    arch/x86/kernel/setup_percpu.c | 2 +-
    drivers/base/cpu.c | 2 +-
    drivers/base/node.c | 4 ++--
    drivers/base/topology.c | 4 ++--
    drivers/pci/pci-sysfs.c | 4 ++--
    drivers/pci/probe.c | 4 ++--
    include/linux/cpumask.h | 21 +++++++--------------
    kernel/cpuset.c | 4 ++--
    kernel/irq/proc.c | 4 ++--
    kernel/profile.c | 4 ++--
    kernel/sched.c | 4 ++--
    kernel/sched_stats.h | 2 +-
    kernel/taskstats.c | 2 +-
    kernel/trace/trace.c | 4 ++--
    mm/slub.c | 2 +-
    19 files changed, 36 insertions(+), 43 deletions(-)

    --- linux-2.6.28.orig/arch/ia64/kernel/topology.c
    +++ linux-2.6.28/arch/ia64/kernel/topology.c
    @@ -217,7 +217,7 @@ static ssize_t show_shared_cpu_map(struc
    cpumask_t shared_cpu_map;

    cpus_and(shared_cpu_map, this_leaf->shared_cpu_map, cpu_online_map);
    - len = cpumask_scnprintf(buf, NR_CPUS+1, shared_cpu_map);
    + len = cpumask_scnprintf(buf, NR_CPUS+1, &shared_cpu_map);
    len += sprintf(buf+len, "\n");
    return len;
    }
    --- linux-2.6.28.orig/arch/mips/kernel/smp-cmp.c
    +++ linux-2.6.28/arch/mips/kernel/smp-cmp.c
    @@ -51,10 +51,10 @@ static int __init allowcpus(char *str)
    int len;

    cpus_clear(cpu_allow_map);
    - if (cpulist_parse(str, cpu_allow_map) == 0) {
    + if (cpulist_parse(str, &cpu_allow_map) == 0) {
    cpu_set(0, cpu_allow_map);
    cpus_and(cpu_possible_map, cpu_possible_map, cpu_allow_map);
    - len = cpulist_scnprintf(buf, sizeof(buf)-1, cpu_possible_map);
    + len = cpulist_scnprintf(buf, sizeof(buf)-1, &cpu_possible_map);
    buf[len] = '\0';
    pr_debug("Allowable CPUs: %s\n", buf);
    return 1;
    --- linux-2.6.28.orig/arch/powerpc/platforms/pseries/xics.c
    +++ linux-2.6.28/arch/powerpc/platforms/pseries/xics.c
    @@ -358,7 +358,7 @@ static void xics_set_affinity(unsigned i
    irq_server = get_irq_server(virq, 1);
    if (irq_server == -1) {
    char cpulist[128];
    - cpumask_scnprintf(cpulist, sizeof(cpulist), cpumask);
    + cpumask_scnprintf(cpulist, sizeof(cpulist), &cpumask);
    printk(KERN_WARNING
    "%s: No online cpus in the mask %s for irq %d\n",
    __func__, cpulist, virq);
    --- linux-2.6.28.orig/arch/x86/kernel/cpu/intel_cacheinfo.c
    +++ linux-2.6.28/arch/x86/kernel/cpu/intel_cacheinfo.c
    @@ -626,8 +626,8 @@ static ssize_t show_shared_cpu_map_func(
    cpumask_t *mask = &this_leaf->shared_cpu_map;

    n = type?
    - cpulist_scnprintf(buf, len-2, *mask):
    - cpumask_scnprintf(buf, len-2, *mask);
    + cpulist_scnprintf(buf, len-2, mask) :
    + cpumask_scnprintf(buf, len-2, mask);
    buf[n++] = '\n';
    buf[n] = '\0';
    }
    --- linux-2.6.28.orig/arch/x86/kernel/setup_percpu.c
    +++ linux-2.6.28/arch/x86/kernel/setup_percpu.c
    @@ -282,7 +282,7 @@ static void __cpuinit numa_set_cpumask(i
    else
    cpu_clear(cpu, *mask);

    - cpulist_scnprintf(buf, sizeof(buf), *mask);
    + cpulist_scnprintf(buf, sizeof(buf), mask);
    printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",
    enable? "numa_add_cpu":"numa_remove_cpu", cpu, node, buf);
    }
    --- linux-2.6.28.orig/drivers/base/cpu.c
    +++ linux-2.6.28/drivers/base/cpu.c
    @@ -109,7 +109,7 @@ static SYSDEV_ATTR(crash_notes, 0400, sh
    */
    static ssize_t print_cpus_map(char *buf, cpumask_t *map)
    {
    - int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
    + int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map);

    buf[n++] = '\n';
    buf[n] = '\0';
    --- linux-2.6.28.orig/drivers/base/node.c
    +++ linux-2.6.28/drivers/base/node.c
    @@ -30,8 +30,8 @@ static ssize_t node_read_cpumap(struct s
    BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));

    len = type?
    - cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
    - cpumask_scnprintf(buf, PAGE_SIZE-2, *mask);
    + cpulist_scnprintf(buf, PAGE_SIZE-2, mask) :
    + cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
    buf[len++] = '\n';
    buf[len] = '\0';
    return len;
    --- linux-2.6.28.orig/drivers/base/topology.c
    +++ linux-2.6.28/drivers/base/topology.c
    @@ -49,8 +49,8 @@ static ssize_t show_cpumap(int type, cpu

    if (len > 1) {
    n = type?
    - cpulist_scnprintf(buf, len-2, *mask):
    - cpumask_scnprintf(buf, len-2, *mask);
    + cpulist_scnprintf(buf, len-2, mask) :
    + cpumask_scnprintf(buf, len-2, mask);
    buf[n++] = '\n';
    buf[n] = '\0';
    }
    --- linux-2.6.28.orig/drivers/pci/pci-sysfs.c
    +++ linux-2.6.28/drivers/pci/pci-sysfs.c
    @@ -74,7 +74,7 @@ static ssize_t local_cpus_show(struct de
    int len;

    mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
    - len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
    + len = cpumask_scnprintf(buf, PAGE_SIZE-2, &mask);
    buf[len++] = '\n';
    buf[len] = '\0';
    return len;
    @@ -88,7 +88,7 @@ static ssize_t local_cpulist_show(struct
    int len;

    mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
    - len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
    + len = cpulist_scnprintf(buf, PAGE_SIZE-2, &mask);
    buf[len++] = '\n';
    buf[len] = '\0';
    return len;
    --- linux-2.6.28.orig/drivers/pci/probe.c
    +++ linux-2.6.28/drivers/pci/probe.c
    @@ -55,8 +55,8 @@ static ssize_t pci_bus_show_cpuaffinity(

    cpumask = pcibus_to_cpumask(to_pci_bus(dev));
    ret = type?
    - cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask):
    - cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
    + cpulist_scnprintf(buf, PAGE_SIZE-2, &cpumask) :
    + cpumask_scnprintf(buf, PAGE_SIZE-2, &cpumask);
    buf[ret++] = '\n';
    buf[ret] = '\0';
    return ret;
    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -174,13 +174,6 @@ extern cpumask_t _unused_cpumask_arg_;
    cpumask_shift_right(&(dst), &(src), (n))
    #define cpus_shift_left(dst, src, n) \
    cpumask_shift_left(&(dst), &(src), (n))
    -#define cpumask_scnprintf(buf, len, src) \
    - __cpumask_scnprintf((buf), (len), &(src))
    -#define cpumask_parse_user(ubuf, ulen, dst) \
    - __cpumask_parse_user((ubuf), (ulen), &(dst))
    -#define cpulist_scnprintf(buf, len, src) \
    - __cpulist_scnprintf((buf), (len), &(src))
    -#define cpulist_parse(buf, dst) __cpulist_parse((buf), &(dst))
    #define cpu_remap(oldbit, old, new) \
    cpumask_cpuremap((oldbit), &(old), &(new))
    #define cpus_remap(dst, src, old, new) \
    @@ -303,25 +296,25 @@ static inline void cpumask_shift_left(st
    bitmap_shift_left(dstp->bits, srcp->bits, n, NR_CPUS);
    }

    -static inline int __cpumask_scnprintf(char *buf, int len,
    - const struct cpumask *srcp)
    +static inline int cpumask_scnprintf(char *buf, int len,
    + const struct cpumask *srcp)
    {
    return bitmap_scnprintf(buf, len, srcp->bits, NR_CPUS);
    }

    -static inline int __cpumask_parse_user(const char __user *buf, int len,
    - struct cpumask *dstp)
    +static inline int cpumask_parse_user(const char __user *buf, int len,
    + struct cpumask *dstp)
    {
    return bitmap_parse_user(buf, len, dstp->bits, NR_CPUS);
    }

    -static inline int __cpulist_scnprintf(char *buf, int len,
    - const struct cpumask *srcp)
    +static inline int cpulist_scnprintf(char *buf, int len,
    + const struct cpumask *srcp)
    {
    return bitmap_scnlistprintf(buf, len, srcp->bits, NR_CPUS);
    }

    -static inline int __cpulist_parse(const char *buf, struct cpumask *dstp)
    +static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
    {
    return bitmap_parselist(buf, dstp->bits, NR_CPUS);
    }
    --- linux-2.6.28.orig/kernel/cpuset.c
    +++ linux-2.6.28/kernel/cpuset.c
    @@ -891,7 +891,7 @@ static int update_cpumask(struct cpuset
    if (!*buf) {
    cpus_clear(trialcs.cpus_allowed);
    } else {
    - retval = cpulist_parse(buf, trialcs.cpus_allowed);
    + retval = cpulist_parse(buf, &trialcs.cpus_allowed);
    if (retval < 0)
    return retval;

    @@ -1477,7 +1477,7 @@ static int cpuset_sprintf_cpulist(char *
    mask = cs->cpus_allowed;
    mutex_unlock(&callback_mutex);

    - return cpulist_scnprintf(page, PAGE_SIZE, mask);
    + return cpulist_scnprintf(page, PAGE_SIZE, &mask);
    }

    static int cpuset_sprintf_memlist(char *page, struct cpuset *cs)
    --- linux-2.6.28.orig/kernel/irq/proc.c
    +++ linux-2.6.28/kernel/irq/proc.c
    @@ -47,7 +47,7 @@ static ssize_t irq_affinity_proc_write(s
    irq_balancing_disabled(irq))
    return -EIO;

    - err = cpumask_parse_user(buffer, count, new_value);
    + err = cpumask_parse_user(buffer, count, &new_value);
    if (err)
    return err;

    @@ -95,7 +95,7 @@ static ssize_t default_affinity_write(st
    cpumask_t new_value;
    int err;

    - err = cpumask_parse_user(buffer, count, new_value);
    + err = cpumask_parse_user(buffer, count, &new_value);
    if (err)
    return err;

    --- linux-2.6.28.orig/kernel/profile.c
    +++ linux-2.6.28/kernel/profile.c
    @@ -446,7 +446,7 @@ void profile_tick(int type)
    static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
    int count, int *eof, void *data)
    {
    - int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
    + int len = cpumask_scnprintf(page, count, (cpumask_t *)data);
    if (count - len < 2)
    return -EINVAL;
    len += sprintf(page + len, "\n");
    @@ -460,7 +460,7 @@ static int prof_cpu_mask_write_proc(stru
    unsigned long full_count = count, err;
    cpumask_t new_value;

    - err = cpumask_parse_user(buffer, count, new_value);
    + err = cpumask_parse_user(buffer, count, &new_value);
    if (err)
    return err;

    --- linux-2.6.28.orig/kernel/sched.c
    +++ linux-2.6.28/kernel/sched.c
    @@ -6646,7 +6646,7 @@ static int sched_domain_debug_one(struct
    struct sched_group *group = sd->groups;
    char str[256];

    - cpulist_scnprintf(str, sizeof(str), sd->span);
    + cpulist_scnprintf(str, sizeof(str), &sd->span);
    cpus_clear(*groupmask);

    printk(KERN_DEBUG "%*s domain %d: ", level, "", level);
    @@ -6700,7 +6700,7 @@ static int sched_domain_debug_one(struct

    cpus_or(*groupmask, *groupmask, group->cpumask);

    - cpulist_scnprintf(str, sizeof(str), group->cpumask);
    + cpulist_scnprintf(str, sizeof(str), &group->cpumask);
    printk(KERN_CONT " %s", str);

    group = group->next;
    --- linux-2.6.28.orig/kernel/sched_stats.h
    +++ linux-2.6.28/kernel/sched_stats.h
    @@ -42,7 +42,7 @@ static int show_schedstat(struct seq_fil
    for_each_domain(cpu, sd) {
    enum cpu_idle_type itype;

    - cpumask_scnprintf(mask_str, mask_len, sd->span);
    + cpumask_scnprintf(mask_str, mask_len, &sd->span);
    seq_printf(seq, "domain%d %s", dcount++, mask_str);
    for (itype = CPU_IDLE; itype < CPU_MAX_IDLE_TYPES;
    itype++) {
    --- linux-2.6.28.orig/kernel/taskstats.c
    +++ linux-2.6.28/kernel/taskstats.c
    @@ -352,7 +352,7 @@ static int parse(struct nlattr *na, cpum
    if (!data)
    return -ENOMEM;
    nla_strlcpy(data, na, len);
    - ret = cpulist_parse(data, *mask);
    + ret = cpulist_parse(data, mask);
    kfree(data);
    return ret;
    }
    --- linux-2.6.28.orig/kernel/trace/trace.c
    +++ linux-2.6.28/kernel/trace/trace.c
    @@ -2117,7 +2117,7 @@ tracing_cpumask_read(struct file *filp,

    mutex_lock(&tracing_cpumask_update_lock);

    - len = cpumask_scnprintf(mask_str, count, tracing_cpumask);
    + len = cpumask_scnprintf(mask_str, count, &tracing_cpumask);
    if (count - len < 2) {
    count = -EINVAL;
    goto out_err;
    @@ -2138,7 +2138,7 @@ tracing_cpumask_write(struct file *filp,
    int err, cpu;

    mutex_lock(&tracing_cpumask_update_lock);
    - err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
    + err = cpumask_parse_user(ubuf, count, &tracing_cpumask_new);
    if (err)
    goto err_unlock;

    --- linux-2.6.28.orig/mm/slub.c
    +++ linux-2.6.28/mm/slub.c
    @@ -3637,7 +3637,7 @@ static int list_locations(struct kmem_ca
    len < PAGE_SIZE - 60) {
    len += sprintf(buf + len, " cpus=");
    len += cpulist_scnprintf(buf + len, PAGE_SIZE - len - 50,
    - l->cpus);
    + &l->cpus);
    }

    if (num_online_nodes() > 1 && !nodes_empty(l->nodes) &&

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. [PATCH 15/35] cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits. From: Rusty Russell <rusty@rustcorp.com.au>

    In fact, all cpumask ops will only be valid (in general) for bit
    numbers < nr_cpu_ids. So use that instead of NR_CPUS in various
    places.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    arch/alpha/kernel/irq.c | 3 ++-
    arch/alpha/kernel/smp.c | 8 ++++----
    arch/arm/kernel/irq.c | 2 +-
    arch/cris/kernel/setup.c | 2 +-
    arch/frv/kernel/setup.c | 2 +-
    arch/h8300/kernel/setup.c | 2 +-
    arch/ia64/kernel/acpi.c | 2 +-
    arch/ia64/kernel/iosapic.c | 4 ++--
    arch/ia64/kernel/irq.c | 2 +-
    arch/ia64/kernel/mca.c | 6 +++---
    arch/ia64/kernel/perfmon.c | 4 ++--
    arch/ia64/kernel/salinfo.c | 6 +++---
    arch/ia64/kernel/setup.c | 4 ++--
    arch/ia64/sn/kernel/setup.c | 2 +-
    arch/ia64/sn/kernel/sn2/sn2_smp.c | 6 +++---
    arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +-
    arch/m32r/kernel/setup.c | 2 +-
    arch/m68knommu/kernel/setup.c | 2 +-
    arch/mips/kernel/irq-gic.c | 2 +-
    arch/mips/kernel/proc.c | 2 +-
    arch/mips/kernel/smp-cmp.c | 2 +-
    arch/mips/kernel/smtc.c | 6 +++---
    arch/mips/sibyte/bcm1480/irq.c | 2 +-
    arch/mips/sibyte/bcm1480/smp.c | 2 +-
    arch/mips/sibyte/sb1250/smp.c | 2 +-
    arch/mn10300/kernel/irq.c | 4 ++--
    arch/mn10300/kernel/setup.c | 2 +-
    arch/parisc/kernel/irq.c | 4 ++--
    arch/parisc/kernel/processor.c | 4 ++--
    arch/powerpc/include/asm/cputhreads.h | 2 +-
    arch/powerpc/kernel/irq.c | 2 +-
    arch/powerpc/kernel/machine_kexec_64.c | 2 +-
    arch/powerpc/kernel/process.c | 2 +-
    arch/powerpc/kernel/setup-common.c | 10 +++++-----
    arch/powerpc/mm/numa.c | 4 ++--
    arch/powerpc/platforms/powermac/setup.c | 2 +-
    arch/powerpc/platforms/powermac/smp.c | 4 ++--
    arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +-
    arch/powerpc/platforms/pseries/rtasd.c | 2 +-
    arch/powerpc/platforms/pseries/xics.c | 2 +-
    arch/powerpc/xmon/xmon.c | 4 ++--
    arch/s390/kernel/smp.c | 10 +++++-----
    arch/sh/kernel/setup.c | 2 +-
    arch/sparc/kernel/smp.c | 11 +++++------
    arch/sparc/kernel/sun4d_smp.c | 9 ++++-----
    arch/sparc/kernel/sun4m_smp.c | 8 +++-----
    arch/sparc/mm/srmmu.c | 2 +-
    arch/sparc64/kernel/ds.c | 2 +-
    arch/sparc64/kernel/irq.c | 4 ++--
    arch/sparc64/mm/init.c | 2 +-
    arch/um/kernel/um_arch.c | 2 +-
    arch/x86/kernel/apic.c | 2 +-
    arch/x86/kernel/irq_32.c | 2 +-
    arch/x86/mach-voyager/voyager_smp.c | 2 +-
    arch/x86/mm/numa_64.c | 4 ++--
    arch/x86/mm/srat_64.c | 2 +-
    drivers/infiniband/hw/ehca/ehca_irq.c | 2 +-
    kernel/kexec.c | 2 +-
    kernel/smp.c | 2 +-
    net/core/neighbour.c | 4 ++--
    net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 4 ++--
    net/ipv4/route.c | 4 ++--
    net/netfilter/nf_conntrack_standalone.c | 4 ++--
    security/selinux/selinuxfs.c | 2 +-
    64 files changed, 108 insertions(+), 111 deletions(-)

    --- linux-2.6.28.orig/arch/alpha/kernel/irq.c
    +++ linux-2.6.28/arch/alpha/kernel/irq.c
    @@ -50,8 +50,9 @@ int irq_select_affinity(unsigned int irq
    if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
    return 1;

    + /* FIXME: This has an out-by-one error: inc then test! */
    while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity))
    - cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
    + cpu = (cpu < (nr_cpu_ids-1) ? cpu + 1 : 0);
    last_cpu = cpu;

    irq_desc[irq].affinity = cpumask_of_cpu(cpu);
    --- linux-2.6.28.orig/arch/alpha/kernel/smp.c
    +++ linux-2.6.28/arch/alpha/kernel/smp.c
    @@ -497,7 +497,7 @@ smp_cpus_done(unsigned int max_cpus)
    int cpu;
    unsigned long bogosum = 0;

    - for(cpu = 0; cpu < NR_CPUS; cpu++)
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++)
    if (cpu_online(cpu))
    bogosum += cpu_data[cpu].loops_per_jiffy;

    @@ -698,7 +698,7 @@ flush_tlb_mm(struct mm_struct *mm)
    flush_tlb_current(mm);
    if (atomic_read(&mm->mm_users) <= 1) {
    int cpu, this_cpu = smp_processor_id();
    - for (cpu = 0; cpu < NR_CPUS; cpu++) {
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
    if (!cpu_online(cpu) || cpu == this_cpu)
    continue;
    if (mm->context[cpu])
    @@ -747,7 +747,7 @@ flush_tlb_page(struct vm_area_struct *vm
    flush_tlb_current_page(mm, vma, addr);
    if (atomic_read(&mm->mm_users) <= 1) {
    int cpu, this_cpu = smp_processor_id();
    - for (cpu = 0; cpu < NR_CPUS; cpu++) {
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
    if (!cpu_online(cpu) || cpu == this_cpu)
    continue;
    if (mm->context[cpu])
    @@ -803,7 +803,7 @@ flush_icache_user_range(struct vm_area_s
    __load_new_mm_context(mm);
    if (atomic_read(&mm->mm_users) <= 1) {
    int cpu, this_cpu = smp_processor_id();
    - for (cpu = 0; cpu < NR_CPUS; cpu++) {
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
    if (!cpu_online(cpu) || cpu == this_cpu)
    continue;
    if (mm->context[cpu])
    --- linux-2.6.28.orig/arch/arm/kernel/irq.c
    +++ linux-2.6.28/arch/arm/kernel/irq.c
    @@ -193,7 +193,7 @@ void migrate_irqs(void)
    if (desc->cpu == cpu) {
    unsigned int newcpu = any_online_cpu(desc->affinity);

    - if (newcpu == NR_CPUS) {
    + if (newcpu >= nr_cpu_ids) {
    if (printk_ratelimit())
    printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n",
    i, cpu);
    --- linux-2.6.28.orig/arch/cris/kernel/setup.c
    +++ linux-2.6.28/arch/cris/kernel/setup.c
    @@ -166,7 +166,7 @@ void __init setup_arch(char **cmdline_p)

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? (void *)(int)(*pos + 1): NULL;
    + return *pos < nr_cpu_ids ? (void *)(int)(*pos + 1) : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/frv/kernel/setup.c
    +++ linux-2.6.28/arch/frv/kernel/setup.c
    @@ -1100,7 +1100,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? (void *) 0x12345678 : NULL;
    + return *pos < nr_cpu_ids ? (void *) 0x12345678 : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/h8300/kernel/setup.c
    +++ linux-2.6.28/arch/h8300/kernel/setup.c
    @@ -224,7 +224,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
    + return *pos < nr_cpu_ids ? ((void *) 0x12345678) : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/ia64/kernel/acpi.c
    +++ linux-2.6.28/arch/ia64/kernel/acpi.c
    @@ -885,7 +885,7 @@ int acpi_map_lsapic(acpi_handle handle,

    cpus_complement(tmp_map, cpu_present_map);
    cpu = first_cpu(tmp_map);
    - if (cpu >= NR_CPUS)
    + if (cpu >= nr_cpu_ids)
    return -EINVAL;

    acpi_map_cpu2node(handle, cpu, physid);
    --- linux-2.6.28.orig/arch/ia64/kernel/iosapic.c
    +++ linux-2.6.28/arch/ia64/kernel/iosapic.c
    @@ -720,7 +720,7 @@ get_target_cpu (unsigned int gsi, int ir
    for (numa_cpu = first_cpu(cpu_mask) ; i < cpu_index ; i++)
    numa_cpu = next_cpu(numa_cpu, cpu_mask);

    - if (numa_cpu != NR_CPUS)
    + if (numa_cpu < nr_cpus_ids)
    return cpu_physical_id(numa_cpu);
    }
    skip_numa_setup:
    @@ -731,7 +731,7 @@ skip_numa_setup:
    * case of NUMA.)
    */
    do {
    - if (++cpu >= NR_CPUS)
    + if (++cpu >= nr_cpu_ids)
    cpu = 0;
    } while (!cpu_online(cpu) || !cpu_isset(cpu, domain));

    --- linux-2.6.28.orig/arch/ia64/kernel/irq.c
    +++ linux-2.6.28/arch/ia64/kernel/irq.c
    @@ -153,7 +153,7 @@ static void migrate_irqs(void)
    continue;

    cpus_and(mask, irq_desc[irq].affinity, cpu_online_map);
    - if (any_online_cpu(mask) == NR_CPUS) {
    + if (any_online_cpu(mask) >= nr_cpu_ids) {
    /*
    * Save it for phase 2 processing
    */
    --- linux-2.6.28.orig/arch/ia64/kernel/mca.c
    +++ linux-2.6.28/arch/ia64/kernel/mca.c
    @@ -1456,9 +1456,9 @@ ia64_mca_cmc_int_caller(int cmc_irq, voi

    ia64_mca_cmc_int_handler(cmc_irq, arg);

    - for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
    + cpuid = next_cpu(cpuid+1, cpu_online_map);

    - if (cpuid < NR_CPUS) {
    + if (cpuid < nr_cpu_ids) {
    platform_send_ipi(cpuid, IA64_CMCP_VECTOR, IA64_IPI_DM_INT, 0);
    } else {
    /* If no log record, switch out of polling mode */
    @@ -1525,7 +1525,7 @@ ia64_mca_cpe_int_caller(int cpe_irq, voi

    ia64_mca_cpe_int_handler(cpe_irq, arg);

    - for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
    + cpuid = next_cpu(cpuid+1, cpu_online_map);

    if (cpuid < NR_CPUS) {
    platform_send_ipi(cpuid, IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0);
    --- linux-2.6.28.orig/arch/ia64/kernel/perfmon.c
    +++ linux-2.6.28/arch/ia64/kernel/perfmon.c
    @@ -5598,7 +5598,7 @@ pfm_interrupt_handler(int irq, void *arg
    * /proc/perfmon interface, for debug only
    */

    -#define PFM_PROC_SHOW_HEADER ((void *)NR_CPUS+1)
    +#define PFM_PROC_SHOW_HEADER ((void *)nr_cpu_ids+1)

    static void *
    pfm_proc_start(struct seq_file *m, loff_t *pos)
    @@ -5607,7 +5607,7 @@ pfm_proc_start(struct seq_file *m, loff_
    return PFM_PROC_SHOW_HEADER;
    }

    - while (*pos <= NR_CPUS) {
    + while (*pos <= nr_cpu_ids) {
    if (cpu_online(*pos - 1)) {
    return (void *)*pos;
    }
    --- linux-2.6.28.orig/arch/ia64/kernel/salinfo.c
    +++ linux-2.6.28/arch/ia64/kernel/salinfo.c
    @@ -317,7 +317,7 @@ retry:
    }

    n = data->cpu_check;
    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    if (cpu_isset(n, data->cpu_event)) {
    if (!cpu_online(n)) {
    cpu_clear(n, data->cpu_event);
    @@ -326,7 +326,7 @@ retry:
    cpu = n;
    break;
    }
    - if (++n == NR_CPUS)
    + if (++n == nr_cpu_ids)
    n = 0;
    }

    @@ -337,7 +337,7 @@ retry:

    /* for next read, start checking at next CPU */
    data->cpu_check = cpu;
    - if (++data->cpu_check == NR_CPUS)
    + if (++data->cpu_check == nr_cpu_ids)
    data->cpu_check = 0;

    snprintf(cmd, sizeof(cmd), "read %d\n", cpu);
    --- linux-2.6.28.orig/arch/ia64/kernel/setup.c
    +++ linux-2.6.28/arch/ia64/kernel/setup.c
    @@ -719,10 +719,10 @@ static void *
    c_start (struct seq_file *m, loff_t *pos)
    {
    #ifdef CONFIG_SMP
    - while (*pos < NR_CPUS && !cpu_isset(*pos, cpu_online_map))
    + while (*pos < nr_cpu_ids && !cpu_online(*pos))
    ++*pos;
    #endif
    - return *pos < NR_CPUS ? cpu_data(*pos) : NULL;
    + return *pos < nr_cpu_ids ? cpu_data(*pos) : NULL;
    }

    static void *
    --- linux-2.6.28.orig/arch/ia64/sn/kernel/setup.c
    +++ linux-2.6.28/arch/ia64/sn/kernel/setup.c
    @@ -753,7 +753,7 @@ nasid_slice_to_cpuid(int nasid, int slic
    {
    long cpu;

    - for (cpu = 0; cpu < NR_CPUS; cpu++)
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++)
    if (cpuid_to_nasid(cpu) == nasid &&
    cpuid_to_slice(cpu) == slice)
    return cpu;
    --- linux-2.6.28.orig/arch/ia64/sn/kernel/sn2/sn2_smp.c
    +++ linux-2.6.28/arch/ia64/sn/kernel/sn2/sn2_smp.c
    @@ -461,7 +461,7 @@ bool sn_cpu_disable_allowed(int cpu)

    static void *sn2_ptc_seq_start(struct seq_file *file, loff_t * offset)
    {
    - if (*offset < NR_CPUS)
    + if (*offset < nr_cpu_ids)
    return offset;
    return NULL;
    }
    @@ -469,7 +469,7 @@ static void *sn2_ptc_seq_start(struct se
    static void *sn2_ptc_seq_next(struct seq_file *file, void *data, loff_t * offset)
    {
    (*offset)++;
    - if (*offset < NR_CPUS)
    + if (*offset < nr_cpu_ids)
    return offset;
    return NULL;
    }
    @@ -491,7 +491,7 @@ static int sn2_ptc_seq_show(struct seq_f
    seq_printf(file, "# ptctest %d, flushopt %d\n", sn2_ptctest, sn2_flush_opt);
    }

    - if (cpu < NR_CPUS && cpu_online(cpu)) {
    + if (cpu < nr_cpu_ids && cpu_online(cpu)) {
    stat = &per_cpu(ptcstats, cpu);
    seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l,
    stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed,
    --- linux-2.6.28.orig/arch/ia64/sn/kernel/sn2/sn_hwperf.c
    +++ linux-2.6.28/arch/ia64/sn/kernel/sn2/sn_hwperf.c
    @@ -615,7 +615,7 @@ static int sn_hwperf_op_cpu(struct sn_hw
    op_info->a->arg &= SN_HWPERF_ARG_OBJID_MASK;

    if (cpu != SN_HWPERF_ARG_ANY_CPU) {
    - if (cpu >= NR_CPUS || !cpu_online(cpu)) {
    + if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
    r = -EINVAL;
    goto out;
    }
    --- linux-2.6.28.orig/arch/m32r/kernel/setup.c
    +++ linux-2.6.28/arch/m32r/kernel/setup.c
    @@ -356,7 +356,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? cpu_data + *pos : NULL;
    + return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/m68knommu/kernel/setup.c
    +++ linux-2.6.28/arch/m68knommu/kernel/setup.c
    @@ -248,7 +248,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
    + return *pos < nr_cpu_ids ? ((void *) 0x12345678) : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/mips/kernel/irq-gic.c
    +++ linux-2.6.28/arch/mips/kernel/irq-gic.c
    @@ -182,7 +182,7 @@ static void gic_set_affinity(unsigned in
    _intrmap[irq].cpunum = first_cpu(tmp);

    /* Update the pcpu_masks */
    - for (i = 0; i < NR_CPUS; i++)
    + for (i = 0; i < nr_cpu_ids; i++)
    clear_bit(irq, pcpu_masks[i].pcpu_mask);
    set_bit(irq, pcpu_masks[first_cpu(tmp)].pcpu_mask);

    --- linux-2.6.28.orig/arch/mips/kernel/proc.c
    +++ linux-2.6.28/arch/mips/kernel/proc.c
    @@ -86,7 +86,7 @@ static void *c_start(struct seq_file *m,
    {
    unsigned long i = *pos;

    - return i < NR_CPUS ? (void *) (i + 1) : NULL;
    + return i < nr_cpu_ids ? (void *) (i + 1) : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/mips/kernel/smp-cmp.c
    +++ linux-2.6.28/arch/mips/kernel/smp-cmp.c
    @@ -224,7 +224,7 @@ void __init cmp_smp_setup(void)
    cpu_set(0, mt_fpu_cpumask);
    #endif /* CONFIG_MIPS_MT_FPAFF */

    - for (i = 1; i < NR_CPUS; i++) {
    + for (i = 1; i < nr_cpu_ids; i++) {
    if (amon_cpu_avail(i)) {
    cpu_set(i, cpu_possible_map);
    __cpu_number_map[i] = ++ncpu;
    --- linux-2.6.28.orig/arch/mips/kernel/smtc.c
    +++ linux-2.6.28/arch/mips/kernel/smtc.c
    @@ -303,7 +303,7 @@ int __init smtc_build_cpu_map(int start_
    * everything up so that "logical" = "physical".
    */
    ntcs = ((read_c0_mvpconf0() & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT) + 1;
    - for (i=start_cpu_slot; i + for (i = start_cpu_slot; i < nr_cpu_ids && i < ntcs; i++) {
    cpu_set(i, cpu_possible_map);
    __cpu_number_map[i] = i;
    __cpu_logical_map[i] = i;
    @@ -422,8 +422,8 @@ void smtc_prepare_cpus(int cpus)
    if (vpelimit > 0 && nvpe > vpelimit)
    nvpe = vpelimit;
    ntc = ((val & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT) + 1;
    - if (ntc > NR_CPUS)
    - ntc = NR_CPUS;
    + if (ntc > nr_cpu_ids)
    + ntc = nr_cpu_ids;
    if (tclimit > 0 && ntc > tclimit)
    ntc = tclimit;
    slop = ntc % nvpe;
    --- linux-2.6.28.orig/arch/mips/sibyte/bcm1480/irq.c
    +++ linux-2.6.28/arch/mips/sibyte/bcm1480/irq.c
    @@ -195,7 +195,7 @@ static void ack_bcm1480_irq(unsigned int
    if (pending) {
    #ifdef CONFIG_SMP
    int i;
    - for (i=0; i + for (i = 0; i < nr_cpu_ids; i++) {
    /*
    * Clear for all CPUs so an affinity switch
    * doesn't find an old status
    --- linux-2.6.28.orig/arch/mips/sibyte/bcm1480/smp.c
    +++ linux-2.6.28/arch/mips/sibyte/bcm1480/smp.c
    @@ -150,7 +150,7 @@ static void __init bcm1480_smp_setup(voi
    __cpu_number_map[0] = 0;
    __cpu_logical_map[0] = 0;

    - for (i = 1, num = 0; i < NR_CPUS; i++) {
    + for (i = 1, num = 0; i < nr_cpu_ids; i++) {
    if (cfe_cpu_stop(i) == 0) {
    cpu_set(i, cpu_possible_map);
    __cpu_number_map[i] = ++num;
    --- linux-2.6.28.orig/arch/mips/sibyte/sb1250/smp.c
    +++ linux-2.6.28/arch/mips/sibyte/sb1250/smp.c
    @@ -138,7 +138,7 @@ static void __init sb1250_smp_setup(void
    __cpu_number_map[0] = 0;
    __cpu_logical_map[0] = 0;

    - for (i = 1, num = 0; i < NR_CPUS; i++) {
    + for (i = 1, num = 0; i < nr_cpu_ids; i++) {
    if (cfe_cpu_stop(i) == 0) {
    cpu_set(i, cpu_possible_map);
    __cpu_number_map[i] = ++num;
    --- linux-2.6.28.orig/arch/mn10300/kernel/irq.c
    +++ linux-2.6.28/arch/mn10300/kernel/irq.c
    @@ -207,7 +207,7 @@ int show_interrupts(struct seq_file *p,
    /* display column title bar naming CPUs */
    case 0:
    seq_printf(p, " ");
    - for (j = 0; j < NR_CPUS; j++)
    + for (j = 0; j < nr_cpu_ids; j++)
    if (cpu_online(j))
    seq_printf(p, "CPU%d ", j);
    seq_putc(p, '\n');
    @@ -241,7 +241,7 @@ int show_interrupts(struct seq_file *p,
    /* polish off with NMI and error counters */
    case NR_IRQS:
    seq_printf(p, "NMI: ");
    - for (j = 0; j < NR_CPUS; j++)
    + for (j = 0; j < nr_cpu_ids; j++)
    if (cpu_online(j))
    seq_printf(p, "%10u ", nmi_count(j));
    seq_putc(p, '\n');
    --- linux-2.6.28.orig/arch/mn10300/kernel/setup.c
    +++ linux-2.6.28/arch/mn10300/kernel/setup.c
    @@ -276,7 +276,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? cpu_data + *pos : NULL;
    + return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/parisc/kernel/irq.c
    +++ linux-2.6.28/arch/parisc/kernel/irq.c
    @@ -309,11 +309,11 @@ unsigned long txn_alloc_addr(unsigned in
    next_cpu++; /* assign to "next" CPU we want this bugger on */

    /* validate entry */
    - while ((next_cpu < NR_CPUS) && (!cpu_data[next_cpu].txn_addr ||
    + while ((next_cpu < nr_cpu_ids) && (!cpu_data[next_cpu].txn_addr ||
    !cpu_online(next_cpu)))
    next_cpu++;

    - if (next_cpu >= NR_CPUS)
    + if (next_cpu >= nr_cpu_ids)
    next_cpu = 0; /* nothing else, assign monarch */

    return txn_affinity_addr(virt_irq, next_cpu);
    --- linux-2.6.28.orig/arch/parisc/kernel/processor.c
    +++ linux-2.6.28/arch/parisc/kernel/processor.c
    @@ -83,8 +83,8 @@ static int __cpuinit processor_probe(str
    struct cpuinfo_parisc *p;

    #ifdef CONFIG_SMP
    - if (num_online_cpus() >= NR_CPUS) {
    - printk(KERN_INFO "num_online_cpus() >= NR_CPUS\n");
    + if (num_online_cpus() >= nr_cpu_ids) {
    + printk(KERN_INFO "num_online_cpus() >= nr_cpu_ids\n");
    return 1;
    }
    #else
    --- linux-2.6.28.orig/arch/powerpc/include/asm/cputhreads.h
    +++ linux-2.6.28/arch/powerpc/include/asm/cputhreads.h
    @@ -34,7 +34,7 @@ static inline cpumask_t cpu_thread_mask_
    int i;

    res = CPU_MASK_NONE;
    - for (i = 0; i < NR_CPUS; i += threads_per_core) {
    + for (i = 0; i < nr_cpu_ids; i += threads_per_core) {
    cpus_shift_left(tmp, threads_core_mask, i);
    if (cpus_intersects(threads, tmp))
    cpu_set(i, res);
    --- linux-2.6.28.orig/arch/powerpc/kernel/irq.c
    +++ linux-2.6.28/arch/powerpc/kernel/irq.c
    @@ -232,7 +232,7 @@ void fixup_irqs(cpumask_t map)
    continue;

    cpus_and(mask, irq_desc[irq].affinity, map);
    - if (any_online_cpu(mask) == NR_CPUS) {
    + if (any_online_cpu(mask) >= nr_cpu_ids) {
    printk("Breaking affinity for irq %i\n", irq);
    mask = map;
    }
    --- linux-2.6.28.orig/arch/powerpc/kernel/machine_kexec_64.c
    +++ linux-2.6.28/arch/powerpc/kernel/machine_kexec_64.c
    @@ -176,7 +176,7 @@ static void kexec_prepare_cpus(void)
    my_cpu = get_cpu();

    /* check the others cpus are now down (via paca hw cpu id == -1) */
    - for (i=0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    if (i == my_cpu)
    continue;

    --- linux-2.6.28.orig/arch/powerpc/kernel/process.c
    +++ linux-2.6.28/arch/powerpc/kernel/process.c
    @@ -941,7 +941,7 @@ static inline int valid_irq_stack(unsign
    * Avoid crashing if the stack has overflowed and corrupted
    * task_cpu(p), which is in the thread_info struct.
    */
    - if (cpu < NR_CPUS && cpu_possible(cpu)) {
    + if (cpu < nr_cpu_ids && cpu_possible(cpu)) {
    stack_page = (unsigned long) hardirq_ctx[cpu];
    if (sp >= stack_page + sizeof(struct thread_struct)
    && sp <= stack_page + THREAD_SIZE - nbytes)
    --- linux-2.6.28.orig/arch/powerpc/kernel/setup-common.c
    +++ linux-2.6.28/arch/powerpc/kernel/setup-common.c
    @@ -166,7 +166,7 @@ static int show_cpuinfo(struct seq_file
    unsigned short maj;
    unsigned short min;

    - if (cpu_id == NR_CPUS) {
    + if (cpu_id == nr_cpu_ids) {
    struct device_node *root;
    const char *model = NULL;
    #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
    @@ -196,7 +196,7 @@ static int show_cpuinfo(struct seq_file
    /* We only show online cpus: disable preempt (overzealous, I
    * knew) to prevent cpu going down. */
    preempt_disable();
    - if (!cpu_online(cpu_id)) {
    + if (cpu_id >= nr_cpu_ids || !cpu_online(cpu_id)) {
    preempt_enable();
    return 0;
    }
    @@ -307,7 +307,7 @@ static void *c_start(struct seq_file *m,
    {
    unsigned long i = *pos;

    - return i <= NR_CPUS ? (void *)(i + 1) : NULL;
    + return i <= nr_cpu_ids ? (void *)(i + 1) : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    @@ -402,7 +402,7 @@ void __init smp_setup_cpu_maps(void)

    DBG("smp_setup_cpu_maps()\n");

    - while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) {
    + while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < nr_cpu_ids) {
    const int *intserv;
    int j, len;

    @@ -421,7 +421,7 @@ void __init smp_setup_cpu_maps(void)
    intserv = &cpu; /* assume logical == phys */
    }

    - for (j = 0; j < nthreads && cpu < NR_CPUS; j++) {
    + for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
    DBG(" thread %d -> cpu %d (hard id %d)\n",
    j, cpu, intserv[j]);
    cpu_set(cpu, cpu_present_map);
    --- linux-2.6.28.orig/arch/powerpc/mm/numa.c
    +++ linux-2.6.28/arch/powerpc/mm/numa.c
    @@ -765,7 +765,7 @@ void __init dump_numa_cpu_topology(void)
    * If we used a CPU iterator here we would miss printing
    * the holes in the cpumap.
    */
    - for (cpu = 0; cpu < NR_CPUS; cpu++) {
    + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
    if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
    if (count == 0)
    printk(" %u", cpu);
    @@ -778,7 +778,7 @@ void __init dump_numa_cpu_topology(void)
    }

    if (count > 1)
    - printk("-%u", NR_CPUS - 1);
    + printk("-%u", nr_cpu_ids - 1);
    printk("\n");
    }
    }
    --- linux-2.6.28.orig/arch/powerpc/platforms/powermac/setup.c
    +++ linux-2.6.28/arch/powerpc/platforms/powermac/setup.c
    @@ -365,7 +365,7 @@ static void __init pmac_setup_arch(void)
    */
    int cpu;

    - for (cpu = 1; cpu < 4 && cpu < NR_CPUS; ++cpu)
    + for (cpu = 1; cpu < 4 && cpu < nr_cpu_ids; ++cpu)
    cpu_set(cpu, cpu_possible_map);
    smp_ops = &psurge_smp_ops;
    }
    --- linux-2.6.28.orig/arch/powerpc/platforms/powermac/smp.c
    +++ linux-2.6.28/arch/powerpc/platforms/powermac/smp.c
    @@ -314,8 +314,8 @@ static int __init smp_psurge_probe(void)
    * device tree for them, and smp_setup_cpu_maps hasn't
    * set their bits in cpu_possible_map and cpu_present_map.
    */
    - if (ncpus > NR_CPUS)
    - ncpus = NR_CPUS;
    + if (ncpus > nr_cpu_ids)
    + ncpus = nr_cpu_ids;
    for (i = 1; i < ncpus ; ++i) {
    cpu_set(i, cpu_present_map);
    set_hard_smp_processor_id(i, i);
    --- linux-2.6.28.orig/arch/powerpc/platforms/pseries/hotplug-cpu.c
    +++ linux-2.6.28/arch/powerpc/platforms/pseries/hotplug-cpu.c
    @@ -221,7 +221,7 @@ static void pseries_remove_processor(str
    set_hard_smp_processor_id(cpu, -1);
    break;
    }
    - if (cpu == NR_CPUS)
    + if (cpu >= nr_cpu_ids)
    printk(KERN_WARNING "Could not find cpu to remove "
    "with physical id 0x%x\n", intserv[i]);
    }
    --- linux-2.6.28.orig/arch/powerpc/platforms/pseries/rtasd.c
    +++ linux-2.6.28/arch/powerpc/platforms/pseries/rtasd.c
    @@ -400,7 +400,7 @@ static void do_event_scan_all_cpus(long
    get_online_cpus();

    cpu = next_cpu(cpu, cpu_online_map);
    - if (cpu == NR_CPUS)
    + if (cpu >= nr_cpu_ids)
    break;
    }
    put_online_cpus();
    --- linux-2.6.28.orig/arch/powerpc/platforms/pseries/xics.c
    +++ linux-2.6.28/arch/powerpc/platforms/pseries/xics.c
    @@ -164,7 +164,7 @@ static int get_irq_server(unsigned int v

    server = first_cpu(tmp);

    - if (server < NR_CPUS)
    + if (server < nr_cpu_ids)
    return get_hard_smp_processor_id(server);

    if (strict_check)
    --- linux-2.6.28.orig/arch/powerpc/xmon/xmon.c
    +++ linux-2.6.28/arch/powerpc/xmon/xmon.c
    @@ -938,7 +938,7 @@ static int cpu_cmd(void)
    /* print cpus waiting or in xmon */
    printf("cpus stopped:");
    count = 0;
    - for (cpu = 0; cpu < NR_CPUS; ++cpu) {
    + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
    if (cpu_isset(cpu, cpus_in_xmon)) {
    if (count == 0)
    printf(" %x", cpu);
    @@ -950,7 +950,7 @@ static int cpu_cmd(void)
    }
    }
    if (count > 1)
    - printf("-%x", NR_CPUS - 1);
    + printf("-%x", nr_cpu_ids - 1);
    printf("\n");
    return 0;
    }
    --- linux-2.6.28.orig/arch/s390/kernel/smp.c
    +++ linux-2.6.28/arch/s390/kernel/smp.c
    @@ -438,7 +438,7 @@ static int smp_rescan_cpus_sigp(cpumask_
    int cpu_id, logical_cpu;

    logical_cpu = first_cpu(avail);
    - if (logical_cpu == NR_CPUS)
    + if (logical_cpu >= nr_cpu_ids)
    return 0;
    for (cpu_id = 0; cpu_id <= 65535; cpu_id++) {
    if (cpu_known(cpu_id))
    @@ -450,7 +450,7 @@ static int smp_rescan_cpus_sigp(cpumask_
    cpu_set(logical_cpu, cpu_present_map);
    smp_cpu_state[logical_cpu] = CPU_STATE_CONFIGURED;
    logical_cpu = next_cpu(logical_cpu, avail);
    - if (logical_cpu == NR_CPUS)
    + if (logical_cpu >= nr_cpu_ids)
    break;
    }
    return 0;
    @@ -463,7 +463,7 @@ static int smp_rescan_cpus_sclp(cpumask_
    int rc;

    logical_cpu = first_cpu(avail);
    - if (logical_cpu == NR_CPUS)
    + if (logical_cpu >= nr_cpu_ids)
    return 0;
    info = kmalloc(sizeof(*info), GFP_KERNEL);
    if (!info)
    @@ -485,7 +485,7 @@ static int smp_rescan_cpus_sclp(cpumask_
    else
    smp_cpu_state[logical_cpu] = CPU_STATE_CONFIGURED;
    logical_cpu = next_cpu(logical_cpu, avail);
    - if (logical_cpu == NR_CPUS)
    + if (logical_cpu >= nr_cpu_ids)
    break;
    }
    out:
    @@ -727,7 +727,7 @@ static int __init setup_possible_cpus(ch

    pcpus = simple_strtoul(s, NULL, 0);
    cpu_possible_map = cpumask_of_cpu(0);
    - for (cpu = 1; cpu < pcpus && cpu < NR_CPUS; cpu++)
    + for (cpu = 1; cpu < pcpus && cpu < nr_cpu_ids; cpu++)
    cpu_set(cpu, cpu_possible_map);
    return 0;
    }
    --- linux-2.6.28.orig/arch/sh/kernel/setup.c
    +++ linux-2.6.28/arch/sh/kernel/setup.c
    @@ -534,7 +534,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? cpu_data + *pos : NULL;
    + return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
    }
    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    {
    --- linux-2.6.28.orig/arch/sparc/kernel/smp.c
    +++ linux-2.6.28/arch/sparc/kernel/smp.c
    @@ -70,13 +70,12 @@ void __init smp_cpus_done(unsigned int m
    extern void smp4m_smp_done(void);
    extern void smp4d_smp_done(void);
    unsigned long bogosum = 0;
    - int cpu, num;
    + int cpu, num = 0;

    - for (cpu = 0, num = 0; cpu < NR_CPUS; cpu++)
    - if (cpu_online(cpu)) {
    - num++;
    - bogosum += cpu_data(cpu).udelay_val;
    - }
    + for_each_online_cpu(cpu) {
    + num++;
    + bogosum += cpu_data(cpu).udelay_val;
    + }

    printk("Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
    num, bogosum/(500000/HZ),
    --- linux-2.6.28.orig/arch/sparc/kernel/sun4d_smp.c
    +++ linux-2.6.28/arch/sparc/kernel/sun4d_smp.c
    @@ -228,11 +228,10 @@ void __init smp4d_smp_done(void)
    /* setup cpu list for irq rotation */
    first = 0;
    prev = &first;
    - for (i = 0; i < NR_CPUS; i++)
    - if (cpu_online(i)) {
    - *prev = i;
    - prev = &cpu_data(i).next;
    - }
    + for_each_online_cpu(i) {
    + *prev = i;
    + prev = &cpu_data(i).next;
    + }
    *prev = first;
    local_flush_cache_all();

    --- linux-2.6.28.orig/arch/sparc/kernel/sun4m_smp.c
    +++ linux-2.6.28/arch/sparc/kernel/sun4m_smp.c
    @@ -185,11 +185,9 @@ void __init smp4m_smp_done(void)
    /* setup cpu list for irq rotation */
    first = 0;
    prev = &first;
    - for (i = 0; i < NR_CPUS; i++) {
    - if (cpu_online(i)) {
    - *prev = i;
    - prev = &cpu_data(i).next;
    - }
    + for_each_online_cpu(i) {
    + *prev = i;
    + prev = &cpu_data(i).next;
    }
    *prev = first;
    local_flush_cache_all();
    --- linux-2.6.28.orig/arch/sparc/mm/srmmu.c
    +++ linux-2.6.28/arch/sparc/mm/srmmu.c
    @@ -1427,7 +1427,7 @@ static void __init init_vac_layout(void)
    min_line_size = vac_line_size;
    //FIXME: cpus not contiguous!!
    cpu++;
    - if (cpu >= NR_CPUS || !cpu_online(cpu))
    + if (cpu >= nr_cpu_ids || !cpu_online(cpu))
    break;
    #else
    break;
    --- linux-2.6.28.orig/arch/sparc64/kernel/ds.c
    +++ linux-2.6.28/arch/sparc64/kernel/ds.c
    @@ -653,7 +653,7 @@ static void __cpuinit dr_cpu_data(struct
    if (cpu_list[i] == CPU_SENTINEL)
    continue;

    - if (cpu_list[i] < NR_CPUS)
    + if (cpu_list[i] < nr_cpu_ids)
    cpu_set(cpu_list[i], mask);
    }

    --- linux-2.6.28.orig/arch/sparc64/kernel/irq.c
    +++ linux-2.6.28/arch/sparc64/kernel/irq.c
    @@ -260,12 +260,12 @@ static int irq_choose_cpu(unsigned int v
    spin_lock_irqsave(&irq_rover_lock, flags);

    while (!cpu_online(irq_rover)) {
    - if (++irq_rover >= NR_CPUS)
    + if (++irq_rover >= nr_cpu_ids)
    irq_rover = 0;
    }
    cpuid = irq_rover;
    do {
    - if (++irq_rover >= NR_CPUS)
    + if (++irq_rover >= nr_cpu_ids)
    irq_rover = 0;
    } while (!cpu_online(irq_rover));

    --- linux-2.6.28.orig/arch/sparc64/mm/init.c
    +++ linux-2.6.28/arch/sparc64/mm/init.c
    @@ -1080,7 +1080,7 @@ static void __init numa_parse_mdesc_grou
    if (strcmp(name, "cpu"))
    continue;
    id = mdesc_get_property(md, target, "id", NULL);
    - if (*id < NR_CPUS)
    + if (*id < nr_cpu_ids)
    cpu_set(*id, *mask);
    }
    }
    --- linux-2.6.28.orig/arch/um/kernel/um_arch.c
    +++ linux-2.6.28/arch/um/kernel/um_arch.c
    @@ -80,7 +80,7 @@ static int show_cpuinfo(struct seq_file

    static void *c_start(struct seq_file *m, loff_t *pos)
    {
    - return *pos < NR_CPUS ? cpu_data + *pos : NULL;
    + return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
    }

    static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    --- linux-2.6.28.orig/arch/x86/kernel/apic.c
    +++ linux-2.6.28/arch/x86/kernel/apic.c
    @@ -2106,7 +2106,7 @@ __cpuinit int apic_is_clustered_box(void
    bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
    bitmap_zero(clustermap, NUM_APIC_CLUSTERS);

    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    /* are we being called early in kernel startup? */
    if (bios_cpu_apicid) {
    id = bios_cpu_apicid[i];
    --- linux-2.6.28.orig/arch/x86/kernel/irq_32.c
    +++ linux-2.6.28/arch/x86/kernel/irq_32.c
    @@ -246,7 +246,7 @@ void fixup_irqs(cpumask_t map)
    continue;

    cpus_and(mask, desc->affinity, map);
    - if (any_online_cpu(mask) == NR_CPUS) {
    + if (any_online_cpu(mask) >= nr_cpu_ids) {
    printk("Breaking affinity for irq %i\n", irq);
    mask = map;
    }
    --- linux-2.6.28.orig/arch/x86/mach-voyager/voyager_smp.c
    +++ linux-2.6.28/arch/x86/mach-voyager/voyager_smp.c
    @@ -661,7 +661,7 @@ void __init smp_boot_cpus(void)

    /* loop over all the extended VIC CPUs and boot them. The
    * Quad CPUs must be bootstrapped by their extended VIC cpu */
    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    if (i == boot_cpu_id || !cpu_isset(i, phys_cpu_present_map))
    continue;
    do_boot_cpu(i);
    --- linux-2.6.28.orig/arch/x86/mm/numa_64.c
    +++ linux-2.6.28/arch/x86/mm/numa_64.c
    @@ -278,7 +278,7 @@ void __init numa_init_array(void)
    int rr, i;

    rr = first_node(node_online_map);
    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    if (early_cpu_to_node(i) != NUMA_NO_NODE)
    continue;
    numa_set_node(i, rr);
    @@ -549,7 +549,7 @@ void __init initmem_init(unsigned long s
    memnodemap[0] = 0;
    node_set_online(0);
    node_set(0, node_possible_map);
    - for (i = 0; i < NR_CPUS; i++)
    + for (i = 0; i < nr_cpu_ids; i++)
    numa_set_node(i, 0);
    e820_register_active_regions(0, start_pfn, last_pfn);
    setup_node_bootmem(0, start_pfn << PAGE_SHIFT, last_pfn << PAGE_SHIFT);
    --- linux-2.6.28.orig/arch/x86/mm/srat_64.c
    +++ linux-2.6.28/arch/x86/mm/srat_64.c
    @@ -382,7 +382,7 @@ int __init acpi_scan_nodes(unsigned long
    if (!node_online(i))
    setup_node_bootmem(i, nodes[i].start, nodes[i].end);

    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    int node = early_cpu_to_node(i);

    if (node == NUMA_NO_NODE)
    --- linux-2.6.28.orig/drivers/infiniband/hw/ehca/ehca_irq.c
    +++ linux-2.6.28/drivers/infiniband/hw/ehca/ehca_irq.c
    @@ -922,7 +922,7 @@ void ehca_destroy_comp_pool(void)

    unregister_hotcpu_notifier(&comp_pool_callback_nb);

    - for (i = 0; i < NR_CPUS; i++) {
    + for (i = 0; i < nr_cpu_ids; i++) {
    if (cpu_online(i))
    destroy_comp_task(pool, i);
    }
    --- linux-2.6.28.orig/kernel/kexec.c
    +++ linux-2.6.28/kernel/kexec.c
    @@ -1116,7 +1116,7 @@ void crash_save_cpu(struct pt_regs *regs
    struct elf_prstatus prstatus;
    u32 *buf;

    - if ((cpu < 0) || (cpu >= NR_CPUS))
    + if ((cpu < 0) || (cpu >= nr_cpu_ids))
    return;

    /* Using ELF notes here is opportunistic.
    --- linux-2.6.28.orig/kernel/smp.c
    +++ linux-2.6.28/kernel/smp.c
    @@ -222,7 +222,7 @@ int smp_call_function_single(int cpu, vo
    local_irq_save(flags);
    func(info);
    local_irq_restore(flags);
    - } else if ((unsigned)cpu < NR_CPUS && cpu_online(cpu)) {
    + } else if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) {
    struct call_single_data *data = NULL;

    if (!wait) {
    --- linux-2.6.28.orig/net/core/neighbour.c
    +++ linux-2.6.28/net/core/neighbour.c
    @@ -2423,7 +2423,7 @@ static void *neigh_stat_seq_start(struct
    if (*pos == 0)
    return SEQ_START_TOKEN;

    - for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos-1; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    @@ -2438,7 +2438,7 @@ static void *neigh_stat_seq_next(struct
    struct neigh_table *tbl = pde->data;
    int cpu;

    - for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    --- linux-2.6.28.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
    +++ linux-2.6.28/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
    @@ -291,7 +291,7 @@ static void *ct_cpu_seq_start(struct seq
    if (*pos == 0)
    return SEQ_START_TOKEN;

    - for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos-1; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    @@ -306,7 +306,7 @@ static void *ct_cpu_seq_next(struct seq_
    struct net *net = seq_file_net(seq);
    int cpu;

    - for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    --- linux-2.6.28.orig/net/ipv4/route.c
    +++ linux-2.6.28/net/ipv4/route.c
    @@ -427,7 +427,7 @@ static void *rt_cpu_seq_start(struct seq
    if (*pos == 0)
    return SEQ_START_TOKEN;

    - for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos-1; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    @@ -440,7 +440,7 @@ static void *rt_cpu_seq_next(struct seq_
    {
    int cpu;

    - for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu+1;
    --- linux-2.6.28.orig/net/netfilter/nf_conntrack_standalone.c
    +++ linux-2.6.28/net/netfilter/nf_conntrack_standalone.c
    @@ -200,7 +200,7 @@ static void *ct_cpu_seq_start(struct seq
    if (*pos == 0)
    return SEQ_START_TOKEN;

    - for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos-1; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu + 1;
    @@ -215,7 +215,7 @@ static void *ct_cpu_seq_next(struct seq_
    struct net *net = seq_file_net(seq);
    int cpu;

    - for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *pos = cpu + 1;
    --- linux-2.6.28.orig/security/selinux/selinuxfs.c
    +++ linux-2.6.28/security/selinux/selinuxfs.c
    @@ -1206,7 +1206,7 @@ static struct avc_cache_stats *sel_avc_g
    {
    int cpu;

    - for (cpu = *idx; cpu < NR_CPUS; ++cpu) {
    + for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
    if (!cpu_possible(cpu))
    continue;
    *idx = cpu + 1;

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  14. [PATCH 05/35] cpumask: remove min from first_cpu/next_cpu From: Rusty Russell <rusty@rustcorp.com.au>

    Seems like this has been here forever, but I can't see why:
    find_first_bit and find_next_bit both return >= NR_CPUS on failure.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    lib/cpumask.c | 7 +++----
    1 file changed, 3 insertions(+), 4 deletions(-)

    --- linux-2.6.28.orig/lib/cpumask.c
    +++ linux-2.6.28/lib/cpumask.c
    @@ -5,13 +5,13 @@

    int __first_cpu(const cpumask_t *srcp)
    {
    - return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
    + return find_first_bit(srcp->bits, NR_CPUS);
    }
    EXPORT_SYMBOL(__first_cpu);

    int __next_cpu(int n, const cpumask_t *srcp)
    {
    - return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
    + return find_next_bit(srcp->bits, NR_CPUS, n+1);
    }
    EXPORT_SYMBOL(__next_cpu);

    @@ -27,8 +27,7 @@ EXPORT_SYMBOL(cpumask_next_and);
    #if NR_CPUS > 64
    int __next_cpu_nr(int n, const cpumask_t *srcp)
    {
    - return min_t(int, nr_cpu_ids,
    - find_next_bit(srcp->bits, nr_cpu_ids, n+1));
    + return find_next_bit(srcp->bits, nr_cpu_ids, n+1);
    }
    EXPORT_SYMBOL(__next_cpu_nr);
    #endif

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  15. [PATCH 17/35] cpumask: make nr_cpu_ids the actual limit on bitmap size

    nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers;
    ie. the variable version of NR_CPUS.

    If we use this in *all* the cpu ops it simplifies the API, and will
    be possible to allocate cpumasks of the minimal length at runtime.

    From: Rusty Russell
    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 124 ++++++++++++++++++-----------------------------
    include/linux/seq_file.h | 2
    lib/cpumask.c | 14 +----
    3 files changed, 54 insertions(+), 86 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -3,7 +3,8 @@

    /*
    * Cpumasks provide a bitmap suitable for representing the
    - * set of CPU's in a system, one bit position per CPU number.
    + * set of CPU's in a system, one bit position per CPU number up to
    + * nr_cpu_ids (<= NR_CPUS).
    *
    * Old-style uses "cpumask_t", but new ops are "struct cpumask *";
    * don't put "struct cpumask"s on the stack.
    @@ -20,20 +21,6 @@
    * For details of cpumask_onto(), see bitmap_onto in lib/bitmap.c.
    * For details of cpumask_fold(), see bitmap_fold in lib/bitmap.c.
    *
    - * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    - * Note: The alternate operations with the suffix "_nr" are used
    - * to limit the range of the loop to nr_cpu_ids instead of
    - * NR_CPUS when NR_CPUS > 64 for performance reasons.
    - * If NR_CPUS is <= 64 then most assembler bitmask
    - * operators execute faster with a constant range, so
    - * the operator will continue to use NR_CPUS.
    - *
    - * Another consideration is that nr_cpu_ids is initialized
    - * to NR_CPUS and isn't lowered until the possible cpus are
    - * discovered (including any disabled cpus). So early uses
    - * will span the entire range of NR_CPUS.
    - * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    - *
    * The available cpumask operations are:
    *
    * void cpumask_set_cpu(cpu, mask) turn on bit 'cpu' in mask
    @@ -55,14 +42,12 @@
    * int cpumask_empty(mask) Is mask empty (no bits sets)?
    * int cpumask_full(mask) Is mask full (all bits sets)?
    * int cpumask_weight(mask) Hamming weigh - number of set bits
    - * int cpumask_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
    *
    * void cpumask_shift_right(dst, src, n) Shift right
    * void cpumask_shift_left(dst, src, n) Shift left
    *
    - * int first_cpu(mask) Number lowest set bit, or NR_CPUS
    - * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
    - * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
    + * int first_cpu(mask) Number lowest set bit, or >= nr_cpu_ids
    + * int next_cpu(cpu, mask) Next cpu past 'cpu', or >= nr_cpu_ids
    *
    * void cpumask_copy(dmask, smask) dmask = smask
    *
    @@ -113,8 +98,7 @@
    * void cpumask_onto(dst, orig, relmap) *dst = orig relative to relmap
    * void cpumask_fold(dst, orig, sz) dst bits = orig bits mod sz
    *
    - * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using NR_CPUS
    - * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
    + * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using nr_cpu_ids
    * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
    *
    * int num_online_cpus() Number of online CPUs
    @@ -150,7 +134,7 @@ struct cpumask {
    };
    #define cpumask_bits(maskp) ((maskp)->bits)

    -#define cpumask_size() (BITS_TO_LONGS(NR_CPUS) * sizeof(long))
    +#define cpumask_size() (BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long))

    /* Deprecated. */
    typedef struct cpumask cpumask_t;
    @@ -188,6 +172,9 @@ extern cpumask_t _unused_cpumask_arg_;
    #define cpus_fold(dst, orig, sz) \
    cpumask_fold(&(dst), &(orig), sz)
    #define cpus_addr(src) ((src).bits)
    +#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)
    /* End deprecated region. */

    #if NR_CPUS > 1
    @@ -225,73 +212,73 @@ static inline int cpumask_test_and_set_c

    static inline void cpumask_setall(struct cpumask *dstp)
    {
    - bitmap_fill(dstp->bits, NR_CPUS);
    + bitmap_fill(dstp->bits, nr_cpumask_bits);
    }

    static inline void cpumask_clear(struct cpumask *dstp)
    {
    - bitmap_zero(dstp->bits, NR_CPUS);
    + bitmap_zero(dstp->bits, nr_cpumask_bits);
    }

    static inline void cpumask_and(struct cpumask *dstp,
    const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - bitmap_and(dstp->bits, src1p->bits, src2p->bits, NR_CPUS);
    + bitmap_and(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline void cpumask_or(struct cpumask *dstp, const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - bitmap_or(dstp->bits, src1p->bits, src2p->bits, NR_CPUS);
    + bitmap_or(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline void cpumask_xor(struct cpumask *dstp,
    const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - bitmap_xor(dstp->bits, src1p->bits, src2p->bits, NR_CPUS);
    + bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline void cpumask_andnot(struct cpumask *dstp,
    const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, NR_CPUS);
    + bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline void cpumask_complement(struct cpumask *dstp,
    const struct cpumask *srcp)
    {
    - bitmap_complement(dstp->bits, srcp->bits, NR_CPUS);
    + bitmap_complement(dstp->bits, srcp->bits, nr_cpumask_bits);
    }

    static inline int cpumask_equal(const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - return bitmap_equal(src1p->bits, src2p->bits, NR_CPUS);
    + return bitmap_equal(src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline int cpumask_intersects(const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - return bitmap_intersects(src1p->bits, src2p->bits, NR_CPUS);
    + return bitmap_intersects(src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline int cpumask_subset(const struct cpumask *src1p,
    const struct cpumask *src2p)
    {
    - return bitmap_subset(src1p->bits, src2p->bits, NR_CPUS);
    + return bitmap_subset(src1p->bits, src2p->bits, nr_cpumask_bits);
    }

    static inline int cpumask_empty(const struct cpumask *srcp)
    {
    - return bitmap_empty(srcp->bits, NR_CPUS);
    + return bitmap_empty(srcp->bits, nr_cpumask_bits);
    }

    static inline int cpumask_full(const struct cpumask *srcp)
    {
    - return bitmap_full(srcp->bits, NR_CPUS);
    + return bitmap_full(srcp->bits, nr_cpumask_bits);
    }

    static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
    @@ -301,49 +288,49 @@ static inline int __cpus_weight(const cp

    static inline int cpumask_weight(const struct cpumask *srcp)
    {
    - return bitmap_weight(srcp->bits, NR_CPUS);
    + return bitmap_weight(srcp->bits, nr_cpumask_bits);
    }

    static inline void cpumask_shift_right(struct cpumask *dstp,
    const struct cpumask *srcp, int n)
    {
    - bitmap_shift_right(dstp->bits, srcp->bits, n, NR_CPUS);
    + bitmap_shift_right(dstp->bits, srcp->bits, n, nr_cpumask_bits);
    }

    static inline void cpumask_shift_left(struct cpumask *dstp,
    const struct cpumask *srcp, int n)
    {
    - bitmap_shift_left(dstp->bits, srcp->bits, n, NR_CPUS);
    + bitmap_shift_left(dstp->bits, srcp->bits, n, nr_cpumask_bits);
    }

    static inline int cpumask_scnprintf(char *buf, int len,
    const struct cpumask *srcp)
    {
    - return bitmap_scnprintf(buf, len, srcp->bits, NR_CPUS);
    + return bitmap_scnprintf(buf, len, srcp->bits, nr_cpumask_bits);
    }

    static inline int cpumask_parse_user(const char __user *buf, int len,
    struct cpumask *dstp)
    {
    - return bitmap_parse_user(buf, len, dstp->bits, NR_CPUS);
    + return bitmap_parse_user(buf, len, dstp->bits, nr_cpumask_bits);
    }

    static inline int cpulist_scnprintf(char *buf, int len,
    const struct cpumask *srcp)
    {
    - return bitmap_scnlistprintf(buf, len, srcp->bits, NR_CPUS);
    + return bitmap_scnlistprintf(buf, len, srcp->bits, nr_cpumask_bits);
    }

    static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
    {
    - return bitmap_parselist(buf, dstp->bits, NR_CPUS);
    + return bitmap_parselist(buf, dstp->bits, nr_cpumask_bits);
    }

    static inline int cpumask_cpuremap(int oldbit,
    const struct cpumask *oldp,
    const struct cpumask *newp)
    {
    - return bitmap_bitremap(oldbit, oldp->bits, newp->bits, NR_CPUS);
    + return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nr_cpumask_bits);
    }

    static inline void cpumask_remap(struct cpumask *dstp,
    @@ -351,26 +338,27 @@ static inline void cpumask_remap(struct
    const struct cpumask *oldp,
    const struct cpumask *newp)
    {
    - bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, NR_CPUS);
    + bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits,
    + nr_cpumask_bits);
    }

    static inline void cpumask_onto(struct cpumask *dstp,
    const struct cpumask *origp,
    const struct cpumask *relmapp)
    {
    - bitmap_onto(dstp->bits, origp->bits, relmapp->bits, NR_CPUS);
    + bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nr_cpumask_bits);
    }

    static inline void cpumask_fold(struct cpumask *dstp,
    const struct cpumask *origp, int sz)
    {
    - bitmap_fold(dstp->bits, origp->bits, sz, NR_CPUS);
    + bitmap_fold(dstp->bits, origp->bits, sz, nr_cpumask_bits);
    }

    static inline void cpumask_copy(struct cpumask *dstp,
    const struct cpumask *srcp)
    {
    - bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), NR_CPUS);
    + bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits);
    }

    /*
    @@ -468,34 +456,22 @@ int __any_online_cpu(const cpumask_t *ma
    #define for_each_cpu_mask(cpu, mask) \
    for ((cpu) = -1; \
    (cpu) = next_cpu((cpu), (mask)), \
    - (cpu) < NR_CPUS
    + (cpu) < nr_cpu_ids
    #define for_each_cpu_mask_and(cpu, mask, and) \
    for ((cpu) = -1; \
    (cpu) = cpumask_next_and((cpu), &(mask), &(and)), \
    (cpu) < nr_cpu_ids
    -#endif

    -#define cpumask_first_and(mask, and) cpumask_next_and(-1, (mask), (and))
    -
    -#if 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)
    -
    -#else /* NR_CPUS > 64 */
    -
    -int __next_cpu_nr(int n, const cpumask_t *srcp);
    -
    -#define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
    -#define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
    -
    -#define for_each_cpu_mask_nr(cpu, mask) \
    - for ((cpu) = -1; \
    - (cpu) = next_cpu_nr((cpu), (mask)), \
    - (cpu) < nr_cpu_ids
    +#define num_online_cpus() cpus_weight(cpu_online_map)
    +#define num_possible_cpus() cpus_weight(cpu_possible_map)
    +#define num_present_cpus() cpus_weight(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)
    +#endif /* NR_CPUS */

    -#endif /* NR_CPUS > 64 */
    +#define cpumask_first_and(mask, and) cpumask_next_and(-1, (mask), (and))

    /*
    * cpumask_var_t: struct cpumask for stack usage.
    @@ -596,9 +572,9 @@ 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)
    -#define num_possible_cpus() cpus_weight_nr(cpu_possible_map)
    -#define num_present_cpus() cpus_weight_nr(cpu_present_map)
    +#define num_online_cpus() cpus_weight(cpu_online_map)
    +#define num_possible_cpus() cpus_weight(cpu_possible_map)
    +#define num_present_cpus() cpus_weight(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)
    @@ -615,8 +591,8 @@ extern cpumask_t cpu_active_map;

    #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))

    -#define for_each_possible_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_possible_map)
    -#define for_each_online_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_online_map)
    -#define for_each_present_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_present_map)
    +#define for_each_possible_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
    +#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
    +#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)

    #endif /* __LINUX_CPUMASK_H */
    --- linux-2.6.28.orig/include/linux/seq_file.h
    +++ linux-2.6.28/include/linux/seq_file.h
    @@ -52,7 +52,7 @@ int seq_path_root(struct seq_file *m, st
    int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits);
    static inline int seq_cpumask(struct seq_file *m, cpumask_t *mask)
    {
    - return seq_bitmap(m, mask->bits, NR_CPUS);
    + return seq_bitmap(m, mask->bits, nr_cpu_ids);
    }

    static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
    --- linux-2.6.28.orig/lib/cpumask.c
    +++ linux-2.6.28/lib/cpumask.c
    @@ -5,33 +5,25 @@

    int __first_cpu(const cpumask_t *srcp)
    {
    - return find_first_bit(srcp->bits, NR_CPUS);
    + return find_first_bit(srcp->bits, nr_cpumask_bits);
    }
    EXPORT_SYMBOL(__first_cpu);

    int __next_cpu(int n, const cpumask_t *srcp)
    {
    - return find_next_bit(srcp->bits, NR_CPUS, n+1);
    + return find_next_bit(srcp->bits, nr_cpumask_bits, n+1);
    }
    EXPORT_SYMBOL(__next_cpu);

    int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp)
    {
    - while ((n = next_cpu_nr(n, *srcp)) < nr_cpu_ids)
    + while ((n = next_cpu(n, *srcp)) < nr_cpu_ids)
    if (cpumask_test_cpu(n, andp))
    break;
    return n;
    }
    EXPORT_SYMBOL(cpumask_next_and);

    -#if NR_CPUS > 64
    -int __next_cpu_nr(int n, const cpumask_t *srcp)
    -{
    - return find_next_bit(srcp->bits, nr_cpu_ids, n+1);
    -}
    -EXPORT_SYMBOL(__next_cpu_nr);
    -#endif
    -
    int __any_online_cpu(const cpumask_t *mask)
    {
    int cpu;

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  16. [PATCH 12/35] cpumask: make CONFIG_NR_CPUS always valid. From: Rusty Russell <rusty@rustcorp.com.au>

    Currently we have NR_CPUS, which is 1 on UP, and CONFIG_NR_CPUS on
    SMP. If we make CONFIG_NR_CPUS always valid (and always 1 on !SMP),
    we can skip the middleman.

    This also allows us to find and check all the remaining NR_CPUS users.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    arch/alpha/Kconfig | 10 +++++-----
    arch/arm/Kconfig | 6 +++---
    arch/ia64/Kconfig | 8 ++++----
    arch/m32r/Kconfig | 8 ++++----
    arch/mips/Kconfig | 4 ++--
    arch/parisc/Kconfig | 8 ++++----
    arch/s390/Kconfig | 10 +++++-----
    arch/sh/Kconfig | 10 +++++-----
    arch/sparc/Kconfig | 8 ++++----
    arch/sparc64/Kconfig | 8 ++++----
    arch/um/Kconfig | 8 ++++----
    arch/x86/Kconfig | 6 +++---
    include/linux/threads.h | 10 ++--------
    13 files changed, 49 insertions(+), 55 deletions(-)

    --- linux-2.6.28.orig/arch/alpha/Kconfig
    +++ linux-2.6.28/arch/alpha/Kconfig
    @@ -544,11 +544,11 @@ config HAVE_DEC_LOCK
    default y

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "32" if ALPHA_GENERIC || ALPHA_MARVEL
    - default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    + default "32" if SMP && (ALPHA_GENERIC || ALPHA_MARVEL)
    + default "4" if SMP && (!ALPHA_GENERIC && !ALPHA_MARVEL)
    help
    MARVEL support can handle a maximum of 32 CPUs, all the others
    with working support have a maximum of 4 CPUs.
    --- linux-2.6.28.orig/arch/arm/Kconfig
    +++ linux-2.6.28/arch/arm/Kconfig
    @@ -769,9 +769,9 @@ config PAGE_OFFSET
    default 0xC0000000

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    default "4"

    config HOTPLUG_CPU
    --- linux-2.6.28.orig/arch/ia64/Kconfig
    +++ linux-2.6.28/arch/ia64/Kconfig
    @@ -315,10 +315,10 @@ config SMP
    If you don't know what to do here, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-4096)"
    - range 2 4096
    - depends on SMP
    - default "4096"
    + int "Maximum number of CPUs (2-4096)" if SMP
    + range 2 4096 if SMP
    + default "1" if !SMP
    + default "4096" if SMP
    help
    You should set this to the number of CPUs in your system, but
    keep in mind that a kernel compiled for, e.g., 2 CPUs will boot but
    --- linux-2.6.28.orig/arch/m32r/Kconfig
    +++ linux-2.6.28/arch/m32r/Kconfig
    @@ -319,10 +319,10 @@ config CHIP_M32700_TS1
    default n

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "2"
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    + default "2" if SMP
    help
    This allows you to specify the maximum number of CPUs which this
    kernel will support. The maximum supported value is 32 and the
    --- linux-2.6.28.orig/arch/mips/Kconfig
    +++ linux-2.6.28/arch/mips/Kconfig
    @@ -1719,9 +1719,9 @@ config NR_CPUS_DEFAULT_64
    bool

    config NR_CPUS
    - int "Maximum number of CPUs (2-64)"
    + int "Maximum number of CPUs (2-64)" if SMP
    range 1 64 if NR_CPUS_DEFAULT_1
    - depends on SMP
    + default "1" if !SMP
    default "1" if NR_CPUS_DEFAULT_1
    default "2" if NR_CPUS_DEFAULT_2
    default "4" if NR_CPUS_DEFAULT_4
    --- linux-2.6.28.orig/arch/parisc/Kconfig
    +++ linux-2.6.28/arch/parisc/Kconfig
    @@ -256,10 +256,10 @@ config HPUX
    depends on !64BIT

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "32"
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    + default "32" if SMP

    endmenu

    --- linux-2.6.28.orig/arch/s390/Kconfig
    +++ linux-2.6.28/arch/s390/Kconfig
    @@ -116,11 +116,11 @@ config SMP
    Even if you don't know what to do here, say Y.

    config NR_CPUS
    - int "Maximum number of CPUs (2-64)"
    - range 2 64
    - depends on SMP
    - default "32" if !64BIT
    - default "64" if 64BIT
    + int "Maximum number of CPUs (2-64)" if SMP
    + range 2 64 if SMP
    + default "1" if !SMP
    + default "32" if SMP && !64BIT
    + default "64" if SMP && 64BIT
    help
    This allows you to specify the maximum number of CPUs which this
    kernel will support. The maximum supported value is 64 and the
    --- linux-2.6.28.orig/arch/sh/Kconfig
    +++ linux-2.6.28/arch/sh/Kconfig
    @@ -545,11 +545,11 @@ config SMP
    If you don't know what to do here, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "4" if CPU_SHX3
    - default "2"
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    + default "4" if SMP && CPU_SHX3
    + default "2" if SMP
    help
    This allows you to specify the maximum number of CPUs which this
    kernel will support. The maximum supported value is 32 and the
    --- linux-2.6.28.orig/arch/sparc/Kconfig
    +++ linux-2.6.28/arch/sparc/Kconfig
    @@ -64,10 +64,10 @@ config SMP
    If you don't know what to do here, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "32"
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if SMP
    + default "32" if SMP

    config SPARC
    bool
    --- linux-2.6.28.orig/arch/sparc64/Kconfig
    +++ linux-2.6.28/arch/sparc64/Kconfig
    @@ -169,10 +169,10 @@ config SMP
    If you don't know what to do here, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-1024)"
    - range 2 1024
    - depends on SMP
    - default "64"
    + int "Maximum number of CPUs (2-1024)" if SMP
    + range 2 1024 if SMP
    + default "1" if !SMP
    + default "64" if SMP

    source "drivers/cpufreq/Kconfig"

    --- linux-2.6.28.orig/arch/um/Kconfig
    +++ linux-2.6.28/arch/um/Kconfig
    @@ -198,10 +198,10 @@ config SMP
    If you don't know what to do, say N.

    config NR_CPUS
    - int "Maximum number of CPUs (2-32)"
    - range 2 32
    - depends on SMP
    - default "32"
    + int "Maximum number of CPUs (2-32)" if SMP
    + range 2 32 if SMP
    + default "1" if !SMP
    + default "32" if SMP

    config HIGHMEM
    bool "Highmem support (EXPERIMENTAL)"
    --- linux-2.6.28.orig/arch/x86/Kconfig
    +++ linux-2.6.28/arch/x86/Kconfig
    @@ -585,12 +585,12 @@ config MAXSMP
    If unsure, say N.

    config NR_CPUS
    - depends on SMP
    int "Maximum number of CPUs" if SMP && !MAXSMP
    range 2 512 if SMP && !MAXSMP
    + default "1" if !SMP
    default "4096" if MAXSMP
    - default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000
    - default "8"
    + default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
    + default "8" if SMP
    help
    This allows you to specify the maximum number of CPUs which this
    kernel will support. The maximum supported value is 512 (4096
    --- linux-2.6.28.orig/include/linux/threads.h
    +++ linux-2.6.28/include/linux/threads.h
    @@ -8,16 +8,10 @@
    */

    /*
    - * Maximum supported processors that can run under SMP. This value is
    - * set via configure setting. The maximum is equal to the size of the
    - * bitmasks used on that platform, i.e. 32 or 64. Setting this smaller
    - * saves quite a bit of memory.
    + * Maximum supported processors. Setting this smaller saves quite a
    + * bit of memory. Use nr_cpu_ids instead of this except for bitmaps.
    */
    -#ifdef CONFIG_SMP
    #define NR_CPUS CONFIG_NR_CPUS
    -#else
    -#define NR_CPUS 1
    -#endif

    #define MIN_THREADS_LEFT_FOR_ROOT 4


    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  17. [PATCH 32/35] cpumask: debug options for cpumasks From: Rusty Russell <rusty@rustcorp.com.au>

    It's useful to check that no one is accessing > nr_cpumask_bits for
    cpumasks. This also allows you to turn on CONFIG_CPUMASKS_OFFSTACK
    even for smaller CONFIG_NR_CPUS.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 23 +++++++++++++++++------
    lib/Kconfig.debug | 6 ++++++
    lib/cpumask.c | 3 +++
    3 files changed, 26 insertions(+), 6 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -250,23 +250,34 @@ extern cpumask_t _unused_cpumask_arg_;
    #define cpu_mask_all (*(cpumask_t *)cpu_all_mask)
    /* End deprecated region. */

    +/* verify cpu argument to cpumask_* operators */
    +static inline unsigned int cpumask_check(unsigned int cpu)
    +{
    +#ifdef CONFIG_DEBUG_PER_CPU_MAPS
    + /* This breaks at runtime. */
    + BUG_ON(cpu >= nr_cpumask_bits);
    +#endif /* CONFIG_DEBUG_PER_CPU_MAPS */
    + return cpu;
    +}
    +
    /* cpumask_* operators */
    static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
    {
    - set_bit(cpu, cpumask_bits(dstp));
    + set_bit(cpumask_check(cpu), cpumask_bits(dstp));
    }

    static inline void cpumask_clear_cpu(int cpu, volatile struct cpumask *dstp)
    {
    - clear_bit(cpu, cpumask_bits(dstp));
    + clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
    }

    /* No static inline type checking - see Subtlety (1) above. */
    -#define cpumask_test_cpu(cpu, cpumask) test_bit((cpu), (cpumask)->bits)
    +#define cpumask_test_cpu(cpu, cpumask) \
    + test_bit(cpumask_check(cpu), (cpumask)->bits)

    static inline int cpumask_test_and_set_cpu(int cpu, struct cpumask *addr)
    {
    - return test_and_set_bit(cpu, cpumask_bits(addr));
    + return test_and_set_bit(cpumask_check(cpu), cpumask_bits(addr));
    }

    static inline void cpumask_setall(struct cpumask *dstp)
    @@ -400,8 +411,8 @@ static inline int cpumask_cpuremap(int o
    const struct cpumask *oldp,
    const struct cpumask *newp)
    {
    - return bitmap_bitremap(oldbit, cpumask_bits(oldp), cpumask_bits(newp),
    - nr_cpumask_bits);
    + return bitmap_bitremap(cpumask_check(oldbit), cpumask_bits(oldp),
    + cpumask_bits(newp), nr_cpumask_bits);
    }

    static inline void cpumask_remap(struct cpumask *dstp,
    --- linux-2.6.28.orig/lib/Kconfig.debug
    +++ linux-2.6.28/lib/Kconfig.debug
    @@ -784,6 +784,12 @@ config SYSCTL_SYSCALL_CHECK
    to properly maintain and use. This enables checks that help
    you to keep things correct.

    +config DEBUG_PER_CPU_MAPS
    + bool "Cpumask debug checks"
    + ---help---
    + Extra debugging for cpumasks.
    + eg. to make sure accesses to cpumasks are < nr_cpu_ids.
    +
    source kernel/trace/Kconfig

    config PROVIDE_OHCI1394_DMA_INIT
    --- linux-2.6.28.orig/lib/cpumask.c
    +++ linux-2.6.28/lib/cpumask.c
    @@ -11,6 +11,9 @@ EXPORT_SYMBOL(cpumask_first);

    int cpumask_next(int n, const cpumask_t *srcp)
    {
    + /* -1 is a legal arg here. */
    + if (n != -1)
    + cpumask_check(n);
    return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
    }
    EXPORT_SYMBOL(cpumask_next);

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  18. [PATCH 14/35] cpumask: add nr_cpumask_bits

    When nr_cpu_ids is set to CONFIG_NR_CPUS then references to nr_cpu_ids
    will return the maximum index of the configured NR_CPUS (+1) instead
    of the maximum index of the possible number of cpus (+1). This results
    in extra unused memory being allocated by functions that are setting up
    arrays of structs to keep track of per cpu items.

    Since we do want to keep the ability to use constants for the cpu bit
    operators on smaller systems (which are generally much faster assembler
    ops), we introduce a separate "nr_cpumask_bits" to replace "nr_cpu_ids"
    only for the inline assembly ops. This will be a constant when
    CONFIG_CPUMASK_OFFSTACK is undefined and a variable when it is defined.

    Thus "nr_cpu_ids" reverts back to being a variable representing the
    maximum possible cpu (+1), except in the non-SMP case where it is a
    constant value of 1. The relationship between the related variables
    and constants is: (1 <= nr_cpu_ids <= nr_cpumask_bits <= NR_CPUS).

    Signed-off-by: Mike Travis
    ---
    arch/x86/kernel/setup_percpu.c | 7 ++++---
    include/linux/cpumask.h | 8 ++++++++
    2 files changed, 12 insertions(+), 3 deletions(-)

    --- linux-2.6.28.orig/arch/x86/kernel/setup_percpu.c
    +++ linux-2.6.28/arch/x86/kernel/setup_percpu.c
    @@ -155,6 +155,10 @@ void __init setup_per_cpu_areas(void)
    printk(KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n",
    size);

    + printk(KERN_DEBUG
    + "NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n",
    + NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
    +
    for_each_possible_cpu(cpu) {
    #ifndef CONFIG_NEED_MULTIPLE_NODES
    ptr = __alloc_bootmem(size, align,
    @@ -183,9 +187,6 @@ void __init setup_per_cpu_areas(void)
    memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
    }

    - printk(KERN_DEBUG "NR_CPUS: %d, nr_cpu_ids: %d, nr_node_ids %d\n",
    - NR_CPUS, nr_cpu_ids, nr_node_ids);
    -
    /* Setup percpu data maps */
    setup_per_cpu_maps();

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -197,6 +197,14 @@ extern int nr_cpu_ids;
    #define nr_cpu_ids NR_CPUS
    #endif

    +/* The number of bits to hand to the bitmask ops. */
    +#if NR_CPUS <= BITS_PER_LONG
    +/* This produces more efficient code. */
    +#define nr_cpumask_bits NR_CPUS
    +#else
    +#define nr_cpumask_bits nr_cpu_ids
    +#endif
    +
    static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
    {
    set_bit(cpu, dstp->bits);

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  19. [PATCH 13/35] cpumask: make nr_cpu_ids valid in all configurations. From: Rusty Russell <rusty@rustcorp.com.au>

    nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers;
    ie. the variable version of NR_CPUS.

    This makes is valid in all configs, including UP.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 9 +++++++--
    init/main.c | 7 +++++++
    2 files changed, 14 insertions(+), 2 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -190,6 +190,13 @@ extern cpumask_t _unused_cpumask_arg_;
    #define cpus_addr(src) ((src).bits)
    /* End deprecated region. */

    +#if NR_CPUS > 1
    +/* Starts at NR_CPUS until we know better. */
    +extern int nr_cpu_ids;
    +#else
    +#define nr_cpu_ids NR_CPUS
    +#endif
    +
    static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
    {
    set_bit(cpu, dstp->bits);
    @@ -429,7 +436,6 @@ extern cpumask_t cpu_mask_all;

    #if NR_CPUS == 1

    -#define nr_cpu_ids 1
    #define first_cpu(src) ({ (void)(src); 0; })
    #define next_cpu(n, src) ({ (void)(src); 1; })
    #define cpumask_next_and(n, srcp, andp) ({ (void)(srcp), (void)(andp); 1; })
    @@ -442,7 +448,6 @@ extern cpumask_t cpu_mask_all;

    #else /* NR_CPUS > 1 */

    -extern int nr_cpu_ids;
    int __first_cpu(const cpumask_t *srcp);
    int __next_cpu(int n, const cpumask_t *srcp);
    int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
    --- linux-2.6.28.orig/init/main.c
    +++ linux-2.6.28/init/main.c
    @@ -374,6 +374,8 @@ EXPORT_SYMBOL(cpu_mask_all);
    #endif

    /* Setup number of possible processor ids */
    +/* nr_cpu_ids is a real variable for SMP. */
    +#ifndef nr_cpu_ids
    int nr_cpu_ids __read_mostly = NR_CPUS;
    EXPORT_SYMBOL(nr_cpu_ids);

    @@ -387,6 +389,11 @@ static void __init setup_nr_cpu_ids(void

    nr_cpu_ids = highest_cpu + 1;
    }
    +#else
    +void __init setup_nr_cpu_ids(void)
    +{
    +}
    +#endif /* ... nr_cpu_ids is a constant. */

    #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
    unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;

    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  20. [PATCH 28/35] cpumask: CONFIG_BITS_ALL, CONFIG_BITS_NONE and CONFIG_BITS_CPU0 From: Rusty Russell <rusty@rustcorp.com.au>

    Since we're now preferring raw bitmaps for (eventually rare) static
    cpumasks, we replace CPU_MASK_X with CPU_BITS_X.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    ---
    include/linux/cpumask.h | 44 ++++++++++++++++++++++++--------------------
    1 file changed, 24 insertions(+), 20 deletions(-)

    --- linux-2.6.28.orig/include/linux/cpumask.h
    +++ linux-2.6.28/include/linux/cpumask.h
    @@ -53,8 +53,9 @@
    *
    * size_t cpumask_size() Length of cpumask in bytes.
    * const struct cpumask *cpumask_of(cpu) Return cpumask with bit 'cpu' set
    - * CPU_MASK_ALL Initializer - all bits set
    - * CPU_MASK_NONE Initializer - no bits set
    + * CPU_BITS_ALL Initializer - all bits set
    + * CPU_BITS_NONE Initializer - no bits set
    + * CPU_BITS_CPU0 Initializer - first bit set
    * unsigned long *cpumask_bits(mask) Array of unsigned long's in mask
    *
    * struct cpumask *to_cpumask(const unsigned long[])
    @@ -115,6 +116,9 @@ struct cpumask {
    typedef struct cpumask cpumask_t;
    extern cpumask_t _unused_cpumask_arg_;

    +#define CPU_MASK_ALL ((cpumask_t){ CPU_BITS_ALL })
    +#define CPU_MASK_NONE ((cpumask_t){ CPU_BITS_NONE })
    +#define CPU_MASK_CPU0 ((cpumask_t){ CPU_BITS_CPU0 })
    #define cpu_set(cpu, dst) cpumask_set_cpu((cpu), &(dst))
    #define cpu_clear(cpu, dst) cpumask_clear_cpu((cpu), &(dst))
    #define cpu_test_and_set(cpu, mask) cpumask_test_and_set_cpu((cpu), &(mask))
    @@ -400,20 +404,20 @@ static inline const struct cpumask *cpum

    #if NR_CPUS <= BITS_PER_LONG

    -#define CPU_MASK_ALL \
    -(cpumask_t) { { \
    - [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    -} }
    +#define CPU_BITS_ALL \
    +{ \
    + [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    +}

    #define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)

    #else

    -#define CPU_MASK_ALL \
    -(cpumask_t) { { \
    - [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
    - [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    -} }
    +#define CPU_BITS_ALL \
    +{ \
    + [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL, \
    + [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD \
    +}

    /* cpu_mask_all is in init/main.c */
    extern cpumask_t cpu_mask_all;
    @@ -421,15 +425,15 @@ extern cpumask_t cpu_mask_all;

    #endif

    -#define CPU_MASK_NONE \
    -(cpumask_t) { { \
    - [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
    -} }
    -
    -#define CPU_MASK_CPU0 \
    -(cpumask_t) { { \
    - [0] = 1UL \
    -} }
    +#define CPU_BITS_NONE \
    +{ \
    + [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = 0UL \
    +}
    +
    +#define CPU_BITS_CPU0 \
    +{ \
    + [0] = 1UL \
    +}

    #if NR_CPUS == 1


    --
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast