linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: yanghui <yanghui.def@bytedance.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/mempolicy: fix a race between offset_il_node and mpol_rebind_task
Date: Sat, 14 Aug 2021 10:37:23 +0800	[thread overview]
Message-ID: <CAMZfGtXi3k_nFoLo+2LJCd2zJCr+326qDOAsAz610jpaKMqO9w@mail.gmail.com> (raw)
In-Reply-To: <YRakjlObxOOYgfCw@casper.infradead.org>

On Sat, Aug 14, 2021 at 12:58 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sat, Aug 14, 2021 at 12:40:53AM +0800, yanghui wrote:
> > +++ b/mm/mempolicy.c
> > @@ -193,7 +193,7 @@ static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes)
> >  {
> >       if (nodes_empty(*nodes))
> >               return -EINVAL;
> > -     pol->nodes = *nodes;
> > +     WRITE_ONCE(pol->nodes, *nodes);
>
> typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
>
> If MAX_NUMNODES is large enough, is WRITE_ONCE going to work?  It could
> be 128 bits, and few architectures have an atomic 128-bit store
> instruction.
>

Hi Matthew,

In my memory, the WRITE_ONCE will become memcpy if
the size is greater than sizeof(long). But I found that it didn't
support the size over sizeof(long) nowadays. So you are
right. It doesn't work when MAX_NUMNODES is large enough.

If we don't use WRITE_ONCE/READ_ONCE here, it seems
like no problem. At least we can sure offset_il_node returns
a valid node id. What is your opinion about this fix?

Thanks,
Muchun


  reply	other threads:[~2021-08-14  2:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 16:40 yanghui
2021-08-13 16:57 ` Matthew Wilcox
2021-08-14  2:37   ` Muchun Song [this message]
2021-08-14  3:11     ` Matthew Wilcox
2021-08-13 23:16 ` kernel test robot
2021-08-14  1:35   ` Nathan Chancellor
2021-08-14  1:40 ` kernel test robot

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=CAMZfGtXi3k_nFoLo+2LJCd2zJCr+326qDOAsAz610jpaKMqO9w@mail.gmail.com \
    --to=songmuchun@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    --cc=yanghui.def@bytedance.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