Commit 2406b76f authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds
Browse files

mm/swap_slots.c: assign|reset cache slot by value directly

Currently we use a tmp pointer, pentry, to transfer and reset swap cache
slot, which is a little redundant.  Swap cache slot stores the entry value
directly, assign and reset it by value would be straight forward.

Also this patch merges the else and if, since this is the only case we
refill and repeat swap cache.
Signed-off-by: default avatarWei Yang <>
Signed-off-by: default avatarAndrew Morton <>
Acked-by: default avatarTim Chen <>

Signed-off-by: default avatarLinus Torvalds <>
parent 21820948
......@@ -309,7 +309,7 @@ int free_swap_slot(swp_entry_t entry)
swp_entry_t get_swap_page(struct page *page)
swp_entry_t entry, *pentry;
swp_entry_t entry;
struct swap_slots_cache *cache;
entry.val = 0;
......@@ -336,13 +336,11 @@ swp_entry_t get_swap_page(struct page *page)
if (cache->slots) {
if (cache->nr) {
pentry = &cache->slots[cache->cur++];
entry = *pentry;
pentry->val = 0;
entry = cache->slots[cache->cur];
cache->slots[cache->cur++].val = 0;
} else {
if (refill_swap_slots_cache(cache))
goto repeat;
} else if (refill_swap_slots_cache(cache)) {
goto repeat;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment