[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <984ADA76-837B-4B07-88C5-0D82FE8FA9A5@lca.pw>
Date: Tue, 25 Feb 2020 20:48:14 -0500
From: Qian Cai <cai@....pw>
To: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, elver@...gle.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/vmscan: fix data races at kswapd_classzone_idx
> On Feb 25, 2020, at 8:29 PM, Matthew Wilcox <willy@...radead.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.
Powered by blists - more mailing lists