Commit 5b9c98f3 authored by Mike Kravetz's avatar Mike Kravetz Committed by Linus Torvalds
Browse files

mm/shmem: add __rcu annotations and properly deref radix entry

Patch series "restructure memfd code", v4.

This patch (of 3):

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: default avatarMike Kravetz <>
Signed-off-by: default avatarMatthew Wilcox <>
Cc: Hugh Dickins <>
Cc: Andrea Arcangeli <>
Cc: Michal Hocko <>
Cc: Marc-Andr Lureau <>
Cc: David Herrmann <>
Cc: Khalid Aziz <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c0265342
......@@ -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;
......@@ -395,7 +395,7 @@ static bool shmem_confirm_swap(struct address_space *mapping,
/* 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;
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);
if (entry == item) {
found = iter.index;
......@@ -2622,7 +2628,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;
......@@ -2664,7 +2670,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;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment