[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210313150918.GH2577561@casper.infradead.org>
Date: Sat, 13 Mar 2021 15:09:18 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Yu Zhao <yuzhao@...gle.com>
Cc: linux-mm@...ck.org, Alex Shi <alex.shi@...ux.alibaba.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Hillf Danton <hdanton@...a.com>,
Johannes Weiner <hannes@...xchg.org>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Mel Gorman <mgorman@...e.de>, Michal Hocko <mhocko@...e.com>,
Roman Gushchin <guro@...com>, Vlastimil Babka <vbabka@...e.cz>,
Wei Yang <richard.weiyang@...ux.alibaba.com>,
Yang Shi <shy828301@...il.com>,
Ying Huang <ying.huang@...el.com>,
linux-kernel@...r.kernel.org, page-reclaim@...gle.com
Subject: Re: [PATCH v1 01/14] include/linux/memcontrol.h: do not warn in
page_memcg_rcu() if !CONFIG_MEMCG
On Sat, Mar 13, 2021 at 12:57:34AM -0700, Yu Zhao wrote:
> We want to make sure the rcu lock is held while using
> page_memcg_rcu(). But having a WARN_ON_ONCE() in page_memcg_rcu() when
> !CONFIG_MEMCG is superfluous because of the following legit use case:
>
> memcg = lock_page_memcg(page1)
> (rcu_read_lock() if CONFIG_MEMCG=y)
>
> do something to page1
>
> if (page_memcg_rcu(page2) == memcg)
> do something to page2 too as it cannot be migrated away from the
> memcg either.
>
> unlock_page_memcg(page1)
> (rcu_read_unlock() if CONFIG_MEMCG=y)
>
> This patch removes the WARN_ON_ONCE() from page_memcg_rcu() for the
> !CONFIG_MEMCG case.
I think this is wrong. Usually we try to have the same locking
environment no matter what the CONFIG options are, like with
kmap_atomic(). I think lock_page_memcg() should disable RCU even if
CONFIG_MEMCG=n.
Powered by blists - more mailing lists