[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200414150556.10920-2-qais.yousef@arm.com>
Date: Tue, 14 Apr 2020 16:05:53 +0100
From: Qais Yousef <qais.yousef@....com>
To: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>
Cc: Qais Yousef <qais.yousef@....com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Yury Norov <yury.norov@...il.com>,
Paul Turner <pjt@...gle.com>,
Alexey Dobriyan <adobriyan@...il.com>,
Josh Don <joshdon@...gle.com>,
Pavan Kondeti <pkondeti@...eaurora.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/4] cpumask: Rename cpumask_any_and_distribute
The function is actually an alias of cpumask_any_and(), except that the
new function does the randomization and the old implementation didn't.
Rename the new function to cpumask_any_and() so that old users can take
advantage of its 'enhanced' randomness.
Signed-off-by: Qais Yousef <qais.yousef@....com>
CC: Juri Lelli <juri.lelli@...hat.com>
CC: Vincent Guittot <vincent.guittot@...aro.org>
CC: Dietmar Eggemann <dietmar.eggemann@....com>
CC: Steven Rostedt <rostedt@...dmis.org>
CC: Ben Segall <bsegall@...gle.com>
CC: Mel Gorman <mgorman@...e.de>
CC: Andrew Morton <akpm@...ux-foundation.org>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Yury Norov <yury.norov@...il.com>
CC: Paul Turner <pjt@...gle.com>
CC: Alexey Dobriyan <adobriyan@...il.com>
CC: Josh Don <joshdon@...gle.com>
CC: Pavan Kondeti <pkondeti@...eaurora.org>
CC: linux-kernel@...r.kernel.org
---
include/linux/cpumask.h | 17 ++++-------------
kernel/sched/core.c | 2 +-
lib/cpumask.c | 14 ++++++--------
3 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index f0d895d6ac39..e4d6d140a67c 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -194,8 +194,9 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
return 0;
}
-static inline int cpumask_any_and_distribute(const struct cpumask *src1p,
- const struct cpumask *src2p) {
+static inline int cpumask_any_and(const struct cpumask *src1p,
+ const struct cpumask *src2p)
+{
return cpumask_next_and(-1, src1p, src2p);
}
@@ -250,8 +251,7 @@ 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);
unsigned int cpumask_local_spread(unsigned int i, int node);
-int cpumask_any_and_distribute(const struct cpumask *src1p,
- const struct cpumask *src2p);
+int cpumask_any_and(const struct cpumask *src1p, const struct cpumask *src2p);
/**
* for_each_cpu - iterate over every cpu in a mask
@@ -617,15 +617,6 @@ static inline void cpumask_copy(struct cpumask *dstp,
*/
#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
-/**
- * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2
- * @mask1: the first input cpumask
- * @mask2: the second input cpumask
- *
- * Returns >= nr_cpu_ids if no cpus set.
- */
-#define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
-
/**
* cpumask_of - the cpumask containing just a given cpu
* @cpu: the cpu (<= nr_cpu_ids)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c1f923d647ee..7942ebc83e6e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1655,7 +1655,7 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
* for groups of tasks (ie. cpuset), so that load balancing is not
* immediately required to distribute the tasks within their new mask.
*/
- dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask);
+ dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
if (dest_cpu >= nr_cpu_ids) {
ret = -EINVAL;
goto out;
diff --git a/lib/cpumask.c b/lib/cpumask.c
index fb22fb266f93..b527a153b023 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -236,15 +236,13 @@ EXPORT_SYMBOL(cpumask_local_spread);
static DEFINE_PER_CPU(int, distribute_cpu_mask_prev);
/**
- * Returns an arbitrary cpu within srcp1 & srcp2.
+ * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2
+ * @mask1: the first input cpumask
+ * @mask2: the second input cpumask
*
- * Iterated calls using the same srcp1 and srcp2 will be distributed within
- * their intersection.
- *
- * Returns >= nr_cpu_ids if the intersection is empty.
+ * Returns >= nr_cpu_ids if no cpus set.
*/
-int cpumask_any_and_distribute(const struct cpumask *src1p,
- const struct cpumask *src2p)
+int cpumask_any_and(const struct cpumask *src1p, const struct cpumask *src2p)
{
int next, prev;
@@ -260,4 +258,4 @@ int cpumask_any_and_distribute(const struct cpumask *src1p,
return next;
}
-EXPORT_SYMBOL(cpumask_any_and_distribute);
+EXPORT_SYMBOL(cpumask_any_and);
--
2.17.1
Powered by blists - more mailing lists