From: Andrea Parri <parri.andrea@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: paulmck@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com,
aou@eecs.berkeley.edu, mmaas@google.com, hboehm@google.com,
striker@us.ibm.com, charlie@rivosinc.com, rehn@rivosinc.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] membarrier: riscv: Provide core serializing command
Date: Mon, 11 Dec 2023 17:46:19 +0100 [thread overview]
Message-ID: <ZXc82331D+qWufsL@andrea> (raw)
In-Reply-To: <fc29a938-c34a-45ee-8c6e-3aa71964c873@efficios.com>
> > /*
> > * The membarrier system call requires a full memory barrier
> > * after storing to rq->curr, before going back to user-space.
> > + *
> > + * The barrier is also needed for the SYNC_CORE command when
> > + * switching between processes; in particular, on a transition
> > + * from a thread belonging to another mm to a thread belonging
> > + * to the mm for which a membarrier SYNC_CORE is done on CPU0:
> > + *
> > + * - [CPU0] sets all bits in the mm icache_stale_mask.
> > + *
> > + * - [CPU1] store to rq->curr (by the scheduler).
> > + *
> > + * - [CPU0] loads rq->curr within membarrier and observes
> > + * cpu_rq(1)->curr->mm != mm, so the IPI is skipped on
> > + * CPU1; this means membarrier relies on switch_mm() to
> > + * issue the sync-core.
> > + *
> > + * - [CPU1] switch_mm() loads icache_stale_mask; if the bit
> > + * is zero, switch_mm() may incorrectly skip the sync-core.
> > + *
> > + * Matches the full barrier in membarrier_private_expedited().
>
> There are two full barriers in membarrier_private_expedited(). We
> should clearly state which one it matches, and update the associated
> barrier to state that it matches this barrier as well.
Agreed, will do.
Andrea
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-12-11 16:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 9:44 [PATCH v2 0/4] membarrier: riscv: Core serializing command Andrea Parri
2023-12-11 9:44 ` [PATCH v2 1/4] membarrier: riscv: Add full memory barrier in switch_mm() Andrea Parri
2023-12-11 13:39 ` Mathieu Desnoyers
2023-12-11 9:44 ` [PATCH v2 2/4] locking: Introduce prepare_sync_core_cmd() Andrea Parri
2023-12-11 9:44 ` [PATCH v2 3/4] membarrier: riscv: Provide core serializing command Andrea Parri
2023-12-11 13:55 ` Mathieu Desnoyers
2023-12-11 16:46 ` Andrea Parri [this message]
2023-12-11 9:44 ` [RFC PATCH 4/4] membarrier: Introduce Kconfig ARCH_HAS_MEMBARRIER Andrea Parri
2023-12-11 13:34 ` Mathieu Desnoyers
2023-12-11 16:53 ` Andrea Parri
2023-12-11 16:54 ` Mathieu Desnoyers
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=ZXc82331D+qWufsL@andrea \
--to=parri.andrea@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=hboehm@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mmaas@google.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=paulmck@kernel.org \
--cc=rehn@rivosinc.com \
--cc=striker@us.ibm.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;
as well as URLs for NNTP newsgroup(s).