From: Qian Cai <cai@lca.pw>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
elver@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmscan: fix data races at kswapd_classzone_idx
Date: Tue, 25 Feb 2020 20:48:14 -0500 [thread overview]
Message-ID: <984ADA76-837B-4B07-88C5-0D82FE8FA9A5@lca.pw> (raw)
In-Reply-To: <20200226012952.GV24185@bombadil.infradead.org>
> On Feb 25, 2020, at 8:29 PM, Matthew Wilcox <willy@infradead.org> wrote:
>
> On Tue, Feb 25, 2020 at 11:55:26AM -0500, Qian Cai wrote:
>> - if (pgdat->kswapd_classzone_idx == MAX_NR_ZONES)
>> - pgdat->kswapd_classzone_idx = classzone_idx;
>> - else
>> - pgdat->kswapd_classzone_idx = max(pgdat->kswapd_classzone_idx,
>> - classzone_idx);
>> + if (READ_ONCE(pgdat->kswapd_classzone_idx) == MAX_NR_ZONES ||
>> + READ_ONCE(pgdat->kswapd_classzone_idx) < classzone_idx)
>> + WRITE_ONCE(pgdat->kswapd_classzone_idx, classzone_idx);
>> +
>> pgdat->kswapd_order = max(pgdat->kswapd_order, order);
>
> Doesn't this line have the exact same problem you're "solving" above?
Good catch. I missed that.
>
> Also, why would you do this crazy "f(READ_ONCE(x)) || g(READ_ONCE(x))?
> Surely you should be stashing READ_ONCE(x) into a local variable?
Not a bad idea.
>
> And there are a _lot_ of places which access kswapd_classzone_idx
> without a lock. Are you sure this patch is sufficient?
I am not sure, but KCSAN did not complain about other places after running extended
period of testing, so I will look into once other places show up later.
next prev parent reply other threads:[~2020-02-26 1:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 16:55 Qian Cai
2020-02-26 1:29 ` Matthew Wilcox
2020-02-26 1:48 ` Qian Cai [this message]
2020-02-26 2:11 ` Andrew Morton
2020-02-26 2:26 ` Qian Cai
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=984ADA76-837B-4B07-88C5-0D82FE8FA9A5@lca.pw \
--to=cai@lca.pw \
--cc=akpm@linux-foundation.org \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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