Skip to contentSkip to conversation

mm/madvise: fix WILLNEED on SHM/ANON to actually do something

PATCH In review David Herrmann 2 participants 3 messages May 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/madvise: fix WILLNEED on SHM/ANON to actually do something

Currently, madvise(MADV_WILLNEED) on shmem with swap enabled is a no-op. Problem is, we use find_get_page() to lookup shmem pages in the given range. However, what we're actually interested in is swapped-out pages. Therefore, our current code is a no-op:

    page = find_get_page(mapping, index);
    if (!radix_tree_exceptional_entry(page))
        bail-out;

find_get_page() never returns exceptional entries. Fix this by using find_get_entry(). This was probably meant to be used right from the beginning.

---
 mm/madvise.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -1
index 539eeb9..a402f8f 100644
@@ -195,7 +195,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
 	for (; start < end; start += PAGE_SIZE) {
 		index = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
 
-		page = find_get_page(mapping, index);
+		page = find_get_entry(mapping, index);
 		if (!radix_tree_exceptional_entry(page)) {
 			if (page)
 				page_cache_release(page);
Signature · 7 lines
1.9.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

mm/madvise.c static void force_shm_swapin_readahead(struct vm_area_struct *vma, · line 201

Quoted 13 lines · David Herrmann
mm/madvise.c +1 -1
index 539eeb9..a402f8f 100644
@@ -195,7 +195,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
 	for (; start < end; start += PAGE_SIZE) {
 		index = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
 
-		page = find_get_page(mapping, index);
+		page = find_get_entry(mapping, index);
 		if (!radix_tree_exceptional_entry(page)) {
 			if (page)
 				page_cache_release(page);

This is already in -mm from Johannes, see
http://marc.info/?l=linux-kernel&m=139998616712729. Check out
http://www.ozlabs.org/~akpm/mmotm/ for this kernel.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Hi

Quoted 10 lines · David Rientjes
Quoted 8 lines · David Herrmann
mm/madvise.c +0 -0
index 539eeb9..a402f8f 100644
@@ -195,7 +195,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
      for (; start < end; start += PAGE_SIZE) {
              index = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
 
Quoted 9 lines

mm/madvise.c static void force_shm_swapin_readahead(struct vm_area_struct *vma, · line 201

Quoted 5 lines
mm/madvise.c +1 -1
-             page = find_get_page(mapping, index);
+             page = find_get_entry(mapping, index);
              if (!radix_tree_exceptional_entry(page)) {
                      if (page)
                              page_cache_release(page);

This is already in -mm from Johannes, see
http://marc.info/?l=linux-kernel&m=139998616712729. Check out
http://www.ozlabs.org/~akpm/mmotm/ for this kernel.

Didn't check -mm, sorry. Thanks for the links!
David

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>