Re: [PATCH 1/8] membarrier: Document why membarrier() works

From: Peter Zijlstra
Date: Wed Jun 16 2021 - 03:32:21 EST


On Wed, Jun 16, 2021 at 02:00:37PM +1000, Nicholas Piggin wrote:
> Excerpts from Andy Lutomirski's message of June 16, 2021 1:21 pm:
> > We had a nice comment at the top of membarrier.c explaining why membarrier
> > worked in a handful of scenarios, but that consisted more of a list of
> > things not to forget than an actual description of the algorithm and why it
> > should be expected to work.
> >
> > Add a comment explaining my understanding of the algorithm. This exposes a
> > couple of implementation issues that I will hopefully fix up in subsequent
> > patches.
> >
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> > Cc: Nicholas Piggin <npiggin@xxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
> > ---
> > kernel/sched/membarrier.c | 55 +++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 55 insertions(+)
> >
> > diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c
> > index b5add64d9698..3173b063d358 100644
> > --- a/kernel/sched/membarrier.c
> > +++ b/kernel/sched/membarrier.c
> > @@ -7,6 +7,61 @@
> > #include "sched.h"
> >
>
> Precisely describing the orderings is great, not a fan of the style of the
> comment though.

I'm with Nick on that; I can't read it :/ It only makes things more
confusing. If you want precision, English (or any natural language) is
your enemy.

To describe ordering use the diagrams and/or litmus tests.