提交 cdcf8a43 编写于 作者: M Minchan Kim 提交者: zhongjiang-ali

mm/page_io.c: annotate refault stalls from swap_readpage

task #28327019

commit 937790699be9c8100e5358625e7dfa8b32bd33f2 upstream

If a block device supports rw_page operation, it doesn't submit bios so
the annotation in submit_bio() for refault stall doesn't work.  It
happens with zram in android, especially swap read path which could
consume CPU cycle for decompress.  It is also a problem for zswap which
uses frontswap.

Annotate swap_readpage() to account the synchronous IO overhead to
prevent underreport memory pressure.

[akpm@linux-foundation.org: add comment, per Johannes]
Link: http://lkml.kernel.org/r/20191010152134.38545-1-minchan@kernel.orgSigned-off-by: NMinchan Kim <minchan@google.com>
Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: NShakeel Butt <shakeelb@google.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: NXunlei Pang <xlpang@linux.alibaba.com>
Signed-off-by: Nzhongjiang-ali <zhongjiang-ali@linux.alibaba.com>
上级 e7b88a8a
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/frontswap.h> #include <linux/frontswap.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/psi.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/sched/task.h> #include <linux/sched/task.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -355,10 +356,19 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -355,10 +356,19 @@ int swap_readpage(struct page *page, bool synchronous)
struct swap_info_struct *sis = page_swap_info(page); struct swap_info_struct *sis = page_swap_info(page);
blk_qc_t qc; blk_qc_t qc;
struct gendisk *disk; struct gendisk *disk;
unsigned long pflags;
VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page); VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page);
VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_PAGE(PageUptodate(page), page); VM_BUG_ON_PAGE(PageUptodate(page), page);
/*
* Count submission time as memory stall. When the device is congested,
* or the submitting cgroup IO-throttled, submission can be a
* significant part of overall IO time.
*/
psi_memstall_enter(&pflags);
if (frontswap_load(page) == 0) { if (frontswap_load(page) == 0) {
SetPageUptodate(page); SetPageUptodate(page);
unlock_page(page); unlock_page(page);
...@@ -372,7 +382,7 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -372,7 +382,7 @@ int swap_readpage(struct page *page, bool synchronous)
ret = mapping->a_ops->readpage(swap_file, page); ret = mapping->a_ops->readpage(swap_file, page);
if (!ret) if (!ret)
count_vm_event(PSWPIN); count_vm_event(PSWPIN);
return ret; goto out;
} }
ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
...@@ -383,7 +393,7 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -383,7 +393,7 @@ int swap_readpage(struct page *page, bool synchronous)
} }
count_vm_event(PSWPIN); count_vm_event(PSWPIN);
return 0; goto out;
} }
ret = 0; ret = 0;
...@@ -416,6 +426,7 @@ int swap_readpage(struct page *page, bool synchronous) ...@@ -416,6 +426,7 @@ int swap_readpage(struct page *page, bool synchronous)
bio_put(bio); bio_put(bio);
out: out:
psi_memstall_leave(&pflags);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册