Received: by 10.192.165.148 with SMTP id m20csp974279imm; Sat, 5 May 2018 02:04:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpa6yxCxHBgVv5VrhVwu6Uq6FmxopRwTL8OoX6lDjdCOd81CoRBhVKLrGMkfuLyfXDHBmNc X-Received: by 2002:a63:7f50:: with SMTP id p16-v6mr24468586pgn.79.1525511072238; Sat, 05 May 2018 02:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525511072; cv=none; d=google.com; s=arc-20160816; b=YkYJ6Y5+g0Z/ay70q1Hag8vK61l8EXPD9wQOsawWpTLbb33OXMdQHbmj70Yb7c52LF Zm+hAb2Mjdzl3PMHSuakjf1lwIi35HBf9s9eMIxAUBKpNla3DLamKKvPTnwcJ5tCEEt2 8DlHWVsi6E4raASMTEtH81fFaayn6BshaFNPt6oKtxd2fZT7c6hK9vFVkAUNMfUHvxy2 gsLXnCO/e58TtmwZlDp0qN/KPlCh8mFOzyEnLLZfjg2Jrwc7p+63VdS7JQ/uV5svmSBI 0KVcSsYHloXahPDU+RWcTV84omRpa5riXx4URJxLC5rlQ4UApK7KmoHwk+fPudL9gz4s ShkQ== 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:arc-authentication-results; bh=/KQe3CtQvfei2byClLL1mKADyI18OhCnvDCNmNgRL8k=; b=MPXYGQDjo9trRu0//8jupalRNma1B1j89vbXokUcaghf88cNP8ODhNWsrLXJER/I+0 WKyy6Slqb8qmaKU3OKwfCQTSs6nd0LY4B0n3z1QL6W4mTnxLu8YfFd5RGJ/LgeNwpcMQ GLcktNQaSQMa6rSYYtyliTpib6TpXVSJVhOgpqDeQqAdSrsbQdxFUdduBvYrn26KWK4r +gz20sRozj0yaCC9rnVRsmg4SRDhAJPUk+Mo9JbLQXaQoErPBFRzLSLjbZlPEpSQSBxH aHdTT6ZGjMNxe586w5SNLQc0naMl0yRXv3cqLTZbSrAVMkMQMiSB5kGs34cPxCdRsCjG R5XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Nu+2+629; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si18480567pfy.293.2018.05.05.02.04.18; Sat, 05 May 2018 02:04:32 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=Nu+2+629; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbeEEJEI (ORCPT + 99 others); Sat, 5 May 2018 05:04:08 -0400 Received: from mail-wr0-f173.google.com ([209.85.128.173]:41599 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbeEEJEH (ORCPT ); Sat, 5 May 2018 05:04:07 -0400 Received: by mail-wr0-f173.google.com with SMTP id g21-v6so23223828wrb.8 for ; Sat, 05 May 2018 02:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/KQe3CtQvfei2byClLL1mKADyI18OhCnvDCNmNgRL8k=; b=Nu+2+629wCZMsy4WYCTLm9FKnEpnQcvV0TljQMtg9Ept7xxP5lxVvgfb8EBtCDToPW zaib4pM57HxuKLgPsiVYeByMHB0uL+e+58qNOXJfwkMndGIlC4q3tTva1zBRMf5asHty 568WqC3rIQm+g0BsU8JZDx4BmNcMCADO06n2rZloAThhBRVErj3clJczigRuV+enl/xq 72zfcmAYbMCaGaPJ4isgF+3vpjDlI3d1rYRW9g4dconS+j8vKkQziLOm7A8mlZd8G+p8 xhSaWyrBcIe1J2ZebsZbY98ljWEDExkERZzS71Jq//wdfRrkT4C7qOZe161/19xOGeZx 4aJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=/KQe3CtQvfei2byClLL1mKADyI18OhCnvDCNmNgRL8k=; b=P7kpkX/rYmVC/75Ix0IWDL58c5Bqs7+3ImDAfycfQacnC3GqBaG43m3/qFfHf3RQwK VVTccNK2iMVDp4mHXgjAj/AjV2VFDz1Phb3PunJB3vvW3rghnZaOYTo7F4+lusOwk9GL +o9Xk31hghHvVR0JTKySORdjI5pfQV1uKvA4Kc2fh1ar8QOG/IUolMQQEku0lxkGeS1S HLtShWeuz/gJtfgDTN1bEj9zZTLsxEgPNsW9LDLyTSSaJNdGoWdn2cbldBrY37fsx5oO Ew0dihVcEO9u0HmTQhRVHptucNFNHMazOo9mScITd6yTTbpMoz2ABiOT0/fIDIIVDkqF MR+w== X-Gm-Message-State: ALQs6tBH5CCLH91866R32Vvxau+2/nchavPOYDMjt0XMtRPuAvBVkY1d T0yx0owl4yFKyjxVlMqP6uk= X-Received: by 2002:adf:968b:: with SMTP id u11-v6mr24850665wrb.184.1525511045936; Sat, 05 May 2018 02:04:05 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id o12-v6sm20946169wrf.31.2018.05.05.02.04.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 May 2018 02:04:05 -0700 (PDT) Date: Sat, 5 May 2018 11:04:03 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, aryabinin@virtuozzo.com, boqun.feng@gmail.com, catalin.marinas@arm.com, dvyukov@google.com, will.deacon@arm.com Subject: Re: [PATCH] locking/atomics: Clean up the atomic.h maze of #defines Message-ID: <20180505090403.p2ywuen42rnlwizq@gmail.com> References: <20180504173937.25300-1-mark.rutland@arm.com> <20180504173937.25300-2-mark.rutland@arm.com> <20180504180105.GS12217@hirez.programming.kicks-ass.net> <20180504180909.dnhfflibjwywnm4l@lakrids.cambridge.arm.com> <20180505081100.nsyrqrpzq2vd27bk@gmail.com> <20180505084721.GA32344@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180505084721.GA32344@noisy.programming.kicks-ass.net> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra wrote: > > So we could do the following simplification on top of that: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > This would disallow an architecture to override just fetch_dec_release for > instance. Couldn't such a crazy arch just define _all_ the 3 APIs in this group? That's really a small price and makes the place pay the complexity price that does the weirdness... > I don't think there currently is any architecture that does that, but the > intent was to allow it to override anything and only provide defaults where it > does not. I'd argue that if a new arch only defines one of these APIs that's probably a bug. If they absolutely want to do it, they still can - by defining all 3 APIs. So there's no loss in arch flexibility. > None of this takes away the giant trainwreck that is the annotated atomic stuff > though. > > And I seriously hate this one: > > ba1c9f83f633 ("locking/atomic/x86: Un-macro-ify atomic ops implementation") > > and will likely undo that the moment I need to change anything there. If it makes the code more readable then I don't object - the problem was that the instrumentation indirection made all that code much harder to follow. Thanks, Ingo