Received: by 10.192.165.148 with SMTP id m20csp978042imm; Sat, 5 May 2018 02:09:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+Drv6Jye9JYjIljz/oD1R8k7Lh7y0uPydB1KT0/1rsqra3JTkRbsorSLLhBhsyDBrNbFY X-Received: by 2002:a17:902:ba87:: with SMTP id k7-v6mr22888322pls.193.1525511372296; Sat, 05 May 2018 02:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525511372; cv=none; d=google.com; s=arc-20160816; b=rsknhw1/87/hJaZ7o/ltO+hG4TG0Y8VQP4Xy+wq0XYNdroqIDYGwa+oSmI+e/a4aX8 NDbBnXIGJNgKcFSdcY5CSihEJlYMwS/6J1CA6C0EWQNnf8rKxdJ/cSisQXwTwO5NaSMW lkrrTAT0R0EtRfTj6E1plRLc4on4anyksr/RQF3/g+kB4U+E9WdastC/y0/ZqNaHrQjh 2wRzEbyTJZMLed7UHjg00QwOPQ3OQOW/bDzZxa9arYPjvSdAitJOLoxNF0xtxE3/Y6nv oR5oOKSiS1MoneN0txZPJdCuBYHRbv/G6manEk8+DB1gxmaU9pUeZADFGzLdPMQvKJHm EL9w== 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=OdLhozBCGHxUMpPtfyBN4rP+UQO1FGVsR8qwWyKLafc=; b=GVTPP5pL3lYaMf1MK3FkFrKgvXxnmRrVRFJLvOXmbC49SGkjB/NjtwMzcfvaAA3mNX 3SyHffJj72N1qzVCdqXQF3uNoMDBMha6HyW0Arv73/fSU2YhYdgDFbZXiiR/EjXbnIQE K4id2f+WJG7Wi4EeaESsXwjIuc8BiYoAbdxfzruEq9L5GuGb4tFM9pyXmL/Q29R1Sp+r V799VtZy+mmCkQujTYOGz/aODey+56AFWWtrmjupZr/yGBFuUUy//n6AAKn7Z5dEy5LU ERWip+G0Lhv9IcT3AtFXbFbWPUEUslx5NXW0bapTPVatrx1VPBWAhDynrjcJpi+6Mu71 2Q1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LKvtX0T9; 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 t17-v6si16831959plo.46.2018.05.05.02.09.17; Sat, 05 May 2018 02:09: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=LKvtX0T9; 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 S1751211AbeEEJJI (ORCPT + 99 others); Sat, 5 May 2018 05:09:08 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35131 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbeEEJJH (ORCPT ); Sat, 5 May 2018 05:09:07 -0400 Received: by mail-wr0-f195.google.com with SMTP id i14-v6so20078304wre.2 for ; Sat, 05 May 2018 02:09: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=OdLhozBCGHxUMpPtfyBN4rP+UQO1FGVsR8qwWyKLafc=; b=LKvtX0T91tkpdg3HeSGF9wAHgBtyFX9hj/P5PXcoXJWrlgCNPnomN9VspGdnBk0f9t sxRibFAr45/rBg42P3ry0amnwHaw0Dbtb9z2yoi32tJMaQmtZih1lj6G2WxsbrNMvxhG 5XOFbOruEjO0DgrRPRhdHEhT/PvKPHdZewF1p1PAOnaEtzWVCGXEht74bjnGL/2afCUA AinY5CfLPtdhneiIIlnePcBN4Rc6q2AJcMTe77os3paKIKjtKdHRHelrJFRR5jrVxubE whckNNRYLogc5daqfHmvA8ZMvVR2fnvDp/wo1u90fbbmTYPDVDWSyWHV3GOPXS0UtuEu V7gQ== 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=OdLhozBCGHxUMpPtfyBN4rP+UQO1FGVsR8qwWyKLafc=; b=o3x1G0TlNhMeP2ggyFLOOtjH/4kNPhVCyg2ZYnn6UdVt2ryWfWJ4Q5JI5nTsIDNpF9 CGpypbCyw4RhcCgcDevnsG2uwxySxobvv68dcBBTB+aywv5pEB9rM6s0fra4fG/GwkSl WtwwBLoej8yvhisa3VhSSF7jq7UQVY7nKFdLMpjhIUKBonH1jW0ozd2ncgLAbOsPOngA QnyFEncGKfXBSIcnfrkogYnGDsfANBqJ97ovcmQciaPy4afXs3zVol8zyWFS4zAThYyK n/XztK1AglhUStCIuXwNe4QQB/dUmMbVtsRP5Ooel1JZ4ZTB9YWCXRsQyJT2vZ/BXUgQ BXcg== X-Gm-Message-State: ALQs6tBhNyh/5iqOopa4gItqzDDfUv9nXpL/VNS6TVVgiaNPvvO5/7+F PRwO6TzRP4i4dGLUOdSiBWY= X-Received: by 2002:adf:b456:: with SMTP id v22-v6mr13996519wrd.67.1525511345750; Sat, 05 May 2018 02:09:05 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id m1-v6sm3680896wma.8.2018.05.05.02.09.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 May 2018 02:09:05 -0700 (PDT) Date: Sat, 5 May 2018 11:09: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: <20180505090903.ebsf5vosgwckxooy@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: > On Sat, May 05, 2018 at 10:11:00AM +0200, Ingo Molnar wrote: > > > Before: > > > > #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 /* atomic_fetch_dec */ > > #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 /* atomic_fetch_dec */ > > > > #else /* atomic_fetch_dec_relaxed */ > > > > #ifndef atomic_fetch_dec_acquire > > #define atomic_fetch_dec_acquire(...) \ > > __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > #endif > > > > #ifndef atomic_fetch_dec_release > > #define atomic_fetch_dec_release(...) \ > > __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > #endif > > > > #ifndef atomic_fetch_dec > > #define atomic_fetch_dec(...) \ > > __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > #endif > > #endif /* atomic_fetch_dec_relaxed */ > > > > After: > > > > #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_acquire > > # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec_release > > # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > The new variant is readable at a glance, and the hierarchy of defines is very > > obvious as well. > > It wraps and looks hideous in my normal setup. And I do detest that indent > after # thing. You should use wider terminals if you take a look at such code - there's already numerous areas of the kernel that are not readable on 80x25 terminals. _Please_ try the following experiment, for me: Enter the 21st century temporarily and widen two of your terminals from 80 cols to 100 cols - it's only ~20% wider. Apply the 3 patches I sent and then open the new and the old atomic.h in the two terminals and compare them visually. The new structure is _much_ more compact, it is nicer looking and much more readable. Thanks, Ingo