From: Patrick Bellasi <patrick.bellasi@arm.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Joel Fernandes <joelaf@google.com>,
"Joel Fernandes (Google)" <joel.opensrc@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-pm@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [RFC v3 1/5] sched/core: add capacity constraints to CPU controller
Date: Wed, 15 Mar 2017 16:44:39 +0000 [thread overview]
Message-ID: <20170315164439.GG18557@e110439-lin> (raw)
In-Reply-To: <20170315161048.GJ3637@linux.vnet.ibm.com>
On 15-Mar 09:10, Paul E. McKenney wrote:
> On Wed, Mar 15, 2017 at 06:20:28AM -0700, Joel Fernandes wrote:
> > On Wed, Mar 15, 2017 at 4:20 AM, Patrick Bellasi
> > <patrick.bellasi@arm.com> wrote:
> > > On 13-Mar 03:46, Joel Fernandes (Google) wrote:
> > >> On Tue, Feb 28, 2017 at 6:38 AM, Patrick Bellasi
> > >> <patrick.bellasi@arm.com> wrote:
> > >> > The CPU CGroup controller allows to assign a specified (maximum)
> > >> > bandwidth to tasks within a group, however it does not enforce any
> > >> > constraint on how such bandwidth can be consumed.
> > >> > With the integration of schedutil, the scheduler has now the proper
> > >> > information about a task to select the most suitable frequency to
> > >> > satisfy tasks needs.
> > >> [..]
> > >>
> > >> > +static u64 cpu_capacity_min_read_u64(struct cgroup_subsys_state *css,
> > >> > + struct cftype *cft)
> > >> > +{
> > >> > + struct task_group *tg;
> > >> > + u64 min_capacity;
> > >> > +
> > >> > + rcu_read_lock();
> > >> > + tg = css_tg(css);
> > >> > + min_capacity = tg->cap_clamp[CAP_CLAMP_MIN];
> > >>
> > >> Shouldn't the cap_clamp be accessed with READ_ONCE (and WRITE_ONCE in
> > >> the write path) to avoid load-tearing?
> > >
> > > tg->cap_clamp is an "unsigned int" and thus I would expect a single
> > > memory access to write/read it, isn't it? I mean: I do not expect the
> > > compiler "to mess" with these accesses.
> >
> > This depends on compiler and arch. I'm not sure if its in practice
> > these days an issue, but see section on 'load tearing' in
> > Documentation/memory-barriers.txt . If compiler decided to break down
> > the access to multiple accesses due to some reason, then might be a
> > problem.
>
> The compiler might also be able to inline cpu_capacity_min_read_u64()
> fuse the load from tg->cap_clamp[CAP_CLAMP_MIN] with other accesses.
> If min_capacity is used several times in the ensuing code, the compiler
> could reload multiple times from tg->cap_clamp[CAP_CLAMP_MIN], which at
> best might be a bit confusing.
That's actually an interesting case, however I don't think it applies
in this case since cpu_capacity_min_read_u64() is called only via
a function poninter and thus it will never be inlined. isn't it?
> > Adding Paul for his expert opinion on the matter ;)
>
> My personal approach is to use READ_ONCE() and WRITE_ONCE() unless
> I can absolutely prove that the compiler cannot do any destructive
> optimizations. And I not-infrequently find unsuspected opportunities
> for destructive optimization in my own code. Your mileage may vary. ;-)
I guess here the main concern from Joel is that such a pattern:
u64 var = unsigned_int_value_from_memory;
can result is a couple of "load from memory" operations.
In that case a similar:
unsigned_int_left_value = new_unsigned_int_value;
executed on a different thread can overlap with the previous memory
read operations and ending up in "var" containing a not consistent
value.
Question is: can this really happen, given the data types in use?
> Thanx, Paul
Thanks! ;-)
--
#include <best/regards.h>
Patrick Bellasi
next prev parent reply other threads:[~2017-03-15 16:45 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 14:38 [RFC v3 0/5] Add capacity capping support to the CPU controller Patrick Bellasi
2017-02-28 14:38 ` [RFC v3 1/5] sched/core: add capacity constraints to " Patrick Bellasi
2017-03-13 10:46 ` Joel Fernandes (Google)
2017-03-15 11:20 ` Patrick Bellasi
2017-03-15 13:20 ` Joel Fernandes
2017-03-15 16:10 ` Paul E. McKenney
2017-03-15 16:44 ` Patrick Bellasi [this message]
2017-03-15 17:24 ` Paul E. McKenney
2017-03-15 17:57 ` Patrick Bellasi
2017-03-20 17:15 ` Tejun Heo
2017-03-20 17:36 ` Tejun Heo
2017-03-20 18:08 ` Patrick Bellasi
2017-03-23 0:28 ` Joel Fernandes (Google)
2017-03-23 10:32 ` Patrick Bellasi
2017-03-23 16:01 ` Tejun Heo
2017-03-23 18:15 ` Patrick Bellasi
2017-03-23 18:39 ` Tejun Heo
2017-03-24 6:37 ` Joel Fernandes (Google)
2017-03-24 15:00 ` Tejun Heo
2017-03-30 21:13 ` Paul Turner
2017-03-24 7:02 ` Joel Fernandes (Google)
2017-03-30 21:15 ` Paul Turner
2017-04-01 16:25 ` Patrick Bellasi
2017-02-28 14:38 ` [RFC v3 2/5] sched/core: track CPU's capacity_{min,max} Patrick Bellasi
2017-02-28 14:38 ` [RFC v3 3/5] sched/core: sync capacity_{min,max} between slow and fast paths Patrick Bellasi
2017-02-28 14:38 ` [RFC v3 4/5] sched/{core,cpufreq_schedutil}: add capacity clamping for FAIR tasks Patrick Bellasi
2017-02-28 14:38 ` [RFC v3 5/5] sched/{core,cpufreq_schedutil}: add capacity clamping for RT/DL tasks Patrick Bellasi
2017-03-13 10:08 ` Joel Fernandes (Google)
2017-03-15 11:40 ` Patrick Bellasi
2017-03-15 12:59 ` Joel Fernandes
2017-03-15 14:44 ` Juri Lelli
2017-03-15 16:13 ` Joel Fernandes
2017-03-15 16:24 ` Juri Lelli
2017-03-15 23:40 ` Joel Fernandes
2017-03-16 11:16 ` Juri Lelli
2017-03-16 12:27 ` Patrick Bellasi
2017-03-16 12:44 ` Juri Lelli
2017-03-16 16:58 ` Joel Fernandes
2017-03-16 17:17 ` Juri Lelli
2017-03-15 11:41 ` [RFC v3 0/5] Add capacity capping support to the CPU controller Rafael J. Wysocki
2017-03-15 12:59 ` Patrick Bellasi
2017-03-16 1:04 ` Rafael J. Wysocki
2017-03-16 3:15 ` Joel Fernandes
2017-03-20 22:51 ` Rafael J. Wysocki
2017-03-21 11:01 ` Patrick Bellasi
2017-03-24 23:52 ` Rafael J. Wysocki
2017-03-16 12:23 ` Patrick Bellasi
2017-03-20 14:51 ` Tejun Heo
2017-03-20 17:22 ` Patrick Bellasi
2017-04-10 7:36 ` Peter Zijlstra
2017-04-11 17:58 ` Patrick Bellasi
2017-04-12 12:10 ` Peter Zijlstra
2017-04-12 13:55 ` Patrick Bellasi
2017-04-12 15:37 ` Peter Zijlstra
2017-04-13 11:33 ` Patrick Bellasi
2017-04-12 12:15 ` Peter Zijlstra
2017-04-12 13:34 ` Patrick Bellasi
2017-04-12 14:41 ` Peter Zijlstra
2017-04-12 12:22 ` Peter Zijlstra
2017-04-12 13:24 ` Patrick Bellasi
2017-04-12 12:48 ` Peter Zijlstra
2017-04-12 13:27 ` Patrick Bellasi
2017-04-12 14:34 ` Peter Zijlstra
2017-04-12 14:43 ` Patrick Bellasi
2017-04-12 16:14 ` Peter Zijlstra
2017-04-13 10:34 ` Patrick Bellasi
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=20170315164439.GG18557@e110439-lin \
--to=patrick.bellasi@arm.com \
--cc=joel.opensrc@gmail.com \
--cc=joelaf@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
/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