From df3436b9664acb98008fb1637bae4e4e2aff00b0 Mon Sep 17 00:00:00 2001 From: "Chang S. Bae" Date: Fri, 25 Feb 2022 02:46:20 -0800 Subject: [PATCH] Add the cpus_copy() helper This helper is useful when updating a global mask with a local value. The upcoming thermal-event handler Handling thermal events has the case. Signed-off-by: Chang S. Bae --- cpumask.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpumask.h b/cpumask.h index 5bebbeb..2ec3f79 100644 --- a/cpumask.h +++ b/cpumask.h @@ -40,6 +40,7 @@ * * void cpus_shift_right(dst, src, n) Shift right * void cpus_shift_left(dst, src, n) Shift left + * void cpus_copy(dst, src) Copy from src to dst * * int first_cpu(mask) Number lowest set bit, or NR_CPUS * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS @@ -197,6 +198,14 @@ static inline void __cpus_shift_left(cpumask_t *dstp, bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); } +#define cpus_copy(dst, src) \ + __cpus_copy(&(dst), &(src), NR_CPUS) +static inline void __cpus_copy(cpumask_t *dstp, + const cpumask_t *srcp, int nbits) +{ + bitmap_copy(dstp->bits, srcp->bits, nbits); +} + static inline int __first_cpu(const cpumask_t *srcp) { return ffs(*srcp->bits)-1;