linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org
Subject: find_swap_entry sparse cleanup
Date: Fri, 6 Apr 2018 15:13:45 -0700	[thread overview]
Message-ID: <ffad6db6-85b1-59b2-bc5e-5492d1c175ac@oracle.com> (raw)


As part of restructuring code for memfd, I want clean up all the
sparse warnings in mm/shmem.c.  Most are straight forward, but I
am not sure about find_swap_entry.  Specifically the code:

	rcu_read_lock();
	radix_tree_for_each_slot(slot, root, &iter, 0) {
		if (*slot == item) {
			found = iter.index;
			break;
		}
		checked++;
		if ((checked % 4096) != 0)
			continue;
		slot = radix_tree_iter_resume(slot, &iter);
		cond_resched_rcu();
	}
	rcu_read_unlock();

The complaint is about that (*slot == item) comparison.

My first thought was to do the radix_tree_deref_slot(),
radix_tree_exception(), radix_tree_deref_retry() thing.
However, I was concerned that swap entries (which this routine
is looking for) are stored as exception entries?  So, perhaps
this should just use rcu_dereference_raw()?

Suggestions would be appreciated.

And, yes I do know that the XArray code would replace all this.
-- 
Mike Kravetz

             reply	other threads:[~2018-04-06 22:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 22:13 Mike Kravetz [this message]
2018-04-07  2:28 ` find_swap_entry sparse cleanup Matthew Wilcox
2018-04-07  2:59   ` Mike Kravetz

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=ffad6db6-85b1-59b2-bc5e-5492d1c175ac@oracle.com \
    --to=mike.kravetz@oracle.com \
    --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;
as well as URLs for NNTP newsgroup(s).