2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* linux/mm/page_io.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
|
|
|
|
*
|
|
|
|
* Swap reorganised 29.12.95,
|
|
|
|
* Asynchronous swapping added 30.12.95. Stephen Tweedie
|
|
|
|
* Removed race in async swapping. 14.4.1996. Bruno Haible
|
|
|
|
* Add swap of shared pages through the page cache. 20.2.1998. Stephen Tweedie
|
|
|
|
* Always use brw_page, life becomes simpler. 12 May 1998 Eric Biederman
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/gfp.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/swap.h>
|
|
|
|
#include <linux/bio.h>
|
|
|
|
#include <linux/swapops.h>
|
2012-08-01 06:44:55 +07:00
|
|
|
#include <linux/buffer_head.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/writeback.h>
|
2012-04-10 06:08:06 +07:00
|
|
|
#include <linux/frontswap.h>
|
2013-07-04 05:01:24 +07:00
|
|
|
#include <linux/blkdev.h>
|
2015-02-22 23:58:50 +07:00
|
|
|
#include <linux/uio.h>
|
2017-08-03 03:32:09 +07:00
|
|
|
#include <linux/sched/task.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
|
2009-12-15 08:58:40 +07:00
|
|
|
static struct bio *get_swap_bio(gfp_t gfp_flags,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct page *page, bio_end_io_t end_io)
|
|
|
|
{
|
2017-09-07 06:22:30 +07:00
|
|
|
int i, nr = hpage_nr_pages(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct bio *bio;
|
|
|
|
|
2017-09-07 06:22:30 +07:00
|
|
|
bio = bio_alloc(gfp_flags, nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bio) {
|
2017-08-24 00:10:32 +07:00
|
|
|
struct block_device *bdev;
|
|
|
|
|
|
|
|
bio->bi_iter.bi_sector = map_swap_page(page, &bdev);
|
|
|
|
bio_set_dev(bio, bdev);
|
2013-10-12 05:44:27 +07:00
|
|
|
bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
|
2005-04-17 05:20:36 +07:00
|
|
|
bio->bi_end_io = end_io;
|
2014-12-22 18:48:42 +07:00
|
|
|
|
2017-09-07 06:22:30 +07:00
|
|
|
for (i = 0; i < nr; i++)
|
|
|
|
bio_add_page(bio, page + i, PAGE_SIZE, 0);
|
|
|
|
VM_BUG_ON(bio->bi_iter.bi_size != PAGE_SIZE * nr);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
return bio;
|
|
|
|
}
|
|
|
|
|
2015-07-20 20:29:37 +07:00
|
|
|
void end_swap_bio_write(struct bio *bio)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct page *page = bio->bi_io_vec[0].bv_page;
|
|
|
|
|
2017-06-03 14:38:06 +07:00
|
|
|
if (bio->bi_status) {
|
2005-04-17 05:20:36 +07:00
|
|
|
SetPageError(page);
|
2006-09-26 13:31:26 +07:00
|
|
|
/*
|
|
|
|
* We failed to write the page out to swap-space.
|
|
|
|
* Re-dirty the page in order to avoid it being reclaimed.
|
|
|
|
* Also print a dire warning that things will go BAD (tm)
|
|
|
|
* very quickly.
|
|
|
|
*
|
|
|
|
* Also clear PG_reclaim to avoid rotate_reclaimable_page()
|
|
|
|
*/
|
|
|
|
set_page_dirty(page);
|
2016-03-18 04:19:50 +07:00
|
|
|
pr_alert("Write-error on swap-device (%u:%u:%llu)\n",
|
2017-08-24 00:10:32 +07:00
|
|
|
MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
|
2016-03-18 04:19:50 +07:00
|
|
|
(unsigned long long)bio->bi_iter.bi_sector);
|
2006-09-26 13:31:26 +07:00
|
|
|
ClearPageReclaim(page);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
end_page_writeback(page);
|
|
|
|
bio_put(bio);
|
|
|
|
}
|
|
|
|
|
2016-03-23 04:24:36 +07:00
|
|
|
static void swap_slot_free_notify(struct page *page)
|
|
|
|
{
|
|
|
|
struct swap_info_struct *sis;
|
|
|
|
struct gendisk *disk;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is no guarantee that the page is in swap cache - the software
|
|
|
|
* suspend code (at least) uses end_swap_bio_read() against a non-
|
|
|
|
* swapcache page. So we must check PG_swapcache before proceeding with
|
|
|
|
* this optimization.
|
|
|
|
*/
|
|
|
|
if (unlikely(!PageSwapCache(page)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sis = page_swap_info(page);
|
|
|
|
if (!(sis->flags & SWP_BLKDEV))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The swap subsystem performs lazy swap slot freeing,
|
|
|
|
* expecting that the page will be swapped out again.
|
|
|
|
* So we can avoid an unnecessary write if the page
|
|
|
|
* isn't redirtied.
|
|
|
|
* This is good for real swap storage because we can
|
|
|
|
* reduce unnecessary I/O and enhance wear-leveling
|
|
|
|
* if an SSD is used as the as swap device.
|
|
|
|
* But if in-memory swap device (eg zram) is used,
|
|
|
|
* this causes a duplicated copy between uncompressed
|
|
|
|
* data in VM-owned memory and compressed data in
|
|
|
|
* zram-owned memory. So let's free zram-owned memory
|
|
|
|
* and make the VM-owned decompressed page *dirty*,
|
|
|
|
* so the page should be swapped out somewhere again if
|
|
|
|
* we again wish to reclaim it.
|
|
|
|
*/
|
|
|
|
disk = sis->bdev->bd_disk;
|
|
|
|
if (disk->fops->swap_slot_free_notify) {
|
|
|
|
swp_entry_t entry;
|
|
|
|
unsigned long offset;
|
|
|
|
|
|
|
|
entry.val = page_private(page);
|
|
|
|
offset = swp_offset(entry);
|
|
|
|
|
|
|
|
SetPageDirty(page);
|
|
|
|
disk->fops->swap_slot_free_notify(sis->bdev,
|
|
|
|
offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-20 20:29:37 +07:00
|
|
|
static void end_swap_bio_read(struct bio *bio)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct page *page = bio->bi_io_vec[0].bv_page;
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
struct task_struct *waiter = bio->bi_private;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-06-03 14:38:06 +07:00
|
|
|
if (bio->bi_status) {
|
2005-04-17 05:20:36 +07:00
|
|
|
SetPageError(page);
|
|
|
|
ClearPageUptodate(page);
|
2016-03-18 04:19:50 +07:00
|
|
|
pr_alert("Read-error on swap-device (%u:%u:%llu)\n",
|
2017-08-24 00:10:32 +07:00
|
|
|
MAJOR(bio_dev(bio)), MINOR(bio_dev(bio)),
|
2016-03-18 04:19:50 +07:00
|
|
|
(unsigned long long)bio->bi_iter.bi_sector);
|
2013-07-04 05:01:24 +07:00
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2013-07-04 05:01:24 +07:00
|
|
|
|
|
|
|
SetPageUptodate(page);
|
2016-03-23 04:24:36 +07:00
|
|
|
swap_slot_free_notify(page);
|
2013-07-04 05:01:24 +07:00
|
|
|
out:
|
2005-04-17 05:20:36 +07:00
|
|
|
unlock_page(page);
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
WRITE_ONCE(bio->bi_private, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
bio_put(bio);
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
wake_up_process(waiter);
|
2017-08-03 03:32:09 +07:00
|
|
|
put_task_struct(waiter);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:44:57 +07:00
|
|
|
int generic_swapfile_activate(struct swap_info_struct *sis,
|
|
|
|
struct file *swap_file,
|
|
|
|
sector_t *span)
|
|
|
|
{
|
|
|
|
struct address_space *mapping = swap_file->f_mapping;
|
|
|
|
struct inode *inode = mapping->host;
|
|
|
|
unsigned blocks_per_page;
|
|
|
|
unsigned long page_no;
|
|
|
|
unsigned blkbits;
|
|
|
|
sector_t probe_block;
|
|
|
|
sector_t last_block;
|
|
|
|
sector_t lowest_block = -1;
|
|
|
|
sector_t highest_block = 0;
|
|
|
|
int nr_extents = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
blkbits = inode->i_blkbits;
|
|
|
|
blocks_per_page = PAGE_SIZE >> blkbits;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map all the blocks into the extent list. This code doesn't try
|
|
|
|
* to be very smart.
|
|
|
|
*/
|
|
|
|
probe_block = 0;
|
|
|
|
page_no = 0;
|
|
|
|
last_block = i_size_read(inode) >> blkbits;
|
|
|
|
while ((probe_block + blocks_per_page) <= last_block &&
|
|
|
|
page_no < sis->max) {
|
|
|
|
unsigned block_in_page;
|
|
|
|
sector_t first_block;
|
|
|
|
|
2016-07-29 05:48:47 +07:00
|
|
|
cond_resched();
|
|
|
|
|
2012-08-01 06:44:57 +07:00
|
|
|
first_block = bmap(inode, probe_block);
|
|
|
|
if (first_block == 0)
|
|
|
|
goto bad_bmap;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It must be PAGE_SIZE aligned on-disk
|
|
|
|
*/
|
|
|
|
if (first_block & (blocks_per_page - 1)) {
|
|
|
|
probe_block++;
|
|
|
|
goto reprobe;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (block_in_page = 1; block_in_page < blocks_per_page;
|
|
|
|
block_in_page++) {
|
|
|
|
sector_t block;
|
|
|
|
|
|
|
|
block = bmap(inode, probe_block + block_in_page);
|
|
|
|
if (block == 0)
|
|
|
|
goto bad_bmap;
|
|
|
|
if (block != first_block + block_in_page) {
|
|
|
|
/* Discontiguity */
|
|
|
|
probe_block++;
|
|
|
|
goto reprobe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
first_block >>= (PAGE_SHIFT - blkbits);
|
|
|
|
if (page_no) { /* exclude the header page */
|
|
|
|
if (first_block < lowest_block)
|
|
|
|
lowest_block = first_block;
|
|
|
|
if (first_block > highest_block)
|
|
|
|
highest_block = first_block;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks
|
|
|
|
*/
|
|
|
|
ret = add_swap_extent(sis, page_no, 1, first_block);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
nr_extents += ret;
|
|
|
|
page_no++;
|
|
|
|
probe_block += blocks_per_page;
|
|
|
|
reprobe:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ret = nr_extents;
|
|
|
|
*span = 1 + highest_block - lowest_block;
|
|
|
|
if (page_no == 0)
|
|
|
|
page_no = 1; /* force Empty message */
|
|
|
|
sis->max = page_no;
|
|
|
|
sis->pages = page_no - 1;
|
|
|
|
sis->highest_bit = page_no - 1;
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
bad_bmap:
|
2016-03-18 04:19:50 +07:00
|
|
|
pr_err("swapon: swapfile has holes\n");
|
2012-08-01 06:44:57 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* We may have stale swap cache pages in memory: notice
|
|
|
|
* them here and get rid of the unnecessary final write.
|
|
|
|
*/
|
|
|
|
int swap_writepage(struct page *page, struct writeback_control *wbc)
|
|
|
|
{
|
2013-04-30 05:08:34 +07:00
|
|
|
int ret = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-01-07 05:39:36 +07:00
|
|
|
if (try_to_free_swap(page)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
unlock_page(page);
|
|
|
|
goto out;
|
|
|
|
}
|
2012-05-15 22:32:15 +07:00
|
|
|
if (frontswap_store(page) == 0) {
|
2012-04-10 06:08:06 +07:00
|
|
|
set_page_writeback(page);
|
|
|
|
unlock_page(page);
|
|
|
|
end_page_writeback(page);
|
|
|
|
goto out;
|
|
|
|
}
|
2013-04-30 05:08:35 +07:00
|
|
|
ret = __swap_writepage(page, wbc, end_swap_bio_write);
|
2013-04-30 05:08:34 +07:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:07:48 +07:00
|
|
|
static sector_t swap_page_sector(struct page *page)
|
|
|
|
{
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
return (sector_t)__page_file_index(page) << (PAGE_SHIFT - 9);
|
2014-06-05 06:07:48 +07:00
|
|
|
}
|
|
|
|
|
2017-09-07 06:22:30 +07:00
|
|
|
static inline void count_swpout_vm_event(struct page *page)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
|
|
if (unlikely(PageTransHuge(page)))
|
|
|
|
count_vm_event(THP_SWPOUT);
|
|
|
|
#endif
|
|
|
|
count_vm_events(PSWPOUT, hpage_nr_pages(page));
|
|
|
|
}
|
|
|
|
|
2013-04-30 05:08:35 +07:00
|
|
|
int __swap_writepage(struct page *page, struct writeback_control *wbc,
|
2015-07-20 20:29:37 +07:00
|
|
|
bio_end_io_t end_write_func)
|
2013-04-30 05:08:34 +07:00
|
|
|
{
|
|
|
|
struct bio *bio;
|
2016-06-06 02:31:41 +07:00
|
|
|
int ret;
|
2013-04-30 05:08:34 +07:00
|
|
|
struct swap_info_struct *sis = page_swap_info(page);
|
2012-08-01 06:44:55 +07:00
|
|
|
|
2016-10-08 07:00:52 +07:00
|
|
|
VM_BUG_ON_PAGE(!PageSwapCache(page), page);
|
2012-08-01 06:44:55 +07:00
|
|
|
if (sis->flags & SWP_FILE) {
|
|
|
|
struct kiocb kiocb;
|
|
|
|
struct file *swap_file = sis->swap_file;
|
|
|
|
struct address_space *mapping = swap_file->f_mapping;
|
2014-04-05 10:12:29 +07:00
|
|
|
struct bio_vec bv = {
|
|
|
|
.bv_page = page,
|
|
|
|
.bv_len = PAGE_SIZE,
|
|
|
|
.bv_offset = 0
|
|
|
|
};
|
2015-01-23 13:08:07 +07:00
|
|
|
struct iov_iter from;
|
2012-08-01 06:44:55 +07:00
|
|
|
|
2015-01-23 13:08:07 +07:00
|
|
|
iov_iter_bvec(&from, ITER_BVEC | WRITE, &bv, 1, PAGE_SIZE);
|
2012-08-01 06:44:55 +07:00
|
|
|
init_sync_kiocb(&kiocb, swap_file);
|
|
|
|
kiocb.ki_pos = page_file_offset(page);
|
|
|
|
|
2013-04-30 05:08:48 +07:00
|
|
|
set_page_writeback(page);
|
2012-08-01 06:44:55 +07:00
|
|
|
unlock_page(page);
|
2016-04-07 22:51:58 +07:00
|
|
|
ret = mapping->a_ops->direct_IO(&kiocb, &from);
|
2012-08-01 06:44:55 +07:00
|
|
|
if (ret == PAGE_SIZE) {
|
|
|
|
count_vm_event(PSWPOUT);
|
|
|
|
ret = 0;
|
2013-04-30 05:08:47 +07:00
|
|
|
} else {
|
2013-04-30 05:08:48 +07:00
|
|
|
/*
|
|
|
|
* In the case of swap-over-nfs, this can be a
|
|
|
|
* temporary failure if the system has limited
|
|
|
|
* memory for allocating transmit buffers.
|
|
|
|
* Mark the page dirty and avoid
|
|
|
|
* rotate_reclaimable_page but rate-limit the
|
|
|
|
* messages but do not flag PageError like
|
|
|
|
* the normal direct-to-bio case as it could
|
|
|
|
* be temporary.
|
|
|
|
*/
|
2013-04-30 05:08:47 +07:00
|
|
|
set_page_dirty(page);
|
2013-04-30 05:08:48 +07:00
|
|
|
ClearPageReclaim(page);
|
2016-03-18 04:19:50 +07:00
|
|
|
pr_err_ratelimited("Write error on dio swapfile (%llu)\n",
|
|
|
|
page_file_offset(page));
|
2012-08-01 06:44:55 +07:00
|
|
|
}
|
2013-04-30 05:08:48 +07:00
|
|
|
end_page_writeback(page);
|
2012-08-01 06:44:55 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:07:48 +07:00
|
|
|
ret = bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc);
|
|
|
|
if (!ret) {
|
2017-09-07 06:22:30 +07:00
|
|
|
count_swpout_vm_event(page);
|
2014-06-05 06:07:48 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
2013-04-30 05:08:35 +07:00
|
|
|
bio = get_swap_bio(GFP_NOIO, page, end_write_func);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bio == NULL) {
|
|
|
|
set_page_dirty(page);
|
|
|
|
unlock_page(page);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2016-11-01 23:00:38 +07:00
|
|
|
bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
|
2017-09-07 06:22:30 +07:00
|
|
|
count_swpout_vm_event(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
set_page_writeback(page);
|
|
|
|
unlock_page(page);
|
2016-06-06 02:31:41 +07:00
|
|
|
submit_bio(bio);
|
2005-04-17 05:20:36 +07:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
int swap_readpage(struct page *page, bool do_poll)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct bio *bio;
|
|
|
|
int ret = 0;
|
2012-08-01 06:44:55 +07:00
|
|
|
struct swap_info_struct *sis = page_swap_info(page);
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
blk_qc_t qc;
|
2017-08-24 00:10:32 +07:00
|
|
|
struct gendisk *disk;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-10-08 07:00:52 +07:00
|
|
|
VM_BUG_ON_PAGE(!PageSwapCache(page), page);
|
2014-01-24 06:52:54 +07:00
|
|
|
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
|
|
|
VM_BUG_ON_PAGE(PageUptodate(page), page);
|
2012-05-15 22:32:15 +07:00
|
|
|
if (frontswap_load(page) == 0) {
|
2012-04-10 06:08:06 +07:00
|
|
|
SetPageUptodate(page);
|
|
|
|
unlock_page(page);
|
|
|
|
goto out;
|
|
|
|
}
|
2012-08-01 06:44:55 +07:00
|
|
|
|
|
|
|
if (sis->flags & SWP_FILE) {
|
|
|
|
struct file *swap_file = sis->swap_file;
|
|
|
|
struct address_space *mapping = swap_file->f_mapping;
|
|
|
|
|
|
|
|
ret = mapping->a_ops->readpage(swap_file, page);
|
|
|
|
if (!ret)
|
|
|
|
count_vm_event(PSWPIN);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:07:48 +07:00
|
|
|
ret = bdev_read_page(sis->bdev, swap_page_sector(page), page);
|
|
|
|
if (!ret) {
|
2016-04-29 06:18:41 +07:00
|
|
|
if (trylock_page(page)) {
|
|
|
|
swap_slot_free_notify(page);
|
|
|
|
unlock_page(page);
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:07:48 +07:00
|
|
|
count_vm_event(PSWPIN);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
2009-12-15 08:58:40 +07:00
|
|
|
bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (bio == NULL) {
|
|
|
|
unlock_page(page);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2017-08-24 00:10:32 +07:00
|
|
|
disk = bio->bi_disk;
|
2017-08-03 03:32:09 +07:00
|
|
|
/*
|
|
|
|
* Keep this task valid during swap readpage because the oom killer may
|
|
|
|
* attempt to access it in the page fault retry time check.
|
|
|
|
*/
|
|
|
|
get_task_struct(current);
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
bio->bi_private = current;
|
2016-06-06 02:31:48 +07:00
|
|
|
bio_set_op_attrs(bio, REQ_OP_READ, 0);
|
2006-06-30 15:55:45 +07:00
|
|
|
count_vm_event(PSWPIN);
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
bio_get(bio);
|
|
|
|
qc = submit_bio(bio);
|
|
|
|
while (do_poll) {
|
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
|
|
if (!READ_ONCE(bio->bi_private))
|
|
|
|
break;
|
|
|
|
|
2017-08-24 00:10:32 +07:00
|
|
|
if (!blk_mq_poll(disk->queue, qc))
|
swap: add block io poll in swapin path
For fast flash disk, async IO could introduce overhead because of
context switch. block-mq now supports IO poll, which improves
performance and latency a lot. swapin is a good place to use this
technique, because the task is waiting for the swapin page to continue
execution.
In my virtual machine, directly read 4k data from a NVMe with iopoll is
about 60% better than that without poll. With iopoll support in swapin
patch, my microbenchmark (a task does random memory write) is about
10%~25% faster. CPU utilization increases a lot though, 2x and even 3x
CPU utilization. This will depend on disk speed.
While iopoll in swapin isn't intended for all usage cases, it's a win
for latency sensistive workloads with high speed swap disk. block layer
has knob to control poll in runtime. If poll isn't enabled in block
layer, there should be no noticeable change in swapin.
I got a chance to run the same test in a NVMe with DRAM as the media.
In simple fio IO test, blkpoll boosts 50% performance in single thread
test and ~20% in 8 threads test. So this is the base line. In above
swap test, blkpoll boosts ~27% performance in single thread test.
blkpoll uses 2x CPU time though.
If we enable hybid polling, the performance gain has very slight drop
but CPU time is only 50% worse than that without blkpoll. Also we can
adjust parameter of hybid poll, with it, the CPU time penality is
reduced further. In 8 threads test, blkpoll doesn't help though. The
performance is similar to that without blkpoll, but cpu utilization is
similar too. There is lock contention in swap path. The cpu time
spending on blkpoll isn't high. So overall, blkpoll swapin isn't worse
than that without it.
The swapin readahead might read several pages in in the same time and
form a big IO request. Since the IO will take longer time, it doesn't
make sense to do poll, so the patch only does iopoll for single page
swapin.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/070c3c3e40b711e7b1390002c991e86a-b5408f0@7511894063d3764ff01ea8111f5a004d7dd700ed078797c204a24e620ddb965c
Signed-off-by: Shaohua Li <shli@fb.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-07-11 05:47:11 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
__set_current_state(TASK_RUNNING);
|
|
|
|
bio_put(bio);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
2012-08-01 06:44:55 +07:00
|
|
|
|
|
|
|
int swap_set_page_dirty(struct page *page)
|
|
|
|
{
|
|
|
|
struct swap_info_struct *sis = page_swap_info(page);
|
|
|
|
|
|
|
|
if (sis->flags & SWP_FILE) {
|
|
|
|
struct address_space *mapping = sis->swap_file->f_mapping;
|
2016-10-08 07:00:52 +07:00
|
|
|
|
|
|
|
VM_BUG_ON_PAGE(!PageSwapCache(page), page);
|
2012-08-01 06:44:55 +07:00
|
|
|
return mapping->a_ops->set_page_dirty(page);
|
|
|
|
} else {
|
|
|
|
return __set_page_dirty_no_writeback(page);
|
|
|
|
}
|
|
|
|
}
|