LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: "Matthew Wilcox" <willy@infradead.org>,
"Hugh Dickins" <hughd@google.com>,
"Andrea Arcangeli" <aarcange@redhat.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"David Herrmann" <dh.herrmann@gmail.com>,
"Khalid Aziz" <khalid.aziz@oracle.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Mike Kravetz" <mike.kravetz@oracle.com>
Subject: [PATCH v4 1/3] mm/shmem: add __rcu annotations and properly deref radix entry
Date: Sun, 15 Apr 2018 11:21:17 -0700 [thread overview]
Message-ID: <20180415182119.4517-2-mike.kravetz@oracle.com> (raw)
In-Reply-To: <20180415182119.4517-1-mike.kravetz@oracle.com>
In preparation for memfd code restucture, clean up sparse warnings.
Most changes required adding __rcu annotations. The routine
find_swap_entry was modified to properly deference radix tree
entries.
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Matthew Wilcox <willy@infradead.org>
---
mm/shmem.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index b85919243399..c7bad16fe884 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -327,7 +327,7 @@ static int shmem_radix_tree_replace(struct address_space *mapping,
pgoff_t index, void *expected, void *replacement)
{
struct radix_tree_node *node;
- void **pslot;
+ void __rcu **pslot;
void *item;
VM_BUG_ON(!expected);
@@ -395,7 +395,7 @@ static bool shmem_confirm_swap(struct address_space *mapping,
#ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
/* ifdef here to avoid bloating shmem.o when not necessary */
-int shmem_huge __read_mostly;
+static int shmem_huge __read_mostly;
#if defined(CONFIG_SYSFS) || defined(CONFIG_TMPFS)
static int shmem_parse_huge(const char *str)
@@ -682,7 +682,7 @@ unsigned long shmem_partial_swap_usage(struct address_space *mapping,
pgoff_t start, pgoff_t end)
{
struct radix_tree_iter iter;
- void **slot;
+ void __rcu **slot;
struct page *page;
unsigned long swapped = 0;
@@ -1098,13 +1098,19 @@ 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;
}
@@ -2623,7 +2629,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
static void shmem_tag_pins(struct address_space *mapping)
{
struct radix_tree_iter iter;
- void **slot;
+ void __rcu **slot;
pgoff_t start;
struct page *page;
@@ -2665,7 +2671,7 @@ static void shmem_tag_pins(struct address_space *mapping)
static int shmem_wait_for_pins(struct address_space *mapping)
{
struct radix_tree_iter iter;
- void **slot;
+ void __rcu **slot;
pgoff_t start;
struct page *page;
int error, scan;
--
2.13.6
next prev parent reply other threads:[~2018-04-15 18:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-15 18:21 [PATCH v4 0/3] restructure memfd code Mike Kravetz
2018-04-15 18:21 ` Mike Kravetz [this message]
2018-04-15 18:21 ` [PATCH v4 2/3] mm/shmem: update file sealing comments and file checking Mike Kravetz
2018-04-17 23:40 ` Khalid Aziz
2018-04-15 18:21 ` [PATCH v4 3/3] mm: restructure memfd code Mike Kravetz
2018-04-17 23:42 ` Khalid Aziz
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=20180415182119.4517-2-mike.kravetz@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dh.herrmann@gmail.com \
--cc=hughd@google.com \
--cc=khalid.aziz@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcandre.lureau@gmail.com \
--cc=mhocko@kernel.org \
--cc=willy@infradead.org \
--subject='Re: [PATCH v4 1/3] mm/shmem: add __rcu annotations and properly deref radix entry' \
/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
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).