mm: Move lru_to_page to mm.h
Subsystems (11)
PATCH 1/2 mm: Move lru_to_page to mm.h
There are multiple places in the kernel which opencode this helper, this patch moves it to the more generic mm.h header in preparation for using it. No functional changes.
--- include/linux/mm.h | 2 ++ include/linux/mm_inline.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-)
include/linux/mm.h +2 -0
@@ -146,6 +146,8 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ #define PAGE_ALIGNED (addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE) +#define lru_to_page (head) (list_entry((head)->prev, struct page, lru)) +/* * Linux kernel virtual memory manager primitives. * The idea being to have a "virtual" mm in the same way
include/linux/mm_inline.h +0 -3
@@ -124,7 +124,4 @@ static __always_inline enum lru_list page_lru(struct page *page) }return lru; } - -#define lru_to_page (head) (list_entry((head)->prev, struct page, lru)) -#endif
Signature · 1 line
2.17.1
PATCH 2/2 fs: Don't open-code lru_to_page
There are a bunch of filesystems which essentially open-code lru_to_page helper. Change them to using the helper. No functional changes.
---
Since this is a mostly mechanical change I've actually batched all of them in a single patch.
fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)
fs/afs/file.c +3 -2
@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);
@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;for (p = first->lru.prev; p != pages; p = p->prev) {
@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,* page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index; if (add_to_page_cache_lru(page, mapping, index,
fs/btrfs/extent_io.c +1 -1
@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,u64 prev_em_start = (u64)-1 ;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);list_del (&page->lru);
fs/ceph/addr.c +2 -3
@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;u64 off;
@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,if (got)ceph_put_cap_refs (ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page); }
fs/cifs/file.c +2 -1
@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h"
@@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,INIT_LIST_HEAD (tmplist); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* * Lock the page and put it in the cache. Since no one else
fs/ext4/readpage.c +1 -1
@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru);if (add_to_page_cache_lru (page, mapping, page->index,readahead_gfp_mask (mapping)))
fs/ocfs2/aops.c +2 -1
@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h>
@@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,* Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode)) goto out_unlock;
fs/orangefs/inode.c +1 -1
@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,
mm/swap.c +1 -1
@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); }
Signature · 1 line
2.17.1
Re: [PATCH 2/2] fs: Don't open-code lru_to_page
Quoted 2 lines · Nikolay Borisov
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.
I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
Quoted 1 line
Signed-off-by Nikolay Borisov <[email protected]>
Quoted 164 lines
---
Since this is a mostly mechanical change I've actually batched all of them in a single patch.
fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)fs/afs/file.c +3
-2@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;for (p = first->lru.prev; p != pages; p = p->prev) {@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,* page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index; if (add_to_page_cache_lru(page, mapping, index,fs/btrfs/extent_io.c +1
-1@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,u64 prev_em_start = (u64)-1 ;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);list_del (&page->lru);fs/ceph/addr.c +2
-3@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;u64 off;@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,if (got)ceph_put_cap_refs (ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page); }fs/cifs/file.c +2
-1@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h" @@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,INIT_LIST_HEAD (tmplist); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* * Lock the page and put it in the cache. Since no one else fs/ext4/readpage.c +1
-1@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru);if (add_to_page_cache_lru (page, mapping, page->index,readahead_gfp_mask (mapping)))fs/ocfs2/aops.c +2
-1@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h> @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,* Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode)) goto out_unlock;fs/orangefs/inode.c +1
-1@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,mm/swap.c +1
-1@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); }Signature · 1 line
2.17.1
Signature · 2 lines
Michal Hocko SUSE Labs
PATCH 2/2 fs: Don't open-code lru_to_page
Quoted 6 lines · Michal Hocko
Quoted 2 lines · Nikolay Borisov
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
No reason, just didn't know how people would react so that's why I chose to send as two separate.
If I squash them who would be the best person to take them ?
Quoted 170 lines
Quoted 2 lines
Signed-off-by Nikolay Borisov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 164 lines
---
Since this is a mostly mechanical change I've actually batched all of them in a single patch.
fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)fs/afs/file.c +3
-2@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;for (p = first->lru.prev; p != pages; p = p->prev) {@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,* page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index; if (add_to_page_cache_lru(page, mapping, index,fs/btrfs/extent_io.c +1
-1@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,u64 prev_em_start = (u64)-1 ;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);list_del (&page->lru);fs/ceph/addr.c +2
-3@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;u64 off;@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,if (got)ceph_put_cap_refs (ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page); }fs/cifs/file.c +2
-1@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h" @@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,INIT_LIST_HEAD (tmplist); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* * Lock the page and put it in the cache. Since no one else fs/ext4/readpage.c +1
-1@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru);if (add_to_page_cache_lru (page, mapping, page->index,readahead_gfp_mask (mapping)))fs/ocfs2/aops.c +2
-1@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h> @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,* Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode)) goto out_unlock;fs/orangefs/inode.c +1
-1@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,mm/swap.c +1
-1@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); }Signature · 1 line
2.17.1
Re: [PATCH 2/2] fs: Don't open-code lru_to_page
Quoted 4 lines · Nikolay Borisov
Quoted 1 line · Michal Hocko
On Thu 29-11-18 09:52:57, Nikolay Borisov wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
No reason, just didn't know how people would react so that's why I chose to send as two separate.
This is a matter of taste I guess. But I usually prefer to have callers along with a new helper in a single patch. This is not a new helper per-se but doing it the same way seems reasonable to me. Not that I would insist of course. You can use my ack for both patch in case you decide to leave it as is.
Quoted 1 line
If I squash them who would be the best person to take them ?
Sounds like a mmotm material to me.
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH 2/2] fs: Don't open-code lru_to_page
In reply to Nikolay BorisovQuoted 4 lines · Nikolay Borisov
Quoted 1 line · Michal Hocko
On Thu 29-11-18 09:52:57, Nikolay Borisov wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
No reason, just didn't know how people would react so that's why I chose to send as two separate.
I'm with Michal on this, a single patch seems better here. Yet, for either way:
Quoted 173 lines
If I squash them who would be the best person to take them ?
Quoted 170 lines
Quoted 2 lines
Signed-off-by Nikolay Borisov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 164 lines
---
Since this is a mostly mechanical change I've actually batched all of them in a single patch.
fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)fs/afs/file.c +3
-2@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;for (p = first->lru.prev; p != pages; p = p->prev) {@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,* page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index; if (add_to_page_cache_lru(page, mapping, index,fs/btrfs/extent_io.c +1
-1@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,u64 prev_em_start = (u64)-1 ;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);list_del (&page->lru);fs/ceph/addr.c +2
-3@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;u64 off;@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,if (got)ceph_put_cap_refs (ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page); }fs/cifs/file.c +2
-1@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h" @@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,INIT_LIST_HEAD (tmplist); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* * Lock the page and put it in the cache. Since no one else fs/ext4/readpage.c +1
-1@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru);if (add_to_page_cache_lru (page, mapping, page->index,readahead_gfp_mask (mapping)))fs/ocfs2/aops.c +2
-1@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h> @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,* Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode)) goto out_unlock;fs/orangefs/inode.c +1
-1@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,mm/swap.c +1
-1@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); }Signature · 1 line
2.17.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 2/2] fs: Don't open-code lru_to_page
In reply to Nikolay BorisovQuoted 11 lines
Quoted 6 lines
Quoted 3 lines
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
No reason, just didn't know how people would react so that's why I chose to send as two separate.
If I squash them who would be the best person to take them ?
For squashed version:
Quoted 182 lines
Quoted 180 lines
Quoted 3 lines
Signed-off-by Nikolay Borisov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 173 lines
---
Since this is a mostly mechanical change I've actually batched all of them in
a single patch.fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)fs/afs/file.c +2
-1@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, structaddress_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;fs/afs/file.c +1
-1for (p = first->lru.prev; p != pages; p = p->prev) {@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, structaddress_space *mapping, * page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index;fs/afs/file.c +0
-0if (add_to_page_cache_lru(page, mapping, index,fs/btrfs/extent_io.c +1
-1@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping,struct list_head *pages, u64 prev_em_start = (u64)-1;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);fs/btrfs/extent_io.c +0
-0list_del (&page->lru);fs/ceph/addr.c +1
-1@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, structceph_rw_context *rw_ctx, struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;fs/ceph/addr.c +1
-2u64 off;@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, if (got) ceph_put_cap_refs(ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page);fs/ceph/addr.c +0
-0}fs/cifs/file.c +2
-1@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h" @@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping,struct list_head *page_list,INIT_LIST_HEAD (tmplist ); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* fs/cifs/file.c +0
-0* Lock the page and put it in the cache. Since no one else fs/ext4/readpage.c +1
-1@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru); if (add_to_page_cache_lru(page, mapping, page->index,fs/ext4/readpage.c +0
-0readahead_gfp_mask(mapping)))fs/ocfs2/aops.c +2
-1@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h> @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, structaddress_space *mapping, * Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode))fs/ocfs2/aops.c +0
-0goto out_unlock;fs/orangefs/inode.c +1
-1@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,mm/swap.c +1
-2@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); } --2.17.1
David Hildenbrand
Reviewed-byRe: [PATCH 2/2] fs: Don't open-code lru_to_page
In reply to Michal HockoQuoted 10 lines · Michal Hocko
Quoted 2 lines · Nikolay Borisov
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.I would just squash the two into a single patch. It makes the first one more obvious. Or is there any reason to have them separate?
Quoted 1 line
Signed-off-by Nikolay Borisov <[email protected]>Acked-by Michal Hocko <[email protected]>
mm_inline.h is 99.9% about lru and there is barely anything about lru in mm.h. However this simple macro seems to differ from the other inlined functions.
So to the squashed patch
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH 2/2] fs: Don't open-code lru_to_page
In reply to Nikolay BorisovQuoted 77 lines · Nikolay Borisov
There are a bunch of filesystems which essentially open-code
lru_to_pagehelper. Change them to using the helper. No functional changes.Signed-off-by Nikolay Borisov <[email protected]>---
Since this is a mostly mechanical change I've actually batched all of them in a single patch.
fs/afs/file.c | 5 +++-- fs/btrfs/extent_io.c | 2 +- fs/ceph/addr.c | 5 ++--- fs/cifs/file.c | 3 ++- fs/ext4/readpage.c | 2 +- fs/ocfs2/aops.c | 3 ++- fs/orangefs/inode.c | 2 +- mm/swap.c | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-)fs/afs/file.c +3
-2@@ -17,6 +17,7 @@#include <linux/writeback.h> #include <linux/gfp.h> #include <linux/task_io_accounting_ops.h> +#include <linux/mm.h> #include "internal.h" static int afs_file_mmap (struct file *file,struct vm_area_struct *vma);@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,/* Count the number of contiguous pages at the front of the list. Note * that the list goes prev-wards rather than next-wards. */ - first = list_entry(pages->prev, struct page, lru); + first =lru_to_page (pages); index = first->index +1 ; n =1 ;for (p = first->lru.prev; p != pages; p = p->prev) {@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,* page at the end of the file. */ do { - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); index = page->index; if (add_to_page_cache_lru(page, mapping, index,fs/btrfs/extent_io.c +1
-1@@ -4104,7 +4104,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,u64 prev_em_start = (u64)-1 ;for (page_idx =0 ; page_idx < nr_pages; page_idx++) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);prefetchw (&page->flags);list_del (&page->lru);fs/ceph/addr.c +1
-1@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,struct ceph_osd_client *osdc = &ceph_inode_to_client (inode)->client->osdc;struct ceph_inode_info *ci =ceph_inode (inode); - struct page *page = list_entry(page_list->prev, struct page, lru); +struct page *page =lru_to_page (page_list);struct ceph_vino vino;struct ceph_osd_request *req;u64 off;
fs/ceph/addr.c static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, · line 339
Quoted 9 lines
fs/ceph/addr.c +1
-2@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,if (got)ceph_put_cap_refs (ci, got);while (!list_empty (page_list)) { - page =list_entry (page_list->prev, - struct page, lru); + page =lru_to_page (page_list);list_del (&page->lru);put_page (page); }
For the ceph patch
Quoted 84 lines
fs/cifs/file.c +2
-1@@ -33,6 +33,7 @@#include <linux/mount.h> #include <linux/slab.h> #include <linux/swap.h> +#include <linux/mm.h> #include <asm/div64.h> #include "cifsfs.h" #include "cifspdu.h" @@ -3975,7 +3976,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,INIT_LIST_HEAD (tmplist); - page = list_entry(page_list->prev, struct page, lru); + page =lru_to_page (page_list);/* * Lock the page and put it in the cache. Since no one else fs/ext4/readpage.c +1
-1@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,prefetchw (&page->flags);if (pages) { - page = list_entry(pages->prev, struct page, lru); + page =lru_to_page (pages);list_del (&page->lru);if (add_to_page_cache_lru (page, mapping, page->index,readahead_gfp_mask (mapping)))fs/ocfs2/aops.c +2
-1@@ -30,6 +30,7 @@#include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> +#include <linux/mm.h> #include <cluster/masklog.h> @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,* Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ - last = list_entry(pages->prev, struct page, lru); + last =lru_to_page (pages); start = (loff_t )last->index <<PAGE_SHIFT ;if (start >=i_size_read (inode)) goto out_unlock;fs/orangefs/inode.c +1
-1@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, for (page_idx = 0; page_idx < nr_pages; page_idx++) { struct page *page; - page = list_entry(pages->prev, struct page, lru); + page = lru_to_page(pages); list_del(&page->lru); if (!add_to_page_cache(page, mapping,mm/swap.c +1
-2@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)while (!list_empty (pages)) {struct page *victim; - victim = list_entry(pages->prev, struct page, lru); + victim =lru_to_page (pages);list_del (&victim->lru);put_page (victim); } --2.17.1