[lkml]   [2000]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7]
    On Thu, 7 Sep 2000, Franz Sirl wrote:

    >In short terms:
    >- __volatile__ assures that the code isn't reordered against other
    >__volatile__ and isn't hoisted out of loops, nothing else
    >- the "memory" clobber makes sure the asm isn't reordered against other
    >memory accesses

    Ok. That's all I wanted to hear.

    So _definitely_ all spinlocks needs "memory" in the clobber list.

    I'll do a new patch reinserting "memory" in __sti and inserting
    "memory" also in the spin_unlock() case.

    The reason of my doubt was that I only got one agreement by Pavel and none
    other comment. Furthmore in practice there was no miscompilation thus I
    was wondering if I misunderstood the semantics of __volatile__ (but then
    of course I was asking myself what "memory" was good for :))

    >Essentially, you _always_ have to tell the compiler if you touch memory
    >behind it's back, this includes inline assembly to flush the cache or the

    I understand this completly. And as said we can't do that with the
    spinlocks (at least with the current API to spin_lock and friends) thus we
    need "memory" in the clobber list.

    >General rule of thumb for inline assembly:
    > Give the compiler as much information as possible!!
    >If you know inline assembly read/writes memory, tell it to the compiler, as
    >detailed as possible!

    Indeed :). If we could teach all the memory changes to the inline assembly
    then "memory" wouldn't be necessary anymore into the clobber list.


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 12:38    [W:0.021 / U:8.180 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site