From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0FFC11D04 for ; Thu, 20 Feb 2020 10:39:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1631E2467A for ; Thu, 20 Feb 2020 10:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582195181; bh=pmMeD3J462Ed0GYqNb2rQ5J4xvML9edU/W6pE3Ujv+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=sco71/6trnKNjFdHpjy5kX2wMWjkOuWtCV62ha17sKVq5t+NVdbA2b3mPrxIkGU3J DS4vcQzlx6jDCx4svx273OIA20ird1vJLPsXcnvIrEQebhaRi/UAAD2CPXWz6ETBrQ pRo9HRlsP2mDwGhExOjPAfVCbxjHvS9PY7aKOZHE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbgBTKjk (ORCPT ); Thu, 20 Feb 2020 05:39:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:41396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbgBTKjk (ORCPT ); Thu, 20 Feb 2020 05:39:40 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A6A024654; Thu, 20 Feb 2020 10:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582195179; bh=pmMeD3J462Ed0GYqNb2rQ5J4xvML9edU/W6pE3Ujv+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r2TguAywdipbP4Jz7R2+hYm5KCmvFxe6y2myDGF6Ly85bnkYnJ2RBOu/JShHg40H6 Y7+nGQtLziSEWGYsNsfwRKeIGf7MBpN1PbeOiZH5NOIQWRZbe3dcABDtO38TyWpri4 jun2dHMx/RapBMJqjfnwRk7B14rA3jg0AoEn5cco= Date: Thu, 20 Feb 2020 10:39:35 +0000 From: Will Deacon To: Peter Zijlstra Cc: Jens Axboe , Carter Li =?utf-8?B?5p2O6YCa5rSy?= , Pavel Begunkov , io-uring , Oleg Nesterov , Mark Rutland , linux-kernel@vger.kernel.org Subject: Re: [PATCH] asm-generic/atomic: Add try_cmpxchg() fallbacks Message-ID: <20200220103934.GA14459@willie-the-truck> References: <20200217120920.GQ14914@hirez.programming.kicks-ass.net> <53de3581-b902-89ba-3f53-fd46b052df40@kernel.dk> <43c066d1-a892-6a02-82e7-7be850d9454d@kernel.dk> <20200217174610.GU14897@hirez.programming.kicks-ass.net> <592cf069-41ee-0bc1-1f83-e058e5dd53ff@kernel.dk> <20200218131310.GZ14914@hirez.programming.kicks-ass.net> <20200218142700.GB14946@hirez.programming.kicks-ass.net> <20200220103044.GA13608@willie-the-truck> <20200220103727.GW18400@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200220103727.GW18400@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On Thu, Feb 20, 2020 at 11:37:27AM +0100, Peter Zijlstra wrote: > On Thu, Feb 20, 2020 at 10:30:45AM +0000, Will Deacon wrote: > > On Tue, Feb 18, 2020 at 03:27:00PM +0100, Peter Zijlstra wrote: > > > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh > > > index b6c6f5d306a7..3c9be8d550e0 100755 > > > --- a/scripts/atomic/gen-atomic-fallback.sh > > > +++ b/scripts/atomic/gen-atomic-fallback.sh > > > @@ -140,6 +140,32 @@ cat < > > EOF > > > } > > > > > > +gen_try_cmpxchg_fallback() > > > +{ > > > + local order="$1"; shift; > > > + > > > +cat < > > +#ifndef try_cmpxchg${order} > > > +#define try_cmpxchg${order}(_ptr, _oldp, _new) \\ > > > +({ \\ > > > + typeof(*ptr) ___r, ___o = *(_oldp); \\ > > > + ___r = cmpxchg${order}((_ptr), ___o, (_new)); \\ > > > + if (unlikely(___r != ___o)) \\ > > > + *(_old) = ___r; \\ > > > > This doesn't compile because _old isn't declared. Probably best to avoid > > evaluating _oldp twice though. > > Compiler had already spotted that, I'll make it something like: > > typeof(*ptr) *___op = (_oldp), ___o = *___op; > > ... > > *___op = ___r; > > Which avoids the double eval. Cool, you can stick my Ack on the patch with that change. Will