From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Qais Yousef <qais.yousef@arm.com>, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
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: Re: [PATCH 2/4] cpumask: Make cpumask_any() truly random
Date: Wed, 15 Apr 2020 11:36:17 +0200 [thread overview]
Message-ID: <20200415093617.GZ20730@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200414121956.3687d6e9@gandalf.local.home>
On Tue, Apr 14, 2020 at 12:19:56PM -0400, Steven Rostedt wrote:
> > +/**
> > + * cpumask_any - pick a "random" cpu from *srcp
> > + * @srcp: the input cpumask
> > + *
> > + * Returns >= nr_cpu_ids if no cpus set.
> > + */
> > +int cpumask_any(const struct cpumask *srcp)
> > +{
> > + int next, prev;
> > +
> > + /* NOTE: our first selection will skip 0. */
> > + prev = __this_cpu_read(distribute_cpu_mask_prev);
> > +
> > + next = cpumask_next(prev, srcp);
> > + if (next >= nr_cpu_ids)
> > + next = cpumask_first(srcp);
> > +
> > + if (next < nr_cpu_ids)
> > + __this_cpu_write(distribute_cpu_mask_prev, next);
>
> Do we care if this gets preempted and migrated to a new CPU where we read
> "prev" from one distribute_cpu_mask_prev on one CPU and write it to another
> CPU?
I don't think we do; that just adds to the randomness ;-), but you do
raise a good point in that __this_cpu_*() ops assume preemption is
already disabled, which is true of the one exiting
cpumask_any_and_distribute() caller, but is no longer true after patch
1, and this patch repeats the mistake.
So either we need to disable preemption across the function or
transition to this_cpu_*() ops.
next prev parent reply other threads:[~2020-04-15 9:36 UTC|newest]
Thread overview: 28+ 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 ` [PATCH 1/4] cpumask: Rename cpumask_any_and_distribute Qais Yousef
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 [this message]
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-05-28 8:52 ` 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=20200415093617.GZ20730@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--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=pjt@google.com \
--cc=pkondeti@codeaurora.org \
--cc=qais.yousef@arm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.