From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Matt Turner <mattst88@gmail.com>,
Waiman Long <waiman.long@hp.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Daniel J Blueman <daniel@numascale.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v8 4/4] qrwlock: Use smp_store_release() in write_unlock()
Date: Sun, 19 Jan 2014 16:52:15 -0800 [thread overview]
Message-ID: <20140120005215.GH10038@linux.vnet.ibm.com> (raw)
In-Reply-To: <CA+55aFwPpEOqkhi8C=ck+6WFQJHOW3LsNg-0DxjMm9m1HW1AYA@mail.gmail.com>
On Sun, Jan 19, 2014 at 11:56:02AM -0800, Linus Torvalds wrote:
> On Sun, Jan 19, 2014 at 12:04 AM, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> >
> > OK, another approach would be to never add "select ARCH_USE_QUEUE_RWLOCK"
> > on Alpha, at least if the queued rwlocks really do want to atomically
> > manipulate bytes. After all, the Alpha systems that I know about don't
> > have enough CPUs to make queued rwlocks necessary anyway.
> >
> > Much simpler solution!
> >
> > Is this what you were getting at, or am I missing your point?
>
> You're missing something.
>
> Just make the "writer" field be an "int" on little-endian archiectures
> (like alpha).
>
> There is no reason for that field to be a "char" to begin with, as far
> as I can tell, since the padding of the structure means that it
> doesn't save any space. But even if that wasn't true, we could make an
> arch-specific type for "minimum type for locking".
On 64-bit systems (which includes Alpha), agreed, the field can be a
32-bit portion of a 64-bit structure that is then manipulated atomically.
Many 32-bit systems need the reader and writer counts to fix in 32 bits
in order to allow things like queue_read_trylock() to correctly account
for both readers and writers.
If there was a 32-bit system running Linux that did not support byte
accesses, there would be a problem, but I don't know of any such system.
> So my *point* was that it should be easy enough to just make sure that
> any data structures used for locking have types that are appropriate
> for that locking.
So something like the following for the qrwlock definition, with
appropriate C-preprocessor wrappers for the atomic-add accesses?
Thanx, Paul
------------------------------------------------------------------------
typedef struct qrwlock {
union qrwcnts {
#ifdef CONFIG_64B
struct (
int writer;
int reader;
};
atomic_long_t rwa;
u64 rwc;
#else
struct {
#ifdef __LITTLE_ENDIAN
u8 writer; /* Writer state */
#else
u16 r16; /* Reader count - msb */
u8 r8; /* Reader count - lsb */
u8 writer; /* Writer state */
#endif
};
atomic_t rwa; /* Reader/writer atomic */
u32 rwc; /* Reader/writer counts */
} cnts;
#endif
struct mcs_spinlock *waitq; /* Tail of waiting queue */
} arch_rwlock_t;
next prev parent reply other threads:[~2014-01-20 0:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 2:47 [PATCH v8 4/4] qrwlock: Use smp_store_release() in write_unlock() Daniel J Blueman
2014-01-13 3:49 ` Paul E. McKenney
2014-01-13 16:41 ` Waiman Long
2014-01-14 2:28 ` Daniel J Blueman
2014-01-14 11:03 ` Peter Zijlstra
2014-01-14 15:25 ` Waiman Long
2014-01-14 17:08 ` Matt Turner
2014-01-14 18:01 ` Richard Henderson
2014-01-14 19:09 ` Waiman Long
2014-01-14 20:20 ` Peter Zijlstra
2014-01-14 23:44 ` Paul E. McKenney
2014-01-15 0:25 ` Linus Torvalds
2014-01-15 2:39 ` Paul E. McKenney
2014-01-15 8:07 ` Peter Zijlstra
2014-01-15 20:53 ` Paul E. McKenney
2014-01-15 23:21 ` Peter Zijlstra
[not found] ` <CA+55aFydYLQeBq=4AQQp_4dAnq09ocLmde1LFaXiNAJ=wJzfFA@mail.gmail.com>
2014-01-16 10:36 ` Peter Zijlstra
2014-01-18 10:01 ` Paul E. McKenney
2014-01-18 11:34 ` Peter Zijlstra
2014-01-18 12:25 ` Paul E. McKenney
2014-01-18 12:41 ` Peter Zijlstra
2014-01-18 21:22 ` Paul E. McKenney
2014-01-19 0:57 ` Linus Torvalds
2014-01-19 8:04 ` Paul E. McKenney
2014-01-19 19:56 ` Linus Torvalds
2014-01-20 0:52 ` Paul E. McKenney [this message]
2014-01-21 15:02 ` Waiman Long
2014-01-21 15:41 ` Peter Zijlstra
2014-01-21 16:16 ` Waiman Long
2014-01-15 3:08 ` Daniel J Blueman
-- strict thread matches above, loose matches on Subject: below --
2014-01-08 16:59 [PATCH v8 0/4] qrwlock: Introducing a queue read/write lock implementation Waiman Long
2014-01-08 16:59 ` [PATCH v8 4/4] qrwlock: Use smp_store_release() in write_unlock() Waiman Long
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=20140120005215.GH10038@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=daniel@numascale.com \
--cc=ink@jurassic.park.msu.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=peterz@infradead.org \
--cc=rth@twiddle.net \
--cc=torvalds@linux-foundation.org \
--cc=waiman.long@hp.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 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.