From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f197.google.com (mail-io0-f197.google.com [209.85.223.197]) by kanga.kvack.org (Postfix) with ESMTP id 970F56B0038 for ; Tue, 27 Dec 2016 14:23:20 -0500 (EST) Received: by mail-io0-f197.google.com with SMTP id c135so89392426ioe.6 for ; Tue, 27 Dec 2016 11:23:20 -0800 (PST) Received: from mail-io0-x243.google.com (mail-io0-x243.google.com. [2607:f8b0:4001:c06::243]) by mx.google.com with ESMTPS id q186si32535267iod.126.2016.12.27.11.23.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 11:23:19 -0800 (PST) Received: by mail-io0-x243.google.com with SMTP id j76so17192407ioe.0 for ; Tue, 27 Dec 2016 11:23:19 -0800 (PST) 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 Message-ID: Subject: Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Nicholas Piggin Cc: Dave Hansen , Bob Peterson , Linux Kernel Mailing List , Steven Whitehouse , Andrew Lutomirski , Andreas Gruenbacher , Peter Zijlstra , linux-mm , Mel Gorman 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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org