All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bob Breuer <breuerr@mc.net>
To: sparclinux@vger.kernel.org
Subject: Re: 2.6.17-rc5 does not build for sparc
Date: Tue, 06 Jun 2006 04:59:29 +0000	[thread overview]
Message-ID: <44850BB1.9020007@mc.net> (raw)
In-Reply-To: <4478bffd45960@wp.pl>

David Miller wrote:
> From: "Krzysztof Helt" <krzysztof.h1@wp.pl>
> Date: Sat, 27 May 2006 23:09:17 +0200
> 
>> I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The
>> kernel was not build due to a missing macro. Here is a patch
>> which fixes this (I copied the macro from a sparc64 header).
> 
> I was going to apply this just to fix the build, but it's
> not correct.
> 
> Because we embed a spinlock in the rwlock_t, we have to spin
> waiting for the lock bits to be clear before we can trust the
> sample of the rest of the lock.  We used to have to do this
> when we embedded a spinlock into the atomic_t's on sparc32.

Correct me if I am wrong, but...

From asm-sparc/spinlock.h:

 *      ------------------------------------
 *      | 24-bit counter           | wlock |  raw_rwlock_t
 *      ------------------------------------
 *       31                       8 7     0
 *
 * wlock signifies the one writer is in or somebody is updating
 * counter. For a writer, if he successfully acquires the wlock,
 * but counter is non-zero, he has to release the lock and wait,
 * till both counter and wlock are zero.


rw->lock in this case is the full 32-bit raw_rwlock_t, so a value of
0x000000ff is locked by a writer, 0x00000100 would be locked by a
reader, and 0x000001ff would be locked by a reader and updating the counter.

For __raw_write_can_lock(), we should be able to return true when the
whole 32-bits is zero (i.e. no readers, no counter being updated, and no
writers).  rw->lock is the whole 32-bits, so a check of !(rw)->lock
should be the right thing.

While we are at it, another one we are missing is __raw_read_can_lock(),
and I think that a check of !((rw)->lock & 0xff) will work (i.e. no
writers and no updating of the counter), or might it be better if the
counter was negated and we checked  rw->lock <= 0 ?

Bob

  parent reply	other threads:[~2006-06-06  4:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-27 21:09 2.6.17-rc5 does not build for sparc Krzysztof Helt
2006-05-27 22:43 ` Bob Breuer
2006-05-28  9:30 ` BERTRAND Joël
2006-05-28 10:27 ` Christian Joensson
2006-05-29  6:03 ` Krzysztof Helt
2006-06-06  4:15 ` David Miller
2006-06-06  4:59 ` Bob Breuer [this message]
2006-06-06  5:08 ` David Miller
2006-06-06  7:09 ` Bob Breuer
2006-06-08 11:33 ` Krzysztof Helt

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=44850BB1.9020007@mc.net \
    --to=breuerr@mc.net \
    --cc=sparclinux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.