Received: by 10.192.165.148 with SMTP id m20csp989357imm; Sat, 5 May 2018 02:25:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoSxy+GTdHUm34o34EBSjgajZJg3h3/BOQ2E0cYjTLdz9ejwohgUONeguaYy3JBkDGVwZho X-Received: by 10.98.242.74 with SMTP id y10mr30045293pfl.75.1525512321381; Sat, 05 May 2018 02:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525512321; cv=none; d=google.com; s=arc-20160816; b=XC8jIliGcBEX9L58Qhdibc2qRuHjRSLtWCtQrAEhIg/0ygFCaWhMhlqjEBuGpHHGnk DvhGZPQXZ0wuJ59TrUK3DGj+Pc6c/qzcDY17ylz1XXu/mZR01PVPDdiOXnBEEqDgLu1D sqbsw50xljAh6/JHvsc6kQ1BKmQCAgELgPTRnu8wqYnJI6V8tmlZizRDqeIuyLrXGkjf Dr32xdTHM58Ok280K9lLBj2m0YAtcZLvZhdVElzNkHy61octal5SrYZWPWs7ug4Gx4eW HHnljhMDatjfupl/nj6bRM7DbRxlYE9Syso5f0Y4LpcqZLFYhu7URtigbwif7Y1bzu2x X88Q== 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=kI7SaTzNkgXuihFLkHGsLpA+BLtvlViAhe4LVa0QEO0=; b=blV6sDUi+gYgNdTO8I2BpiUuW0UVOQZ9JAHMeeBxYwzSdofuGd3rwYukDDBFAB9gSC dKkN5lIWtg3khiW9vLscBqz5owlMcx67jQnIIAjbxpOgVc+Hb4OA5+nMESnzEtZ4LVHQ vm8JtXfG6+eSoXu+SnahVLxacZxxDOlgezf/uoX7tSWHUUNQAyhhBfvWsYec7I+l6EWL fm+ZctMToyEsuhgsb444BBZtK2rg+ojHdAot2xPYiIhrnkpZNDKxGC+X6jyV37hMvsAy sYFOE5UUXFTrol5AtnTNXW4ccu184n2RMlbJDXRscQ4C0N5Z3SLz25SAgyZWsIZlp+Sx l/7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Ue7Q/HJu; 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 t5-v6si6945092ply.598.2018.05.05.02.24.52; Sat, 05 May 2018 02:25:21 -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=@infradead.org header.s=bombadil.20170209 header.b=Ue7Q/HJu; 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 S1751266AbeEEJYo (ORCPT + 99 others); Sat, 5 May 2018 05:24:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39930 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbeEEJYn (ORCPT ); Sat, 5 May 2018 05:24:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=kI7SaTzNkgXuihFLkHGsLpA+BLtvlViAhe4LVa0QEO0=; b=Ue7Q/HJuM62SmPUTDCi4mbvlZ QyGb1X7ur+lK8OY1Mozr/zgX37MvLR0yPn2hI3cSPJ3Y4bTqGtuUgud3E36WBzbIsyVWTlnAy6CSr ubo2S6lGk6UotIHkWH1M0H6yT1m9kxk/x6U3Jh8R0gYThpa+Qyhca9CkSp+00A8lVa0u73w5PlOBv 71/lYXf9VXX/pakw2IxIN73rkIa1V1J1A1LwEhxuydgJpaGYrgAN870zktuWG0WiH7+LLt6cXYuzF zQ7tJ9zraM9T1YxfjssFzzahtCTapx7cbFbs/TOHIiFZTLPsn93S2DHPCYOpZqyrpv1my0U6pjGQ5 aBU1XJFFA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEtQm-0005tQ-FC; Sat, 05 May 2018 09:24:40 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4A3BA2029FA13; Sat, 5 May 2018 11:24:38 +0200 (CEST) Date: Sat, 5 May 2018 11:24:38 +0200 From: Peter Zijlstra To: Ingo Molnar 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: <20180505092438.GB12217@hirez.programming.kicks-ass.net> 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> <20180505090403.p2ywuen42rnlwizq@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180505090403.p2ywuen42rnlwizq@gmail.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 05, 2018 at 11:04:03AM +0200, Ingo Molnar wrote: > > * 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 would expect the pattern where it can do all 'release' and/or all 'acquire' variants special but cannot use the __atomic_op_*() wrappery. > > 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. Ideally we'd generate the whole mess.. and then allowing these extra few overrides is not a problem at all. > > 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. Thing is, it is all the exact same loop, and bitrot mandates they drift over time. When I cleaned up all the architectures I found plenty cases where there were spurious differences between things.