From: Mike Kravetz <mike.kravetz@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org
Subject: Re: find_swap_entry sparse cleanup
Date: Fri, 6 Apr 2018 19:59:18 -0700 [thread overview]
Message-ID: <d82bced0-5f6b-2959-28d2-3a7d900b6f05@oracle.com> (raw)
In-Reply-To: <20180407022849.GA24377@bombadil.infradead.org>
On 04/06/2018 07:28 PM, Matthew Wilcox wrote:
> I'm happy to help clean this up in advance of the XArray code going in ...
>
> This loop is actually buggy in two or three different ways. Here's how
> it should have looked:
>
> @@ -1098,13 +1098,18 @@ static void shmem_evict_inode(struct inode *inode)
> static unsigned long find_swap_entry(struct radix_tree_root *root, void *item)
> {
> struct radix_tree_iter iter;
> - void **slot;
> + void __rcu **slot;
> unsigned long found = -1;
> unsigned int checked = 0;
>
> rcu_read_lock();
> radix_tree_for_each_slot(slot, root, &iter, 0) {
> - if (*slot == item) {
> + void *entry = radix_tree_deref_slot(slot);
> + if (radix_tree_deref_retry(entry)) {
> + slot = radix_tree_iter_retry(&iter);
> + continue;
> + }
> + if (entry == item) {
> found = iter.index;
> break;
> }
>
Thank you! I was worried about searching for swap entries that would
be marked RADIX_TREE_EXCEPTIONAL_ENTRY. Your changes above make perfect
sense. Do you mind if I roll them into a patch that adds all the other
missing __rcu annotations in the file, and add your Signed-off-by?
--
Mike Kravetz
prev parent reply other threads:[~2018-04-07 2:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-06 22:13 find_swap_entry sparse cleanup Mike Kravetz
2018-04-07 2:28 ` Matthew Wilcox
2018-04-07 2:59 ` Mike Kravetz [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=d82bced0-5f6b-2959-28d2-3a7d900b6f05@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).