[PATCH] docbook: some kernel-locking fixes - Kernel

This is a discussion on [PATCH] docbook: some kernel-locking fixes - Kernel ; From: Matti Linnanvuori Fix a wrong path. Add a chapter about try functions. http://bugzilla.kernel.org/show_bug.cgi?id=9011 Signed-off-by: Matti Linnanvuori Signed-off-by: Randy Dunlap --- Documentation/DocBook/kernel-locking.tmpl | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) --- lin2625-rc8-kdoc.orig/Documentation/DocBook/kernel-locking.tmpl +++ lin2625-rc8-kdoc/Documentation/DocBook/kernel-locking.tmpl @@ -290,7 +290,7 @@ ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] docbook: some kernel-locking fixes

  1. [PATCH] docbook: some kernel-locking fixes

    From: Matti Linnanvuori

    Fix a wrong path. Add a chapter about try functions.

    http://bugzilla.kernel.org/show_bug.cgi?id=9011

    Signed-off-by: Matti Linnanvuori
    Signed-off-by: Randy Dunlap

    ---
    Documentation/DocBook/kernel-locking.tmpl | 25 +++++++++++++++++++-
    1 file changed, 24 insertions(+), 1 deletion(-)

    --- lin2625-rc8-kdoc.orig/Documentation/DocBook/kernel-locking.tmpl
    +++ lin2625-rc8-kdoc/Documentation/DocBook/kernel-locking.tmpl
    @@ -290,7 +290,7 @@

    If you have a data structure which is only ever accessed from
    user context, then you can use a simple semaphore
    - (linux/asm/semaphore.h) to protect it. This
    + (include/asm/semaphore.h) to protect it. This
    is the most trivial case: you initialize the semaphore to the number
    of resources available (usually 1), and call
    down_interruptible() to grab the semaphore, and
    @@ -703,6 +703,29 @@



    +
    + The try variants
    +
    +
    + spin_trylock() does not spin but returns non-zero if
    + it acquires the spinlock on the first try or 0 if not.
    +

    +
    +
    + mutex_trylock() does not suspend your task
    + but returns non-zero if it could lock the mutex on the first try
    + or 0 if not.
    +

    +
    +
    + down_trylock() does not suspend your task
    + but returns 0 if it could get the semaphore on the first try or
    + non-zero if not. The return value is the inverse of that of
    + spin_trylock() and mutex_trylock()
    +
    .
    +

    +

    +

    Common Examples



    ---
    --
    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/

  2. Re: [PATCH] docbook: some kernel-locking fixes

    On Thursday 03 April 2008 07:47:50 Randy Dunlap wrote:
    > From: Matti Linnanvuori
    > +
    > + The try variants
    > +
    > +
    > + spin_trylock() does not spin but returns non-zero
    > + if it acquires the spinlock on the first try or 0 if not.
    > +

    > +
    > +
    > + mutex_trylock() does not suspend your task
    > + but returns non-zero if it could lock the mutex on the first try
    > + or 0 if not.
    > +

    > +
    > +
    > + down_trylock() does not suspend your task
    > + but returns 0 if it could get the semaphore on the first try or
    > + non-zero if not. The return value is the inverse of that of
    > + spin_trylock() and mutex_trylock()
    > +
    .
    > +

    > +


    OK, other than documenting the inconsistent horror of down_trylock, I don't
    like this patch. This document is not about documenting the functions, but
    providing an overview and pointing to them (where you can read to your
    heart's content).

    This is a worthy addition, but it's a paragraph, not a chapter. Unless you
    want to document why you would use the trylock variants (can mutex_trylock
    and down_trylock be used from interrupt context? Or are they only useful to
    avoid deadlock? How are they actually used in the kernel?)

    Thanks,
    Rusty.
    --
    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/

+ Reply to Thread