Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933009AbcL0TaD (ORCPT ); Tue, 27 Dec 2016 14:30:03 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:35142 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932355AbcL0TaC (ORCPT ); Tue, 27 Dec 2016 14:30:02 -0500 MIME-Version: 1.0 In-Reply-To: References: <20161225030030.23219-1-npiggin@gmail.com> <20161225030030.23219-3-npiggin@gmail.com> <20161226111654.76ab0957@roar.ozlabs.ibm.com> <20161227211946.3770b6ce@roar.ozlabs.ibm.com> From: Linus Torvalds Date: Tue, 27 Dec 2016 11:23:19 -0800 X-Google-Sender-Auth: c4Wc4pku4Arq56QjgtjntktZiRA Message-ID: Subject: Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit To: Nicholas Piggin Cc: Dave Hansen , Bob Peterson , Linux Kernel Mailing List , Steven Whitehouse , Andrew Lutomirski , Andreas Gruenbacher , Peter Zijlstra , linux-mm , Mel Gorman 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: 1021 Lines: 36 On Tue, Dec 27, 2016 at 10:58 AM, Linus Torvalds wrote: > > The other alternative is to keep the lock bit as bit #0, and just make > the contention bit be the high bit. Then, on x86, you can do > > lock andb $0xfe,flags > js contention > > which might be even better. Again, it would be a very special > operation just for unlock. Something like > > bit_clear_and_branch_if_negative_byte(mem, label); > > and again, it would be trivial to do on most architectures. > > Let me try to write a patch or two for testing. Ok, that was easy. Of course, none of this is *tested*, but it looks superficially correct, and allows other architectures to do the same optimization if they want. On x86, the unlock_page() code now generates lock; andb $1,(%rdi) #, MEM[(volatile long int *)_7] js .L114 #, popq %rbp # ret for the actual unlock itself. Now to actually compile the whole thing and see if it boots.. Linus