Thread (21 messages) 21 messages, 4 authors, 2017-01-03

Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-12-27 19:30:03
Also in: lkml

On Tue, Dec 27, 2016 at 10:58 AM, Linus Torvalds
[off-list ref] 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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help