lkml.org 
[lkml]   [2005]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [patch 04/15] Generic Mutex Subsystem, add-atomic-call-func-x86_64.patch
    Nicolas Pitre wrote:
    > On Tue, 20 Dec 2005, Ingo Molnar wrote:
    >
    >
    >>* David Woodhouse <dwmw2@infradead.org> wrote:
    >>
    >>
    >>>On Mon, 2005-12-19 at 09:49 -0800, Zwane Mwaikambo wrote:
    >>>
    >>>>Hi Ingo,
    >>>> Doesn't this corrupt caller saved registers?
    >>>
    >>>Looks like it. I _really_ don't like calling functions from inline
    >>>asm. It's not nice. Can't we use atomic_dec_return() for this?
    >>
    >>we can use atomic_dec_return(), but that will add one more instruction
    >>to the fastpath. OTOH, atomic_dec_return() is available on every
    >>architecture, so it's a really tempting thing. I'll experiment with it.
    >
    >
    > Please consider using (a variant of) xchg() instead. Although
    > atomic_dec() is available on all architectures, its implementation is
    > far from being the most efficient thing to do for them all. For
    > example, see my discussion about swp on ARM:
    >

    Considering that on UP, the arm should not need to disable interrupts
    for this function (or has someone refuted Linus?), how about:

    #ifndef CONFIG_SMP
    typedef struct { volatile int counter; } mutex_counter_t;

    static inline int mutex_counter_dec_return(mutex_counter *v)
    {
    return --v->counter;
    }

    ...
    #else
    #define mutex_counter_t atomic_t
    ...
    #endif

    Or does that get too bulky or have other problems?

    MP ARMs should have an adequate atomic_dec_return.

    --
    SUSE Labs, Novell Inc.

    Send instant messages to your online friends http://au.messenger.yahoo.com

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-12-20 09:15    [W:0.021 / U:33.844 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site