Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: "Kevin D. Kissell" <kevink@mips.com>
To: "Linux SGI" <linux@cthulhu.engr.sgi.com>
Subject: Kernel Semaphores
Date: Mon, 6 Dec 1999 17:02:06 +0100	[thread overview]
Message-ID: <00b901bf4003$3f583c50$0ceca8c0@satanas.mips.com> (raw)

This is for Ralf and any other MIPS/Linux kernel
hackers who may be on the list.

Some time ago, I fixed the assembler macros
for waking_non_zero_interruptable and down_trylock
to be correct(ish) for MIPSEL and MIPSEB, but
there remained the issue of their requiring the use
of 64-bit instructions to work - they "cheat" by using
the same ll/sc pair to update both the count and the
waking field of the semaphore.

To make it work on 32-bit CPUs, I looked at using
the x386 model, but that one uses interrupt disables
and is intrinsically SMP-unsafe.  Now, looking at 
the comments and studying the code a bit,
it *seems* that the issue is not so much a race
condition between updates of the waking and
count fields, but a race with other functions that
may be updating the waking field.   CAN ANYONE
CONFIRM OR DENY THAT?

If it's true, it looks to me that by inventing one
new primitive in atomic.h, atomic_sub_and_return_if_gtz(),
one can:

    a) Eliminate the need for an assembly macro dedicated
        to waking_non_zero, which maps directly to the new macro.
    b) Make it possible to do waking_non_zero_interruptible in
        C, as all the examinations/updates of sem->waking can
        be made atomic
    c) Likewise simplify down_trylock() and
    d) Make waking_non_zero_trylock() SMP safe.

I've coded this up for experimentation, and will provide
the sources (at least relative to 2.2.12) to any interested
parties, but I'd really like someone who has worked
intimately with the kernel semaphores to tell me if
there really are races between updates of sem->waking
and sem->count, and if they exist, what they are!
__

Kevin D. Kissell
MIPS Technologies European Architecture Lab
kevink@mips.com
Tel. +33.4.78.38.70.67
FAX. +33.4.78.38.70.68

             reply	other threads:[~1999-12-06 15:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-06 16:02 Kevin D. Kissell [this message]
1999-12-06 19:08 ` Kernel Semaphores Ralf Baechle
  -- strict thread matches above, loose matches on Subject: below --
1999-12-06 20:33 Kevin D. Kissell
1999-12-06 21:13 ` Ralf Baechle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00b901bf4003$3f583c50$0ceca8c0@satanas.mips.com' \
    --to=kevink@mips.com \
    --cc=linux@cthulhu.engr.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox