mm/swap: avoid a xa load for swapout path
Subsystems (2)
PATCH 1/1 mm/swap: avoid a xa load for swapout path
From: Kairui Song <[email protected]>
A variable is never used for swapout path (shadowp is NULL) and compiler is unable to optimize out the unneeded load since it's a function call.
Signed-off-by Kairui Song <[email protected]>
--- mm/swap_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/swap_state.c +3 -3
@@ -109,9 +109,9 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, goto unlock;for (i =0 ; i < nr; i++) {VM_BUG_ON_FOLIO (xas.xa_index != idx + i, folio); - old =xas_load (&xas); -if (xa_is_value (old)) { -if (shadowp) +if (shadowp) { + old =xas_load (&xas); +if (xa_is_value (old)) *shadowp = old; }xas_store (&xas, folio);
Signature · 1 line
2.42.0
Quoted 6 lines · Kairui Song
From: Kairui Song <[email protected]>
A variable is never used for swapout path (shadowp is NULL) and compiler is unable to optimize out the unneeded load since it's a function call.
Signed-off-by Kairui Song <[email protected]>
Reviewed-by Matthew Wilcox (Oracle)
Possibly worth adding a reference to3852f6768ede ("mm/swapcache: support to handle the shadow entries")
Not sure it's worth a Fixes:, but that's where it was introduced.