Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118621
b: refs/heads/master
c: 984f2f3
h: refs/heads/master
i:
  118619: b1354cf
v: v3
  • Loading branch information
Rusty Russell authored and Ingo Molnar committed Nov 9, 2008
1 parent eb5bcb4 commit 503a8ac
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cd83e42c6b0413dcbb548c2ead799111ff7e6a13
refs/heads/master: 984f2f377fdfd098f5ae58d09ee04d5e29e6112b
58 changes: 52 additions & 6 deletions trunk/include/linux/cpumask.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,36 @@ static inline unsigned int cpumask_check(unsigned int cpu)
}

#if NR_CPUS == 1
/* Uniprocesor. */
#define cpumask_first(src) ({ (void)(src); 0; })
#define cpumask_next(n, src) ({ (void)(src); 1; })
#define cpumask_next_zero(n, src) ({ (void)(src); 1; })
#define cpumask_next_and(n, srcp, andp) ({ (void)(srcp), (void)(andp); 1; })
#define cpumask_any_but(mask, cpu) ({ (void)(mask); (void)(cpu); 0; })
/* Uniprocessor. Assume all masks are "1". */
static inline unsigned int cpumask_first(const struct cpumask *srcp)
{
return 0;
}

/* Valid inputs for n are -1 and 0. */
static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
{
return n+1;
}

static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
{
return n+1;
}

static inline unsigned int cpumask_next_and(int n,
const struct cpumask *srcp,
const struct cpumask *andp)
{
return n+1;
}

/* cpu must be a valid cpu, ie 0, so there's no other choice. */
static inline unsigned int cpumask_any_but(const struct cpumask *mask,
unsigned int cpu)
{
return 1;
}

#define for_each_cpu(cpu, mask) \
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
Expand Down Expand Up @@ -620,10 +644,32 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);

/**
* for_each_cpu - iterate over every cpu in a mask
* @cpu: the (optionally unsigned) integer iterator
* @mask: the cpumask pointer
*
* After the loop, cpu is >= nr_cpu_ids.
*/
#define for_each_cpu(cpu, mask) \
for ((cpu) = -1; \
(cpu) = cpumask_next((cpu), (mask)), \
(cpu) < nr_cpu_ids;)

/**
* for_each_cpu_and - iterate over every cpu in both masks
* @cpu: the (optionally unsigned) integer iterator
* @mask: the first cpumask pointer
* @and: 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.
*/
#define for_each_cpu_and(cpu, mask, and) \
for ((cpu) = -1; \
(cpu) = cpumask_next_and((cpu), (mask), (and)), \
Expand Down
3 changes: 2 additions & 1 deletion trunk/lib/cpumask.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
{
unsigned int i;

cpumask_check(cpu);
for_each_cpu(i, mask)
if (i != cpu)
break;
Expand Down Expand Up @@ -108,7 +109,7 @@ void free_cpumask_var(cpumask_var_t mask)
}
EXPORT_SYMBOL(free_cpumask_var);

void free_bootmem_cpumask_var(cpumask_var_t mask)
void __init free_bootmem_cpumask_var(cpumask_var_t mask)
{
free_bootmem((unsigned long)mask, cpumask_size());
}
Expand Down

0 comments on commit 503a8ac

Please sign in to comment.