linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: SeongJae Park <sj@kernel.org>,
	akpm@linux-foundation.org, alexander.h.duyck@linux.intel.com,
	paulmck@kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/page_reporting: replace rcu_access_pointer() with rcu_dereference_protected()
Date: Tue, 27 Dec 2022 19:56:59 +0000	[thread overview]
Message-ID: <20221227195659.2876-1-sj@kernel.org> (raw)
In-Reply-To: <Y6tNnQvGGV+JVgC7@casper.infradead.org>

On Tue, 27 Dec 2022 19:55:09 +0000 Matthew Wilcox <willy@infradead.org> wrote:

> 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.

Good point, agreed.  Will do so in the next version.


Thanks,
SJ


      reply	other threads:[~2022-12-27 19:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 19:21 [PATCH] mm/page_reporting: replace rcu_access_pointer() with rcu_dereference_protected() SeongJae Park
2022-12-27 19:55 ` Matthew Wilcox
2022-12-27 19:56   ` SeongJae Park [this message]

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=20221227195659.2876-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.h.duyck@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).