Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755344Ab3IKPd0 (ORCPT ); Wed, 11 Sep 2013 11:33:26 -0400 Received: from mail-vc0-f173.google.com ([209.85.220.173]:59954 "EHLO mail-vc0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754367Ab3IKPdW (ORCPT ); Wed, 11 Sep 2013 11:33:22 -0400 MIME-Version: 1.0 In-Reply-To: <20130911131323.GQ31370@twins.programming.kicks-ass.net> References: <20130910130811.507933095@infradead.org> <20130910135152.GD7537@gmail.com> <20130910135636.GA8268@gmail.com> <20130910164519.GL31370@twins.programming.kicks-ass.net> <20130910212509.GA18147@laptop.programming.kicks-ass.net> <20130911131323.GQ31370@twins.programming.kicks-ass.net> Date: Wed, 11 Sep 2013 08:33:21 -0700 X-Google-Sender-Auth: WkOr5S_XUdLyoeKdUu2s8p326Cw Message-ID: Subject: Re: [PATCH 0/7] preempt_count rework -v2 From: Linus Torvalds To: Peter Zijlstra Cc: Ingo Molnar , Andi Kleen , Peter Anvin , Mike Galbraith , Thomas Gleixner , Arjan van de Ven , Frederic Weisbecker , Linux Kernel Mailing List , "linux-arch@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1434 Lines: 35 On Wed, Sep 11, 2013 at 6:13 AM, Peter Zijlstra wrote: > On Tue, Sep 10, 2013 at 02:43:06PM -0700, Linus Torvalds wrote: >> That said, looking at your patch, I get the *very* strong feeling that >> we could make a macro that does all the repetitions for us, and then >> have a >> >> GENERATE_RMW(atomic_sub_and_test, LOCK_PREFIX "subl", "e", "") > > The below seems to compile.. You have that horrible duplication in the macro itself now, though. The only difference between the 4-byte and the 8-byte one is the "l" vs "q". And the counter increment/decrement argument (by the caller) defines whether it's add/dec/inc. Why not just add those as parameters to the macro, and suddenly the macro becomes 10x smaller. An excessively complex macro that makes the arguments trivially simpler is not worth it. Especially since that excessive macro complexity now means that your macro is useless for things that the *simpler* macro could have done, like the bit-test-and-modify cases. So your complexity actually makes things worse. So just pass in the operation name and size. Then somebody will use it for test_and_set_bit() and friends too. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/