Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
cpumask.h File Reference
#include <linux/kernel.h>
#include <linux/threads.h>
#include <linux/bitmap.h>
#include <linux/bug.h>

Go to the source code of this file.

Data Structures

struct  cpumask
 

Macros

#define cpumask_bits(maskp)   ((maskp)->bits)
 
#define nr_cpumask_bits   NR_CPUS
 
#define num_online_cpus()   1U
 
#define num_possible_cpus()   1U
 
#define num_present_cpus()   1U
 
#define num_active_cpus()   1U
 
#define cpu_online(cpu)   ((cpu) == 0)
 
#define cpu_possible(cpu)   ((cpu) == 0)
 
#define cpu_present(cpu)   ((cpu) == 0)
 
#define cpu_active(cpu)   ((cpu) == 0)
 
#define for_each_cpu(cpu, mask)
 
#define for_each_cpu_not(cpu, mask)
 
#define for_each_cpu_and(cpu, mask, and)
 
#define CPU_BITS_NONE
 
#define CPU_BITS_CPU0
 
#define cpumask_test_cpu(cpu, cpumask)   test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
 
#define cpumask_any(srcp)   cpumask_first(srcp)
 
#define cpumask_first_and(src1p, src2p)   cpumask_next_and(-1, (src1p), (src2p))
 
#define cpumask_any_and(mask1, mask2)   cpumask_first_and((mask1), (mask2))
 
#define cpumask_of(cpu)   (get_cpu_mask(cpu))
 
#define cpu_all_mask   to_cpumask(cpu_all_bits)
 
#define cpu_none_mask   to_cpumask(cpu_bit_bitmap[0])
 
#define for_each_possible_cpu(cpu)   for_each_cpu((cpu), cpu_possible_mask)
 
#define for_each_online_cpu(cpu)   for_each_cpu((cpu), cpu_online_mask)
 
#define for_each_present_cpu(cpu)   for_each_cpu((cpu), cpu_present_mask)
 
#define to_cpumask(bitmap)
 
#define cpu_is_offline(cpu)   unlikely(!cpu_online(cpu))
 
#define CPU_BITS_ALL
 
#define cpumask_of_cpu(cpu)   (*get_cpu_mask(cpu))
 
#define CPU_MASK_LAST_WORD   BITMAP_LAST_WORD_MASK(NR_CPUS)
 
#define CPU_MASK_ALL
 
#define CPU_MASK_NONE
 
#define CPU_MASK_CPU0
 
#define first_cpu(src)   __first_cpu(&(src))
 
#define next_cpu(n, src)   __next_cpu((n), &(src))
 
#define any_online_cpu(mask)   cpumask_any_and(&mask, cpu_online_mask)
 
#define for_each_cpu_mask(cpu, mask)
 
#define for_each_cpu_mask_nr(cpu, mask)   for_each_cpu_mask(cpu, mask)
 
#define cpus_addr(src)   ((src).bits)
 
#define cpu_set(cpu, dst)   __cpu_set((cpu), &(dst))
 
#define cpu_clear(cpu, dst)   __cpu_clear((cpu), &(dst))
 
#define cpus_setall(dst)   __cpus_setall(&(dst), NR_CPUS)
 
#define cpus_clear(dst)   __cpus_clear(&(dst), NR_CPUS)
 
#define cpu_isset(cpu, cpumask)   test_bit((cpu), (cpumask).bits)
 
#define cpu_test_and_set(cpu, cpumask)   __cpu_test_and_set((cpu), &(cpumask))
 
#define cpus_and(dst, src1, src2)   __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
 
#define cpus_or(dst, src1, src2)   __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
 
#define cpus_xor(dst, src1, src2)   __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
 
#define cpus_andnot(dst, src1, src2)   __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
 
#define cpus_equal(src1, src2)   __cpus_equal(&(src1), &(src2), NR_CPUS)
 
#define cpus_intersects(src1, src2)   __cpus_intersects(&(src1), &(src2), NR_CPUS)
 
#define cpus_subset(src1, src2)   __cpus_subset(&(src1), &(src2), NR_CPUS)
 
#define cpus_empty(src)   __cpus_empty(&(src), NR_CPUS)
 
#define cpus_weight(cpumask)   __cpus_weight(&(cpumask), NR_CPUS)
 
#define cpus_shift_left(dst, src, n)   __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
 

Typedefs

typedef struct cpumask cpumask_t
 
typedef struct cpumask cpumask_var_t [1]
 

Functions

int cpumask_next_and (int n, const struct cpumask *, const struct cpumask *)
 
int cpumask_any_but (const struct cpumask *mask, unsigned int cpu)
 
const DECLARE_BITMAP (cpu_all_bits, NR_CPUS)
 
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)
 
int __first_cpu (const cpumask_t *srcp)
 
int __next_cpu (int n, const cpumask_t *srcp)
 

Variables

int nr_cpu_ids
 
struct cpumask *const cpu_possible_mask
 
struct cpumask *const cpu_online_mask
 
struct cpumask *const cpu_present_mask
 
struct cpumask *const cpu_active_mask
 
const unsigned long cpu_bit_bitmap [BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)]
 

Macro Definition Documentation

#define any_online_cpu (   mask)    cpumask_any_and(&mask, cpu_online_mask)

Definition at line 821 of file cpumask.h.

#define cpu_active (   cpu)    ((cpu) == 0)

Definition at line 101 of file cpumask.h.

#define cpu_all_mask   to_cpumask(cpu_all_bits)

Definition at line 701 of file cpumask.h.

#define CPU_BITS_ALL
Value:

Definition at line 758 of file cpumask.h.

#define CPU_BITS_CPU0
Value:
{ \
[0] = 1UL \
}

Definition at line 245 of file cpumask.h.

#define CPU_BITS_NONE
Value:
{ \
[0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
}

Definition at line 240 of file cpumask.h.

#define cpu_clear (   cpu,
  dst 
)    __cpu_clear((cpu), &(dst))

Definition at line 850 of file cpumask.h.

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

Definition at line 755 of file cpumask.h.

#define cpu_isset (   cpu,
  cpumask 
)    test_bit((cpu), (cpumask).bits)

Definition at line 869 of file cpumask.h.

#define CPU_MASK_ALL
Value:

Definition at line 784 of file cpumask.h.

#define CPU_MASK_CPU0
Value:
(cpumask_t) { { \
[0] = 1UL \
} }

Definition at line 804 of file cpumask.h.

#define CPU_MASK_LAST_WORD   BITMAP_LAST_WORD_MASK(NR_CPUS)

Definition at line 780 of file cpumask.h.

#define CPU_MASK_NONE
Value:
(cpumask_t) { { \
[0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
} }

Definition at line 799 of file cpumask.h.

#define cpu_none_mask   to_cpumask(cpu_bit_bitmap[0])

Definition at line 704 of file cpumask.h.

#define cpu_online (   cpu)    ((cpu) == 0)

Definition at line 98 of file cpumask.h.

#define cpu_possible (   cpu)    ((cpu) == 0)

Definition at line 99 of file cpumask.h.

#define cpu_present (   cpu)    ((cpu) == 0)

Definition at line 100 of file cpumask.h.

#define cpu_set (   cpu,
  dst 
)    __cpu_set((cpu), &(dst))

Definition at line 844 of file cpumask.h.

#define cpu_test_and_set (   cpu,
  cpumask 
)    __cpu_test_and_set((cpu), &(cpumask))

Definition at line 871 of file cpumask.h.

#define cpumask_any (   srcp)    cpumask_first(srcp)

cpumask_any - pick a "random" cpu from *srcp : the input cpumask

Returns >= nr_cpu_ids if no cpus set.

Definition at line 507 of file cpumask.h.

#define cpumask_any_and (   mask1,
  mask2 
)    cpumask_first_and((mask1), (mask2))

cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 : the first input cpumask : the second input cpumask

Returns >= nr_cpu_ids if no cpus set.

Definition at line 525 of file cpumask.h.

#define cpumask_bits (   maskp)    ((maskp)->bits)

cpumask_bits - get the bits in a cpumask : the struct cpumask *

You should only assume nr_cpu_ids bits of this mask are valid. This is a macro so it's const-correct.

Definition at line 23 of file cpumask.h.

#define cpumask_first_and (   src1p,
  src2p 
)    cpumask_next_and(-1, (src1p), (src2p))

cpumask_first_and - return the first cpu from *srcp1 & *srcp2 : the first input : the second input

Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and().

Definition at line 516 of file cpumask.h.

#define cpumask_of (   cpu)    (get_cpu_mask(cpu))

cpumask_of - the cpumask containing just a given cpu : the cpu (<= nr_cpu_ids)

Definition at line 531 of file cpumask.h.

#define cpumask_of_cpu (   cpu)    (*get_cpu_mask(cpu))

Definition at line 778 of file cpumask.h.

#define cpumask_test_cpu (   cpu,
  cpumask 
)    test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))

cpumask_test_cpu - test for a cpu in a cpumask : cpu number (< nr_cpu_ids) : the cpumask pointer

Returns 1 if is set in , else returns 0

No static inline type checking - see Subtlety (1) above.

Definition at line 279 of file cpumask.h.

#define cpus_addr (   src)    ((src).bits)

Definition at line 842 of file cpumask.h.

#define cpus_and (   dst,
  src1,
  src2 
)    __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)

Definition at line 877 of file cpumask.h.

#define cpus_andnot (   dst,
  src1,
  src2 
)    __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)

Definition at line 898 of file cpumask.h.

#define cpus_clear (   dst)    __cpus_clear(&(dst), NR_CPUS)

Definition at line 862 of file cpumask.h.

#define cpus_empty (   src)    __cpus_empty(&(src), NR_CPUS)

Definition at line 927 of file cpumask.h.

#define cpus_equal (   src1,
  src2 
)    __cpus_equal(&(src1), &(src2), NR_CPUS)

Definition at line 906 of file cpumask.h.

#define cpus_intersects (   src1,
  src2 
)    __cpus_intersects(&(src1), &(src2), NR_CPUS)

Definition at line 913 of file cpumask.h.

#define cpus_or (   dst,
  src1,
  src2 
)    __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)

Definition at line 884 of file cpumask.h.

#define cpus_setall (   dst)    __cpus_setall(&(dst), NR_CPUS)

Definition at line 856 of file cpumask.h.

#define cpus_shift_left (   dst,
  src,
  n 
)    __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)

Definition at line 939 of file cpumask.h.

#define cpus_subset (   src1,
  src2 
)    __cpus_subset(&(src1), &(src2), NR_CPUS)

Definition at line 920 of file cpumask.h.

#define cpus_weight (   cpumask)    __cpus_weight(&(cpumask), NR_CPUS)

Definition at line 933 of file cpumask.h.

#define cpus_xor (   dst,
  src1,
  src2 
)    __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)

Definition at line 891 of file cpumask.h.

#define first_cpu (   src)    __first_cpu(&(src))

Definition at line 819 of file cpumask.h.

#define for_each_cpu (   cpu,
  mask 
)
Value:
for ((cpu) = -1; \
(cpu) = cpumask_next((cpu), (mask)), \
(cpu) < nr_cpu_ids;)

for_each_cpu - iterate over every cpu in a mask : the (optionally unsigned) integer iterator : the cpumask pointer

After the loop, cpu is >= nr_cpu_ids.

Definition at line 203 of file cpumask.h.

#define for_each_cpu_and (   cpu,
  mask,
  and 
)
Value:
for ((cpu) = -1; \
(cpu) = cpumask_next_and((cpu), (mask), (and)), \
(cpu) < nr_cpu_ids;)

for_each_cpu_and - iterate over every cpu in both masks : the (optionally unsigned) integer iterator : the first cpumask pointer : the second cpumask pointer

This saves a temporary CPU mask in many places. It is equivalent to: struct cpumask tmp; cpumask_and(&tmp, &mask, &and); for_each_cpu(cpu, &tmp) ...

After the loop, cpu is >= nr_cpu_ids.

Definition at line 234 of file cpumask.h.

#define for_each_cpu_mask (   cpu,
  mask 
)
Value:
for ((cpu) = -1; \
(cpu) = next_cpu((cpu), (mask)), \
(cpu) < NR_CPUS; )

Definition at line 822 of file cpumask.h.

#define for_each_cpu_mask_nr (   cpu,
  mask 
)    for_each_cpu_mask(cpu, mask)

Definition at line 830 of file cpumask.h.

#define for_each_cpu_not (   cpu,
  mask 
)
Value:
for ((cpu) = -1; \
(cpu) = cpumask_next_zero((cpu), (mask)), \
(cpu) < nr_cpu_ids;)

for_each_cpu_not - iterate over every cpu in a complemented mask : the (optionally unsigned) integer iterator : the cpumask pointer

After the loop, cpu is >= nr_cpu_ids.

Definition at line 215 of file cpumask.h.

#define for_each_online_cpu (   cpu)    for_each_cpu((cpu), cpu_online_mask)

Definition at line 707 of file cpumask.h.

#define for_each_possible_cpu (   cpu)    for_each_cpu((cpu), cpu_possible_mask)

Definition at line 706 of file cpumask.h.

#define for_each_present_cpu (   cpu)    for_each_cpu((cpu), cpu_present_mask)

Definition at line 708 of file cpumask.h.

#define next_cpu (   n,
  src 
)    __next_cpu((n), &(src))

Definition at line 820 of file cpumask.h.

#define nr_cpumask_bits   NR_CPUS

Definition at line 36 of file cpumask.h.

#define num_active_cpus ( )    1U

Definition at line 97 of file cpumask.h.

#define num_online_cpus ( )    1U

Definition at line 94 of file cpumask.h.

#define num_possible_cpus ( )    1U

Definition at line 95 of file cpumask.h.

#define num_present_cpus ( )    1U

Definition at line 96 of file cpumask.h.

#define to_cpumask (   bitmap)
Value:
((struct cpumask *)(1 ? (bitmap) \
: (void *)sizeof(__check_is_bitmap(bitmap))))

to_cpumask - convert an NR_CPUS bitmap to a struct cpumask * : the bitmap

There are a few places where cpumask_var_t isn't appropriate and static cpumasks must be used (eg. very early boot), yet we don't expose the definition of 'struct cpumask'.

This does the conversion, and can be used as a constant initializer.

Definition at line 729 of file cpumask.h.

Typedef Documentation

typedef struct cpumask cpumask_var_t[1]

Definition at line 659 of file cpumask.h.

Function Documentation

int __first_cpu ( const cpumask_t srcp)

Definition at line 8 of file cpumask.c.

int __next_cpu ( int  n,
const cpumask_t srcp 
)

Definition at line 14 of file cpumask.c.

int cpumask_any_but ( const struct cpumask mask,
unsigned int  cpu 
)

cpumask_any_but - return a "random" in a cpumask, but not this one. : the cpumask to search : the cpu to ignore.

Often used to find any cpu but smp_processor_id() in a mask. Returns >= nr_cpu_ids if no cpus set.

Definition at line 55 of file cpumask.c.

int cpumask_next_and ( int  n,
const struct cpumask src1p,
const struct cpumask src2p 
)

cpumask_next_and - get the next cpu in *src1p & *src2p
: the cpu prior to the place to search (ie. return will be >
) : the first cpumask pointer : the second cpumask pointer

Returns >= nr_cpu_ids if no further cpus set in both.

Definition at line 37 of file cpumask.c.

const DECLARE_BITMAP ( cpu_all_bits  ,
NR_CPUS   
)
void init_cpu_online ( const struct cpumask src)

Definition at line 723 of file cpu.c.

void init_cpu_possible ( const struct cpumask src)

Definition at line 718 of file cpu.c.

void init_cpu_present ( const struct cpumask src)

Definition at line 713 of file cpu.c.

void set_cpu_active ( unsigned int  cpu,
bool  active 
)

Definition at line 705 of file cpu.c.

void set_cpu_online ( unsigned int  cpu,
bool  online 
)

Definition at line 697 of file cpu.c.

void set_cpu_possible ( unsigned int  cpu,
bool  possible 
)
void set_cpu_present ( unsigned int  cpu,
bool  present 
)

Definition at line 689 of file cpu.c.

Variable Documentation

struct cpumask* const cpu_active_mask
const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)]

Definition at line 646 of file cpu.c.

struct cpumask* const cpu_online_mask
struct cpumask* const cpu_possible_mask
struct cpumask* const cpu_present_mask
int nr_cpu_ids