[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231017011728.37508-1-ryncsn@gmail.com>
Date: Tue, 17 Oct 2023 09:17:28 +0800
From: Kairui Song <ryncsn@...il.com>
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Huang, Ying" <ying.huang@...el.com>, linux-kernel@...r.kernel.org,
Kairui Song <kasong@...cent.com>
Subject: [PATCH] mm/swap: avoid a xa load for swapout path
From: Kairui Song <kasong@...cent.com>
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 <kasong@...cent.com>
---
mm/swap_state.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index b3b14bd0dd64..ab79ffb71736 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -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);
--
2.42.0
Powered by blists - more mailing lists