[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y6tNnQvGGV+JVgC7@casper.infradead.org>
Date: Tue, 27 Dec 2022 19:55:09 +0000
From: Matthew Wilcox <willy@...radead.org>
To: SeongJae Park <sj@...nel.org>
Cc: akpm@...ux-foundation.org, alexander.h.duyck@...ux.intel.com,
paulmck@...nel.org, linux-mm@...ck.org, rcu@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/page_reporting: replace rcu_access_pointer() with
rcu_dereference_protected()
On Tue, Dec 27, 2022 at 07:21:58PM +0000, SeongJae Park wrote:
> +++ b/mm/page_reporting.c
> @@ -356,7 +356,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)
> mutex_lock(&page_reporting_mutex);
>
> /* nothing to do if already in use */
> - if (rcu_access_pointer(pr_dev_info)) {
> + if (rcu_dereference_protected(pr_dev_info, true)) {
Pretty sure that passing a bare 'true' is an antipattern.
Instead, document _what_ lock protects us, ie:
if (rcu_dereference_protected(pr_dev_info,
lockdep_is_held(&page_reporting_mutex))) {
Obviously, we took it just one line up, but if code moves around, it
may save us.
Powered by blists - more mailing lists