9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Devon H. O'Dell" <devon.odell@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] waitfree
Date: Mon, 19 May 2014 17:01:37 -0400	[thread overview]
Message-ID: <CAFgOgC91+3NNYAfp0FYS6uEaktWhLfNfr=xcVWFGJBS_-_-i1Q@mail.gmail.com> (raw)
In-Reply-To: <a593342e60fac111d7ca7146cdca7ff8@ladd.quanstro.net>

So you seem to be worried that N processors in a tight loop of LOCK
XADD could have a single processor. This isn't a problem because
locked instructions have total order. Section 8.2.3.8:

"The memory-ordering model ensures that all processors agree on a
single execution order of all locked instructions, including those
that are larger than 8 bytes or are not naturally aligned."



2014-05-19 16:21 GMT-04:00 erik quanstrom <quanstro@quanstro.net>:
>
> On Mon May 19 15:51:27 EDT 2014, devon.odell@gmail.com wrote:
> > The LOCK prefix is effectively a tiny, tiny mutex, but for all intents
> > and purposes, this is wait-free. The LOCK prefix forces N processors
> > to synchronize on bus and cache operations and this is how there is a
> > guarantee of an atomic read or an atomic write. For instructions like
> > cmpxchg and xadd where reads and writes are implied, the bus is locked
> > for the duration of the instruction.
> >
> > Wait-freedom provides a guarantee on an upper-bound for completion.
> > The pipeline will not be reordered around a LOCK instruction, so your
> > instruction will cause a pipeline stall. But you are guaranteed to be
> > bounded on the time to complete the instruction, and the instruction
> > decomposed into μops will not be preempted as the μops are executed.
>
> there is no bus.

What you mean is that the processor might not LOCK#, but it can. LOCK
will signal LOCK# on the bus if it thinks it has to. (And if whatever
is being ainc()'ed is ainc()'ed frequently, or whatever is being
ainc()'ed is just never in cache for whatever reason, that will
happen.)

> what LOCK really does is invoke part of the MSEI protocol.  the state
> diagrams i've seen do not specifiy how this is arbitrated if there are > 1
> processor trying to gain exclusive access to the same cacheline.
>
> > Wait-freedom is defined by every operation having a bound on the
> > number of steps required before the operation completes. In this case,
> > you are bound by the number of μops of XADDL + latency to memory. This
> > is a finite number, so this is wait-freedom.
>
> i'm worried about the bound on the number of MSEI rounds.  i don't see
> where the memory coherency protocol states that if there are n processors
> a cacheline will be acquired in at most f(n) rounds.

In Section 8.2.3.8 of the manual:

"8.2.3.8 Locked Instructions Have a Total Order

The memory-ordering model ensures that all processors agree on a
single execution order of all locked instructions, including those
that are larger than 8 bytes or are not naturally aligned."

Thus, LOCK-prefixed instructions will never cause processor
starvation, which seems to be your worry. They're wait-free.

--dho

> - erik
>



  reply	other threads:[~2014-05-19 21:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 17:34 erik quanstrom
2014-05-19 19:49 ` Devon H. O'Dell
2014-05-19 20:21   ` erik quanstrom
2014-05-19 21:01     ` Devon H. O'Dell [this message]
2014-05-19 22:05       ` erik quanstrom
2014-05-19 22:14         ` ron minnich
2014-05-19 22:18           ` erik quanstrom
2014-05-20  1:10         ` Devon H. O'Dell
2014-05-20  2:12           ` erik quanstrom
2014-05-20 14:47             ` Devon H. O'Dell
2014-05-20 15:41               ` erik quanstrom
2014-05-20 19:14                 ` Devon H. O'Dell
2014-05-20 19:30                   ` erik quanstrom
2014-05-20 20:32                     ` Devon H. O'Dell

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='CAFgOgC91+3NNYAfp0FYS6uEaktWhLfNfr=xcVWFGJBS_-_-i1Q@mail.gmail.com' \
    --to=devon.odell@gmail.com \
    --cc=9fans@9fans.net \
    /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;
as well as URLs for NNTP newsgroup(s).