Skip to content

Commit 9377906

Browse files
Minchan Kimtorvalds
authored andcommitted
mm/page_io.c: annotate refault stalls from swap_readpage
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.org Signed-off-by: Minchan Kim <minchan@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Shakeel Butt <shakeelb@google.com> Cc: Seth Jennings <sjenning@redhat.com> Cc: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dd33d29 commit 9377906

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎mm/page_io.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/writeback.h>
2323
#include <linux/frontswap.h>
2424
#include <linux/blkdev.h>
25+
#include <linux/psi.h>
2526
#include <linux/uio.h>
2627
#include <linux/sched/task.h>
2728
#include <asm/pgtable.h>
@@ -354,10 +355,19 @@ int swap_readpage(struct page *page, bool synchronous)
354355
struct swap_info_struct *sis = page_swap_info(page);
355356
blk_qc_t qc;
356357
struct gendisk *disk;
358+
unsigned long pflags;
357359

358360
VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page);
359361
VM_BUG_ON_PAGE(!PageLocked(page), page);
360362
VM_BUG_ON_PAGE(PageUptodate(page), page);
363+
364+
/*
365+
* Count submission time as memory stall. When the device is congested,
366+
* or the submitting cgroup IO-throttled, submission can be a
367+
* significant part of overall IO time.
368+
*/
369+
psi_memstall_enter(&pflags);
370+
361371
if (frontswap_load(page) == 0) {
362372
SetPageUptodate(page);
363373
unlock_page(page);
@@ -371,7 +381,7 @@ int swap_readpage(struct page *page, bool synchronous)
371381
ret = mapping->a_ops->readpage(swap_file, page);
372382
if (!ret)
373383
count_vm_event(PSWPIN);
374-
return ret;
384+
goto out;
375385
}
376386

377387
ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
@@ -382,7 +392,7 @@ int swap_readpage(struct page *page, bool synchronous)
382392
}
383393

384394
count_vm_event(PSWPIN);
385-
return 0;
395+
goto out;
386396
}
387397

388398
ret = 0;
@@ -418,6 +428,7 @@ int swap_readpage(struct page *page, bool synchronous)
418428
bio_put(bio);
419429

420430
out:
431+
psi_memstall_leave(&pflags);
421432
return ret;
422433
}
423434

0 commit comments

Comments
 (0)