Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp294201imm; Tue, 15 May 2018 01:37:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxVWT0yGO0fK27jEKtC8osxwqZSzFEZ2unkrqObEQ6eqM+lY3ZnfuNMR7cfH/fPM1GsSU4 X-Received: by 2002:a63:7904:: with SMTP id u4-v6mr3954441pgc.143.1526373473105; Tue, 15 May 2018 01:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526373473; cv=none; d=google.com; s=arc-20160816; b=WZpLhzed4RSpK03gB3N2uUXs05/rwyk7XzinT1EEA8QBnmGRnb1GaQ6w63R7eVVs4I BSnhDCqsZwipIVhG/1TRH7elT+q2qrbydw/l16X1FfEm6nZRZ5E7ZAcCcowBb4GFbgp6 1acxdLUD+4nYslQxXm7hMGTTQFSrWZ85/TPej5ate/zE1BxQSISomaa2fJsvQq9M1WCy kXTq8Vpcym9yV0A1lf3c+CpDm000Un7BwLdvFaZ4D3hpS4+aq4MLWg3NIx73TFAwn8EN s9tLyTkjIZyAcYcDCbW2QFjjwREgVKC3qgwL8TJfPKu1p6qSxZ0ZLb4bQJAWau/lC+fL kiZw== 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=eUCGBvLhayCRO8JZ1cmr8Nn+/G2pbUppTBPwJiuYqxI=; b=JnF2JKSucuMgyYTDb9NUosZBA/VhfJd1vweySXVQiF5SsQEVvVLRMQ//bmjD/8dtow qYQgawkIs6GA/R7pi2GU4zPd/WB2hzZCdamnQod5Qc9wiz2GLN23LJ3hYQenmuOyra39 T1Iy8LFGwF20kN7+CaqYaLP68dcTstpQeuhhfxkcGjoWrzITshIHUI7BebJk8EZONN9V kv3Z5Ha9I/dd9OZ/j4Au9KE5lRcrCXfHPtoniR5mt5e0kDPqho+T4dKlD/PL9G5JcBAg js3JJ6bXcspQ43xkkXkS7zaHzzdNUMcmUc/52hm9hxzNZ/uHsRGUjHnEu7Kb8kp55Dmi SENQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BrXM9RHB; 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 5-v6si11288332pfd.73.2018.05.15.01.37.38; Tue, 15 May 2018 01:37:53 -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=BrXM9RHB; 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 S1752461AbeEOIgD (ORCPT + 99 others); Tue, 15 May 2018 04:36:03 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:50345 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbeEOIgB (ORCPT ); Tue, 15 May 2018 04:36:01 -0400 Received: by mail-wm0-f66.google.com with SMTP id t11-v6so17868097wmt.0; Tue, 15 May 2018 01:36:00 -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=eUCGBvLhayCRO8JZ1cmr8Nn+/G2pbUppTBPwJiuYqxI=; b=BrXM9RHBnaB2o2oEBwSGd1QAy+bWeEcJcu91ACSNPbCjBxX9DwtKNs5vVrZNasqrOp WUG1yZJ6mWkVmfUJePyRYZJdgBWuwcHJzoQT/mWwjsb1CQUd7Bpsx9HuekX3KRlde0G+ C/JBeMhyMMPdgc3FCMIpWOD3xGIz4qqadw7PRSqJxwI0p7rgb1ngE9X+zTq2F4o7SkHg MDTj/QEJqn5YplS59S3N24sruk7HEy3xHua3CvZea8pgHiFvSFv0rBZprXS1uSPyHRyf xz3BraDupoamnU8ROuTJeuNteQh7mwZ4hLag8gA18m5EYqwlD0SkWZGOjGgRdW8VY+Qi CYCQ== 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=eUCGBvLhayCRO8JZ1cmr8Nn+/G2pbUppTBPwJiuYqxI=; b=FOaNqmcIQO6FInOLOaMyL8NcwIZGpIqmU+LQqsQnUV5H13nKa0Onc1rAWszZ/WrSxV Oc9idyT1jmbj9qEaf6zUiNu9y5uOPt00U3FxMmp3WsJdDNjoBlWNCCzaDBD7v4Iatz2c duWrbEtzIsMPVVBzNhX57Becp/S623k7AGLMi+1iE6Esd/zsMOA6eQmsXShq4rj3zem2 hiJxh1mcHkwqoq+3FG/GlVZfS8GZpSaBw68LKT6L10INZgeQ2NvB2nUYkSpyqaV/xyjq khr1Ee/J3zcZf9E4r5GYGHRIO7SYrfw20YctyOvtdPibkfAasGI20Kn5vpLTaKS6n68J UTLg== X-Gm-Message-State: ALKqPwc193tPn15N5Ta0sBmc380o6fQ34IFssCvMHEDsfY9EzqL43K7a 5vXnuaFC5mGGEHwJhw1rhMb12A== X-Received: by 2002:a1c:355:: with SMTP id 82-v6mr6547266wmd.96.1526373359926; Tue, 15 May 2018 01:35:59 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id b57-v6sm18130926wra.9.2018.05.15.01.35.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 01:35:59 -0700 (PDT) Date: Tue, 15 May 2018 10:35:56 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, will.deacon@arm.com, mark.rutland@arm.com, torvalds@linux-foundation.org, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com, linux-tip-commits@vger.kernel.org Subject: Re: [tip:locking/core] locking/atomics: Simplify the op definitions in atomic.h some more Message-ID: <20180515083556.GA30420@gmail.com> References: <20180505083635.622xmcvb42dw5xxh@gmail.com> <20180509073327.GE12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509073327.GE12217@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra wrote: > And if we're going to do codegen, we might as well all generate this > anyway, so all this mucking about is a complete waste of time. I'm not yet convinced that it will be cleaner, but can be convinced in principle, but meanwhile the existing code is arguably butt-ugly and bloaty. Regarding these cleanups, we had this before: /* atomic_add_return_relaxed */ #ifndef atomic_add_return_relaxed #define atomic_add_return_relaxed atomic_add_return #define atomic_add_return_acquire atomic_add_return #define atomic_add_return_release atomic_add_return #else /* atomic_add_return_relaxed */ #ifndef atomic_add_return_acquire #define atomic_add_return_acquire(...) \ __atomic_op_acquire(atomic_add_return, __VA_ARGS__) #endif #ifndef atomic_add_return_release #define atomic_add_return_release(...) \ __atomic_op_release(atomic_add_return, __VA_ARGS__) #endif #ifndef atomic_add_return #define atomic_add_return(...) \ __atomic_op_fence(atomic_add_return, __VA_ARGS__) #endif #endif /* atomic_add_return_relaxed */ Which is 23 lines per definition. Now we have this much more compact definition: #ifndef atomic_add_return_relaxed # define atomic_add_return_relaxed atomic_add_return # define atomic_add_return_acquire atomic_add_return # define atomic_add_return_release atomic_add_return #else # ifndef atomic_add_return # define atomic_add_return(...) __op_fence(atomic_add_return, __VA_ARGS__) # define atomic_add_return_acquire(...) __op_acquire(atomic_add_return, __VA_ARGS__) # define atomic_add_return_release(...) __op_release(atomic_add_return, __VA_ARGS__) # endif #endif Which is just _half_ the linecount. Automated code generation might improve this some more, but the net effect on the core code right now is 373 lines removed: include/linux/atomic.h | 1109 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------- 1 file changed, 368 insertions(+), 741 deletions(-) ... shrunk to just 709 lines. The x86/include/asm/atomic64_64.h file got smaller as well due to the cleanups: arch/x86/include/asm/atomic64_64.h | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------- 1 file changed, 97 insertions(+), 119 deletions(-) So unless you can clean this up and shrink this even more, these changes are obviously justified on their own. Thanks, Ingo