* [PATCH] mm/swap: avoid a xa load for swapout path
@ 2023-10-17 1:17 Kairui Song
2023-10-17 3:00 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Kairui Song @ 2023-10-17 1:17 UTC (permalink / raw)
To: linux-mm; +Cc: Andrew Morton, Huang, Ying, linux-kernel, Kairui Song
From: Kairui Song <kasong@tencent.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@tencent.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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/swap: avoid a xa load for swapout path
2023-10-17 1:17 [PATCH] mm/swap: avoid a xa load for swapout path Kairui Song
@ 2023-10-17 3:00 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2023-10-17 3:00 UTC (permalink / raw)
To: Kairui Song; +Cc: linux-mm, Andrew Morton, Huang, Ying, linux-kernel
On Tue, Oct 17, 2023 at 09:17:28AM +0800, Kairui Song wrote:
> From: Kairui Song <kasong@tencent.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@tencent.com>
Reviewed-by: Matthew Wilcox (Oracle)
Possibly worth adding a reference to
3852f6768ede ("mm/swapcache: support to handle the shadow entries")
Not sure it's worth a Fixes:, but that's where it was introduced.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-17 3:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17 1:17 [PATCH] mm/swap: avoid a xa load for swapout path Kairui Song
2023-10-17 3:00 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox