Messages in this thread Patch in this message | | | Date | Sat, 9 Jul 2005 01:10:17 +0100 (BST) | From | Hugh Dickins <> | Subject | [PATCH 11/13] scan_swap_map latency breaks |
| |
The get_swap_page/scan_swap_map latency can be so bad that even those without preemption configured deserve relief: periodically cond_resched.
Signed-off-by: Hugh Dickins <hugh@veritas.com> ---
mm/swapfile.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
--- swap10/mm/swapfile.c 2005-07-08 19:15:20.000000000 +0100 +++ swap11/mm/swapfile.c 2005-07-08 19:15:33.000000000 +0100 @@ -54,8 +54,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; @@ -82,9 +80,13 @@ void swap_unplug_io_fn(struct backing_de 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 @@ -115,6 +117,10 @@ static inline unsigned long scan_swap_ma 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; @@ -151,6 +157,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; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |