9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <charles.forsyth@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] coherence function in kernel (especially in raspberry pi port)
Date: Fri, 31 Mar 2017 13:35:30 +0100	[thread overview]
Message-ID: <CAOw7k5i5q8UazgK6=DkbiD8ZM71UL7LOwL-JWExKReM=aazvMg@mail.gmail.com> (raw)
In-Reply-To: <57BD96A7-F16A-45E6-B8D2-E1B293E77B0B@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]

On 28 March 2017 at 19:21, yoann padioleau <aryx.padator@gmail.com> wrote:

> For example I see this code in bcm/taslock.c
>
>         coherence();
>         l->key = 0;
>         coherence();
>
> bcm/taslock.c seems actually mostly a copy paste of port/taslock.c
> with an extra call to coherence before the assignment above.
>

I've got that extra coherence call in port/taslock.c now (although my more
recent kernels use MCS locks exclusively)

You need to look at the full code fragment:

l->p = nil;
l->pc = 0;
l->m = nil;
coherence();
l->key = 0;
coherence();

assume coherence is a suitable barrier instruction on a given machine.
the calls are there to control the ordering (of stores in this case) as
seen by an observer,
which depends on the memory ordering model of a given processor or system
implementation.

the sequence is clearing references in the lock, to the Proc and the Mach
on which it's running.
we don't care about the order in which those stores are observed.
the first barrier ensures that all are observable before the critical store
to key that releases the Lock.

the second barrier ensures that once the lock is free, no further store can
be observed before
the lock-clearing store has been observed.

there is a general assumption in the system that any multiprocessor running
these kernels will have cache-coherency enabled across processors, although
that need not extend to devices (where the device drivers can do the little
dances needed to ensure coherent views of memory).

[-- Attachment #2: Type: text/html, Size: 2826 bytes --]

      parent reply	other threads:[~2017-03-31 12:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 18:21 yoann padioleau
2017-03-30 20:39 ` [9fans] coherence function in kernel (especially in raspberry pi Richard Miller
2017-03-31  9:08 ` [9fans] coherence function in kernel (especially in raspberry pi port) Charles Forsyth
2017-03-31 12:35 ` Charles Forsyth [this message]

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='CAOw7k5i5q8UazgK6=DkbiD8ZM71UL7LOwL-JWExKReM=aazvMg@mail.gmail.com' \
    --to=charles.forsyth@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).