Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3168587imu; Wed, 7 Nov 2018 06:15:12 -0800 (PST) X-Google-Smtp-Source: AJdET5ffg8h55zrT2sKTHgtfVGdUzjipJCF5ClZfm/ruBBjP9gyKjknvEW9/m6J8aFqdQmTsnRNL X-Received: by 2002:a17:902:6113:: with SMTP id t19-v6mr408895plj.84.1541600112417; Wed, 07 Nov 2018 06:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541600112; cv=none; d=google.com; s=arc-20160816; b=NP6wlsG91FpNebZrMnSO8JuKVI0PQs88bklF5wfcoZnXNH++i0s0As8o7pRDMTOXf7 eneBJi2lbWcA8sUYolXp/Mp7ngVwatUlZFglrxbtcMWbthKxZnbUztAE6/7Xr4fxOjMj qDY8f/b0Qexk64vE+1Y/tfcPiV6ckQE5QQfTNroqPAiMrLn8TDw6lVtXlr8op/b2q27e 7KGUeCLOoxgMBK0eE1ZlgQ4uiOgt4+N3dla1vI3Wl4jxWCAGhxtRDfIegdz2H26dsoUh zMzu8+39XeiNmz3asAX1F7s70gNGtuHfzkINxzqKQOjD5/bX8SGRiUcXGT0OIFwXrYR6 P6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SBcT9EGd6MxKrVHTreVJ4OinKK8AXjwR0pe7meQhuE8=; b=MfGux8XV6N2JHL01xf6wjyQ8PqU+5rimFQJaWEGlRIlmtuJwtZqg+NINy4omAEQA2S twBW0lL1XP4xiyc8fO7EiGigAMbYnuXZR2KdWBfhPY7vgLxk4rGL/8Bg/foxajFub40o PWL/ag2Uk+jhXbiCnmLgZZ/FicZKkRahOCR8Ds97n0Ez6Vum6OxnvWMmpa/M67xGgfEY Wvo0gsNqbQJ7z1n0ReuSHckvHEqs3rfjw8OP31bG9B93wQTjbMccKNng1U1AiKUI0wYV e6AAa8A4pKxcSUypPKYYvchf7UR2MBgo4qo4twEAbehDaR5cAjB4P/9IqjwWFfWPq+Vt rHYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WxgBZtDg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si666607pgc.343.2018.11.07.06.14.56; Wed, 07 Nov 2018 06:15:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WxgBZtDg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbeKGXo7 (ORCPT + 99 others); Wed, 7 Nov 2018 18:44:59 -0500 Received: from merlin.infradead.org ([205.233.59.134]:32934 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbeKGXo7 (ORCPT ); Wed, 7 Nov 2018 18:44:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SBcT9EGd6MxKrVHTreVJ4OinKK8AXjwR0pe7meQhuE8=; b=WxgBZtDgtqmmZYWiF2h+YmOpV bbzpQvZo5ky7JOz7keqgAeiKFrOlvp0HYHgwtLbrMCi/qCZTAslTudJOVTJ5diTRHUSGhtA9FOEci Od5wwjpfKzj478DSGVVzmqlCCCztqhJwPNmvVv9Ygg6ziZKxZVECDSqcny3baYgFgLip0HEEIoOYv KqMgXE2MZVqXLYU8ku1h8rj7+a8ia6ZgyvVRmdOWugLjljWvJwtAuNt+VCD/JPlCxP6TWETzOlaGW 3S+6dbvYK2aHw2Rmf/joxvxzW5kb42PFcW5+YHQTu7O5ZoCWdJm5GrgVlJ7x/15OwR3olhseiapLw E7AfADedQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKOb2-0006F5-PR; Wed, 07 Nov 2018 14:14:17 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7A4C020284F98; Wed, 7 Nov 2018 15:14:14 +0100 (CET) Date: Wed, 7 Nov 2018 15:14:14 +0100 From: Peter Zijlstra To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v5 03/15] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups Message-ID: <20181107141414.GF9761@hirez.programming.kicks-ass.net> References: <20181029183311.29175-1-patrick.bellasi@arm.com> <20181029183311.29175-4-patrick.bellasi@arm.com> <20181107131632.GP9781@hirez.programming.kicks-ass.net> <20181107135738.GE14309@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181107135738.GE14309@e110439-lin> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)