Skip to content

Commit

Permalink
cpumask: Use all NR_CPUS bits unless CONFIG_CPUMASK_OFFSTACK
Browse files Browse the repository at this point in the history
Impact: futureproof as we convert more code to new APIs

The old cpumask operators treat all NR_CPUS bits as relevent, the new
ones use nr_cpumask_bits.  For large NR_CPUS and small nr_cpu_ids, this
makes a difference.

However, mixing the two can cause problems with undefined bits.  An
arch which sets CONFIG_CPUMASK_OFFSTACK should have converted across
to the new operators, so it's safe in that case.

(Thanks to Stephen Rothwell for bisecting the initial unused-bits bug,
and Mike Travis for this solution).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mike Travis <travis@sgi.com>
  • Loading branch information
Rusty Russell committed Dec 13, 2008
1 parent f0b848c commit 7be7585
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/linux/cpumask.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,22 @@ extern cpumask_t cpu_active_map;
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
}

/* This produces more efficient code. */
#define nr_cpumask_bits NR_CPUS

#else /* NR_CPUS > BITS_PER_LONG */

#define CPU_BITS_ALL \
{ \
[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
}
#endif /* NR_CPUS > BITS_PER_LONG */

#ifdef CONFIG_CPUMASK_OFFSTACK
/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
* not all bits may be allocated. */
#define nr_cpumask_bits nr_cpu_ids
#endif /* NR_CPUS > BITS_PER_LONG */
#else
#define nr_cpumask_bits NR_CPUS
#endif

/* verify cpu argument to cpumask_* operators */
static inline unsigned int cpumask_check(unsigned int cpu)
Expand Down

0 comments on commit 7be7585

Please sign in to comment.