From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH 0/7] preempt_count rework -v2 Date: Tue, 10 Sep 2013 14:43:06 -0700 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-vc0-f180.google.com ([209.85.220.180]:64308 "EHLO mail-vc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954Ab3IJVnH (ORCPT ); Tue, 10 Sep 2013 17:43:07 -0400 In-Reply-To: <20130910212509.GA18147@laptop.programming.kicks-ass.net> Sender: linux-arch-owner@vger.kernel.org List-ID: 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" On Tue, Sep 10, 2013 at 2:25 PM, Peter Zijlstra wrote: > > Here's one that builds and boots on kvm until wanting to mount root. > > I'm not entirely sure on the "ir" vs "er" thing and atomic64_t and > local_t are inconsistent wrt that so I'm too. "i" is "any constant", while "e" is "32-bit signed constant". And I think all of the 64-bit ones should probably be "e", because afaik there is no way to add a 64-bit constant directly to memory (you have to load it into a register first). Of course, in reality, the constant is always just 1 or -1 or something like that, so nobody will ever notice the incorrect case... And it doesn't matter for the 32-bit cases, obviously, but we could just make them all be "e" for simplicity. 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", "") GENERATE_RMW(atomic_dec_and_test, LOCK_PREFIX "decl", "e", "") .. GENERATE_RMW(atomic_add_negative, LOCK_PREFIX "addl", "s", "") GENERATE_RMW(local_sub_and_test, "subl", "e", __percpu_prefix) ... etc. I'm sure the macro would be nasty as hell (and I bet it needs a few more arguments), but then we'd avoid the repetition.. Linus