diff options
-rw-r--r-- | include/linux/swap.h | 11 | ||||
-rw-r--r-- | mm/swapfile.c | 8 |
2 files changed, 13 insertions, 6 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 61d63379e956..9c4ae6f14eea 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -400,16 +400,17 @@ extern struct page *do_swap_page_readahead(swp_entry_t fentry, gfp_t gfp_mask, | |||
400 | struct vm_fault *vmf, | 400 | struct vm_fault *vmf, |
401 | struct vma_swap_readahead *swap_ra); | 401 | struct vma_swap_readahead *swap_ra); |
402 | 402 | ||
403 | static inline bool swap_use_vma_readahead(void) | ||
404 | { | ||
405 | return READ_ONCE(swap_vma_readahead); | ||
406 | } | ||
407 | |||
408 | /* linux/mm/swapfile.c */ | 403 | /* linux/mm/swapfile.c */ |
409 | extern atomic_long_t nr_swap_pages; | 404 | extern atomic_long_t nr_swap_pages; |
410 | extern long total_swap_pages; | 405 | extern long total_swap_pages; |
406 | extern atomic_t nr_rotate_swap; | ||
411 | extern bool has_usable_swap(void); | 407 | extern bool has_usable_swap(void); |
412 | 408 | ||
409 | static inline bool swap_use_vma_readahead(void) | ||
410 | { | ||
411 | return READ_ONCE(swap_vma_readahead) && !atomic_read(&nr_rotate_swap); | ||
412 | } | ||
413 | |||
413 | /* Swap 50% full? Release swapcache more aggressively.. */ | 414 | /* Swap 50% full? Release swapcache more aggressively.. */ |
414 | static inline bool vm_swap_full(void) | 415 | static inline bool vm_swap_full(void) |
415 | { | 416 | { |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 42eff9e4e972..4f8b3e08a547 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -96,6 +96,8 @@ static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait); | |||
96 | /* Activity counter to indicate that a swapon or swapoff has occurred */ | 96 | /* Activity counter to indicate that a swapon or swapoff has occurred */ |
97 | static atomic_t proc_poll_event = ATOMIC_INIT(0); | 97 | static atomic_t proc_poll_event = ATOMIC_INIT(0); |
98 | 98 | ||
99 | atomic_t nr_rotate_swap = ATOMIC_INIT(0); | ||
100 | |||
99 | static inline unsigned char swap_count(unsigned char ent) | 101 | static inline unsigned char swap_count(unsigned char ent) |
100 | { | 102 | { |
101 | return ent & ~SWAP_HAS_CACHE; /* may include SWAP_HAS_CONT flag */ | 103 | return ent & ~SWAP_HAS_CACHE; /* may include SWAP_HAS_CONT flag */ |
@@ -2569,6 +2571,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
2569 | if (p->flags & SWP_CONTINUED) | 2571 | if (p->flags & SWP_CONTINUED) |
2570 | free_swap_count_continuations(p); | 2572 | free_swap_count_continuations(p); |
2571 | 2573 | ||
2574 | if (!p->bdev || !blk_queue_nonrot(bdev_get_queue(p->bdev))) | ||
2575 | atomic_dec(&nr_rotate_swap); | ||
2576 | |||
2572 | mutex_lock(&swapon_mutex); | 2577 | mutex_lock(&swapon_mutex); |
2573 | spin_lock(&swap_lock); | 2578 | spin_lock(&swap_lock); |
2574 | spin_lock(&p->lock); | 2579 | spin_lock(&p->lock); |
@@ -3145,7 +3150,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
3145 | cluster = per_cpu_ptr(p->percpu_cluster, cpu); | 3150 | cluster = per_cpu_ptr(p->percpu_cluster, cpu); |
3146 | cluster_set_null(&cluster->index); | 3151 | cluster_set_null(&cluster->index); |
3147 | } | 3152 | } |
3148 | } | 3153 | } else |
3154 | atomic_inc(&nr_rotate_swap); | ||
3149 | 3155 | ||
3150 | error = swap_cgroup_swapon(p->type, maxpages); | 3156 | error = swap_cgroup_swapon(p->type, maxpages); |
3151 | if (error) | 3157 | if (error) |