mm: refactor readahead defines in mm.h
authorNikolay Borisov <nborisov@suse.com>
Tue, 12 Mar 2019 06:28:13 +0000 (23:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 12 Mar 2019 17:04:01 +0000 (10:04 -0700)
All users of VM_MAX_READAHEAD actually convert it to kbytes and then to
pages. Define the macro explicitly as (SZ_128K / PAGE_SIZE). This
simplifies the expression in every filesystem. Also rename the macro to
VM_READAHEAD_PAGES to properly convey its meaning. Finally remove unused
VM_MIN_READAHEAD

[akpm@linux-foundation.org: fix fs/io_uring.c, per Stephen]
Link: http://lkml.kernel.org/r/20181221144053.24318-1-nborisov@suse.com
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
block/blk-core.c
fs/9p/vfs_super.c
fs/afs/super.c
fs/btrfs/disk-io.c
fs/fuse/inode.c
fs/io_uring.c
include/linux/mm.h

index 6b78ec56a4f2daef624edb1bb025a76aa3520b52..4673ebe4225534dc9965089ba76ad127963dcb0f 100644 (file)
@@ -500,8 +500,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
        if (!q->stats)
                goto fail_stats;
 
-       q->backing_dev_info->ra_pages =
-                       (VM_MAX_READAHEAD * 1024) / PAGE_SIZE;
+       q->backing_dev_info->ra_pages = VM_READAHEAD_PAGES;
        q->backing_dev_info->capabilities = BDI_CAP_CGROUP_WRITEBACK;
        q->backing_dev_info->name = "block";
        q->node = node_id;
index 48ce50484e80e280990dc822bf3e833025cbbc10..10d3bd3f534bce3a40b780d176fdb95ed4e0a772 100644 (file)
@@ -92,7 +92,7 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
                return ret;
 
        if (v9ses->cache)
-               sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024)/PAGE_SIZE;
+               sb->s_bdi->ra_pages = VM_READAHEAD_PAGES;
 
        sb->s_flags |= SB_ACTIVE | SB_DIRSYNC;
        if (!v9ses->cache)
index dcd07fe99871b9b38541293b164ac1cf8328a005..e684f6769b1510796d31f3f80ec15724f17e3f49 100644 (file)
@@ -399,7 +399,7 @@ static int afs_fill_super(struct super_block *sb,
        ret = super_setup_bdi(sb);
        if (ret)
                return ret;
-       sb->s_bdi->ra_pages     = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+       sb->s_bdi->ra_pages     = VM_READAHEAD_PAGES;
 
        /* allocate the root inode and dentry */
        if (as->dyn_root) {
index f0cdb53f3e2dc86f0dee6080d3b719482214170d..6fe9197f6ee44c54a726435da5a83ac4a7490ac1 100644 (file)
@@ -2958,7 +2958,7 @@ int open_ctree(struct super_block *sb,
        sb->s_bdi->congested_fn = btrfs_congested_fn;
        sb->s_bdi->congested_data = fs_info;
        sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
-       sb->s_bdi->ra_pages = VM_MAX_READAHEAD * SZ_1K / PAGE_SIZE;
+       sb->s_bdi->ra_pages = VM_READAHEAD_PAGES;
        sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
        sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
 
index c2d4099429be0d73c32c87a82dc1a939e89d009b..16750ed591aea4a0954a72eaa5ca05b09818b3a0 100644 (file)
@@ -1010,7 +1010,7 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)
        if (err)
                return err;
 
-       sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_SIZE;
+       sb->s_bdi->ra_pages = VM_READAHEAD_PAGES;
        /* fuse does it's own writeback accounting */
        sb->s_bdi->capabilities = BDI_CAP_NO_ACCT_WB | BDI_CAP_STRICTLIMIT;
 
index 5d99376d2369c219e372a847adcd8d12d150341f..c88088d92613595eecf6f1119a2c53f0b63bab27 100644 (file)
@@ -923,7 +923,7 @@ static void io_async_list_note(int rw, struct io_kiocb *req, size_t len)
                /* Use 8x RA size as a decent limiter for both reads/writes */
                max_pages = filp->f_ra.ra_pages;
                if (!max_pages)
-                       max_pages = VM_MAX_READAHEAD >> (PAGE_SHIFT - 10);
+                       max_pages = VM_READAHEAD_PAGES;
                max_pages *= 8;
 
                /* If max pages are exceeded, reset the state */
index 5801ee849f36729c0357bdf5e29b85f63a2830a9..76769749b5a5d546daf7f7513318ad65a494da4c 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/page_ref.h>
 #include <linux/memremap.h>
 #include <linux/overflow.h>
+#include <linux/sizes.h>
 
 struct mempolicy;
 struct anon_vma;
@@ -2402,8 +2403,7 @@ int __must_check write_one_page(struct page *page);
 void task_dirty_inc(struct task_struct *tsk);
 
 /* readahead.c */
-#define VM_MAX_READAHEAD       128     /* kbytes */
-#define VM_MIN_READAHEAD       16      /* kbytes (includes current page) */
+#define VM_READAHEAD_PAGES     (SZ_128K / PAGE_SIZE)
 
 int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
                        pgoff_t offset, unsigned long nr_to_read);