mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qais Yousef <qais.yousef@arm.com>
To: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>
Cc: Qais Yousef <qais.yousef@arm.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Yury Norov <yury.norov@gmail.com>, Paul Turner <pjt@google.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Josh Don <joshdon@google.com>,
	Pavan Kondeti <pkondeti@codeaurora.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] cpumask: Rename cpumask_any_and_distribute
Date: Tue, 14 Apr 2020 16:05:53 +0100	[thread overview]
Message-ID: <20200414150556.10920-2-qais.yousef@arm.com> (raw)
In-Reply-To: <20200414150556.10920-1-qais.yousef@arm.com>

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@arm.com>
CC: Juri Lelli <juri.lelli@redhat.com>
CC: Vincent Guittot <vincent.guittot@linaro.org>
CC: Dietmar Eggemann <dietmar.eggemann@arm.com>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ben Segall <bsegall@google.com>
CC: Mel Gorman <mgorman@suse.de>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Yury Norov <yury.norov@gmail.com>
CC: Paul Turner <pjt@google.com>
CC: Alexey Dobriyan <adobriyan@gmail.com>
CC: Josh Don <joshdon@google.com>
CC: Pavan Kondeti <pkondeti@codeaurora.org>
CC: linux-kernel@vger.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


  reply	other threads:[~2020-04-14 15:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 15:05 [PATCH 0/4] sched/rt: Distribute tasks in find_lowest_rq() Qais Yousef
2020-04-14 15:05 ` Qais Yousef [this message]
2020-04-14 15:05 ` [PATCH 2/4] cpumask: Make cpumask_any() truly random Qais Yousef
2020-04-14 16:19   ` Steven Rostedt
2020-04-15  9:36     ` Peter Zijlstra
2020-04-20 15:43       ` Qais Yousef
2020-04-20 21:36         ` Josh Don
2020-05-28  8:52   ` [cpumask] a7934287d8: BUG:using__this_cpu_read()in_preemptible[#]code:kworker kernel test robot
2020-04-14 15:05 ` [PATCH 3/4] cpumask: Convert cpumask_any_but() to the new random function Qais Yousef
2020-04-14 16:28   ` Steven Rostedt
2020-04-20 15:49     ` Qais Yousef
2020-04-14 15:05 ` [PATCH 4/4] sched/rt: Better distribute tasks that wakeup simultaneously Qais Yousef
2020-04-14 18:58 ` [PATCH 0/4] sched/rt: Distribute tasks in find_lowest_rq() Valentin Schneider
2020-04-14 20:27   ` Steven Rostedt
2020-04-14 20:56     ` Valentin Schneider
2020-04-15  9:39     ` Peter Zijlstra
2020-04-15 13:18       ` Steven Rostedt
2020-04-21 12:15       ` Qais Yousef
2020-04-21 12:13   ` Qais Yousef
2020-04-21 13:18     ` Valentin Schneider
2020-04-21 13:28       ` Vincent Guittot
2020-04-21 14:22         ` Yury Norov
2020-04-21 14:25         ` Qais Yousef
2020-04-21 14:09       ` Marc Zyngier
2020-04-21 14:22         ` Qais Yousef
2020-04-21 14:28           ` Marc Zyngier
2020-04-21 14:39             ` Qais Yousef

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200414150556.10920-2-qais.yousef@arm.com \
    --to=qais.yousef@arm.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=pkondeti@codeaurora.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®