Skip to content

Commit a4ee891

Browse files
committed
Merge tag 'bitmap-6.0-rc2' of https://github.com/norov/linux
Pull bitmap updates from Yury Norov: "cpumask: UP optimisation fixes follow-up As an older version of the UP optimisation fixes was merged, not all review feedback has been implemented. This implements the feedback received on the merged version [1], and the respin [2], for changes related to <linux/cpumask.h> and lib/cpumask.c" Link: https://lore.kernel.org/lkml/[email protected]/ [1] Link: https://lore.kernel.org/lkml/[email protected]/ [2] It spent for more than a week with no issues. * tag 'bitmap-6.0-rc2' of https://github.com/norov/linux: lib/cpumask: drop always-true preprocessor guard lib/cpumask: add inline cpumask_next_wrap() for UP cpumask: align signatures of UP implementations
2 parents 88e0a74 + 61b123f commit a4ee891

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

include/linux/cpumask.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,13 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
202202
return 0;
203203
}
204204

205-
static inline int cpumask_any_and_distribute(const struct cpumask *src1p,
206-
const struct cpumask *src2p) {
205+
static inline unsigned int cpumask_any_and_distribute(const struct cpumask *src1p,
206+
const struct cpumask *src2p)
207+
{
207208
return cpumask_first_and(src1p, src2p);
208209
}
209210

210-
static inline int cpumask_any_distribute(const struct cpumask *srcp)
211+
static inline unsigned int cpumask_any_distribute(const struct cpumask *srcp)
211212
{
212213
return cpumask_first(srcp);
213214
}
@@ -261,7 +262,26 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
261262
(cpu) = cpumask_next_zero((cpu), (mask)), \
262263
(cpu) < nr_cpu_ids;)
263264

265+
#if NR_CPUS == 1
266+
static inline
267+
unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
268+
{
269+
cpumask_check(start);
270+
if (n != -1)
271+
cpumask_check(n);
272+
273+
/*
274+
* Return the first available CPU when wrapping, or when starting before cpu0,
275+
* since there is only one valid option.
276+
*/
277+
if (wrap && n >= 0)
278+
return nr_cpumask_bits;
279+
280+
return cpumask_first(mask);
281+
}
282+
#else
264283
unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap);
284+
#endif
265285

266286
/**
267287
* for_each_cpu_wrap - iterate over every cpu in a mask, starting at a specified location

lib/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
3434
is_single_threaded.o plist.o decompress.o kobject_uevent.o \
3535
earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
3636
nmi_backtrace.o win_minmax.o memcat_p.o \
37-
buildid.o cpumask.o
37+
buildid.o
3838

3939
lib-$(CONFIG_PRINTK) += dump_stack.o
40+
lib-$(CONFIG_SMP) += cpumask.o
4041

4142
lib-y += kobject.o klist.o
4243
obj-y += lockref.o

lib/cpumask.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
109109
}
110110
#endif
111111

112-
#if NR_CPUS > 1
113112
/**
114113
* cpumask_local_spread - select the i'th cpu with local numa cpu's first
115114
* @i: index number
@@ -197,4 +196,3 @@ unsigned int cpumask_any_distribute(const struct cpumask *srcp)
197196
return next;
198197
}
199198
EXPORT_SYMBOL(cpumask_any_distribute);
200-
#endif /* NR_CPUS */

0 commit comments

Comments
 (0)