linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: npiggin@gmail.com, david@redhat.com, willy@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: whack now bogus comment in pmd_install() concerning a fence
Date: Wed, 14 Aug 2024 14:16:14 -0700	[thread overview]
Message-ID: <20240814141614.56337d7cd3f0671d8edc7676@linux-foundation.org> (raw)
In-Reply-To: <20240814145256.1683498-1-mjguzik@gmail.com>

On Wed, 14 Aug 2024 16:52:56 +0200 Mateusz Guzik <mjguzik@gmail.com> wrote:

> Commit 362a61ad6119 ("fix SMP data race in pagetable setup vs walking")
> added the following:
> 
> +       smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
> +
>         spin_lock(&mm->page_table_lock);
> 
> However, over the years the fence along with the comment got moved
> around the file, eventually landing in a spot where it is *NOT* followed
> by a lock acquire (or any other operation which might happen to provide
> any fence on a given arch), rendering the comment stale.
> 
> ...
>
> I fully concede I could not be arsed to check if the fence is still
> needed to begin with, I ran into this while looking at something else.
> The comment puzzled me for a minute suggesting pmd_populate has an
> immediate lock acquire inside.
> 
> ...
>
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -436,7 +436,7 @@ void pmd_install(struct mm_struct *mm, pmd_t *pmd, pgtable_t *pte)
>  		 * seen in-order. See the alpha page table accessors for the
>  		 * smp_rmb() barriers in page table walking code.
>  		 */
> -		smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
> +		smp_wmb();
>  		pmd_populate(mm, pmd, *pte);
>  		*pte = NULL;
>  	}

It's best to document all such barriers, so the preferred patch would
be to fix the comment rather than removing it.

And if the barrier now does nothing then of course removing the thing
would be best.

So I'd suggest that the wrong comment be left there, if only to tell
developers why the barrier used to be there!


  reply	other threads:[~2024-08-14 21:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 14:52 Mateusz Guzik
2024-08-14 21:16 ` Andrew Morton [this message]
2024-08-14 21:28   ` Mateusz Guzik

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=20240814141614.56337d7cd3f0671d8edc7676@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mjguzik@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=willy@infradead.org \
    /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