diff options
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r-- | mm/swap_state.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c index ea6b32d61873..9d3dd3763cf7 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -372,25 +372,23 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, | |||
372 | struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, | 372 | struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, |
373 | struct vm_area_struct *vma, unsigned long addr) | 373 | struct vm_area_struct *vma, unsigned long addr) |
374 | { | 374 | { |
375 | int nr_pages; | ||
376 | struct page *page; | 375 | struct page *page; |
377 | unsigned long offset; | 376 | unsigned long offset = swp_offset(entry); |
378 | unsigned long end_offset; | 377 | unsigned long start_offset, end_offset; |
378 | unsigned long mask = (1UL << page_cluster) - 1; | ||
379 | 379 | ||
380 | /* | 380 | /* Read a page_cluster sized and aligned cluster around offset. */ |
381 | * Get starting offset for readaround, and number of pages to read. | 381 | start_offset = offset & ~mask; |
382 | * Adjust starting address by readbehind (for NUMA interleave case)? | 382 | end_offset = offset | mask; |
383 | * No, it's very unlikely that swap layout would follow vma layout, | 383 | if (!start_offset) /* First page is swap header. */ |
384 | * more likely that neighbouring swap pages came from the same node: | 384 | start_offset++; |
385 | * so use the same "addr" to choose the same node for each swap read. | 385 | |
386 | */ | 386 | for (offset = start_offset; offset <= end_offset ; offset++) { |
387 | nr_pages = valid_swaphandles(entry, &offset); | ||
388 | for (end_offset = offset + nr_pages; offset < end_offset; offset++) { | ||
389 | /* Ok, do the async read-ahead now */ | 387 | /* Ok, do the async read-ahead now */ |
390 | page = read_swap_cache_async(swp_entry(swp_type(entry), offset), | 388 | page = read_swap_cache_async(swp_entry(swp_type(entry), offset), |
391 | gfp_mask, vma, addr); | 389 | gfp_mask, vma, addr); |
392 | if (!page) | 390 | if (!page) |
393 | break; | 391 | continue; |
394 | page_cache_release(page); | 392 | page_cache_release(page); |
395 | } | 393 | } |
396 | lru_add_drain(); /* Push any new pages onto the LRU now */ | 394 | lru_add_drain(); /* Push any new pages onto the LRU now */ |