[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181107135738.GE14309@e110439-lin>
Date: Wed, 7 Nov 2018 13:57:38 +0000
From: Patrick Bellasi <patrick.bellasi@....com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
Ingo Molnar <mingo@...hat.com>, Tejun Heo <tj@...nel.org>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Paul Turner <pjt@...gle.com>,
Quentin Perret <quentin.perret@....com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Morten Rasmussen <morten.rasmussen@....com>,
Juri Lelli <juri.lelli@...hat.com>,
Todd Kjos <tkjos@...gle.com>,
Joel Fernandes <joelaf@...gle.com>,
Steve Muckle <smuckle@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>
Subject: Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values
into CPU's clamp groups
On 07-Nov 14:16, Peter Zijlstra wrote:
> On Mon, Oct 29, 2018 at 06:32:57PM +0000, Patrick Bellasi wrote:
>
> > +static void uclamp_group_put(unsigned int clamp_id, unsigned int group_id)
> > {
> > + union uclamp_map *uc_maps = &uclamp_maps[clamp_id][0];
> > + union uclamp_map uc_map_old, uc_map_new;
> > + long res;
> > +
> > +retry:
> > +
> > + uc_map_old.data = atomic_long_read(&uc_maps[group_id].adata);
> > + uc_map_new = uc_map_old;
> > + uc_map_new.se_count -= 1;
> > + res = atomic_long_cmpxchg(&uc_maps[group_id].adata,
> > + uc_map_old.data, uc_map_new.data);
> > + if (res != uc_map_old.data)
> > + goto retry;
> > +}
>
> Please write cmpxchg loops in the form:
>
> atomic_long_t *ptr = &uclamp_maps[clamp_id][group_id].adata;
> union uclamp_map old, new;
>
> old.data = atomic_long_read(ptr);
> do {
> new.data = old.data;
> new.se_cound--;
> } while (!atomic_long_try_cmpxchg(ptr, &old.data, new.data));
>
>
> (same for all the others of course)
Ok, I did that to save some indentation, but actually it's most
commonly used in a while loop... will update in v6.
Out of curiosity, apart from code consistency, is that required also
specifically for any possible compiler related (mis)behavior ?
--
#include <best/regards.h>
Patrick Bellasi
Powered by blists - more mailing lists