mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
mm/swapfile:__swap_duplicate: drop redundant WRITE_ONCE on swap_map for err cases
The code is quite hard to read, we are still writing swap_map after errors happen. Though the written value is as before, has_cache = count & SWAP_HAS_CACHE; count &= ~SWAP_HAS_CACHE; [snipped] WRITE_ONCE(p->swap_map[offset], count | has_cache); It would be better to entirely drop the WRITE_ONCE for both performance and readability. [akpm@linux-foundation.org: avoid using goto] Link: https://lkml.kernel.org/r/20240221091028.123122-1-21cnbao@gmail.com Signed-off-by: Barry Song <v-songbaohua@oppo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
b4d3de57ca
commit
e26f0b939d
@ -3335,7 +3335,8 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
|
||||
} else
|
||||
err = -ENOENT; /* unused swap entry */
|
||||
|
||||
WRITE_ONCE(p->swap_map[offset], count | has_cache);
|
||||
if (!err)
|
||||
WRITE_ONCE(p->swap_map[offset], count | has_cache);
|
||||
|
||||
unlock_out:
|
||||
unlock_cluster_or_swap_info(p, ci);
|
||||
|
Loading…
Reference in New Issue
Block a user