From f91213cc1e44a0e5222f0b0bc61e6be6a252a154 Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Sat, 3 Sep 2005 15:54:40 -0700 Subject: [PATCH] --- yaml --- r: 6854 b: refs/heads/master c: 048c27fd72816b44e096997d1c6901c3abbfd45b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/swapfile.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 0901607bccd9..35898612b531 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 52b7efdbe5f5696fc80338560a3fc51e0b0a993c +refs/heads/master: 048c27fd72816b44e096997d1c6901c3abbfd45b diff --git a/trunk/mm/swapfile.c b/trunk/mm/swapfile.c index fdee145afc6f..e675ae55f87d 100644 --- a/trunk/mm/swapfile.c +++ b/trunk/mm/swapfile.c @@ -56,8 +56,6 @@ static DECLARE_MUTEX(swapon_sem); */ static DECLARE_RWSEM(swap_unplug_sem); -#define SWAPFILE_CLUSTER 256 - void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page) { swp_entry_t entry; @@ -84,9 +82,13 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page) up_read(&swap_unplug_sem); } +#define SWAPFILE_CLUSTER 256 +#define LATENCY_LIMIT 256 + static inline unsigned long scan_swap_map(struct swap_info_struct *si) { unsigned long offset, last_in_cluster; + int latency_ration = LATENCY_LIMIT; /* * We try to cluster swap pages by allocating them sequentially @@ -117,6 +119,10 @@ static inline unsigned long scan_swap_map(struct swap_info_struct *si) si->cluster_next = offset-SWAPFILE_CLUSTER-1; goto cluster; } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } } swap_device_lock(si); goto lowest; @@ -153,6 +159,10 @@ checks: if (!(si->flags & SWP_WRITEOK)) swap_device_lock(si); goto checks; } + if (unlikely(--latency_ration < 0)) { + cond_resched(); + latency_ration = LATENCY_LIMIT; + } } swap_device_lock(si); goto lowest;