lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181107141414.GF9761@hirez.programming.kicks-ass.net>
Date:   Wed, 7 Nov 2018 15:14:14 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Patrick Bellasi <patrick.bellasi@....com>
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 Wed, Nov 07, 2018 at 01:57:38PM +0000, Patrick Bellasi wrote:
> On 07-Nov 14:16, Peter Zijlstra wrote:

> > 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 ?

No; it is just the 'normal' form my brain likes :-)

And the try_cmpxchg() thing is slightly more efficient on x86 vs the
traditional form:

	while (cmpxchg(ptr, old, new) != old)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ