From: Kairui Song <ryncsn@gmail.com>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: linux-mm@kvack.org, Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <chleroy@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Baoquan He <baoquan.he@linux.dev>,
Barry Song <baohua@kernel.org>,
Youngjun Park <youngjun.park@lge.com>,
David Hildenbrand <david@kernel.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Sayali Patil <sayalip@linux.ibm.com>
Subject: Re: [PATCH v3 1/3] mm, swap: make SWAPFILE_CLUSTER runtime
Date: Wed, 17 Jun 2026 12:23:34 +0800 [thread overview]
Message-ID: <ajIUVSWaQbFoez5Y@KASONG-MC4> (raw)
In-Reply-To: <1e8d7e4d0bb1377277ae8b6561d89fa0e048e7de.1781287297.git.ritesh.list@gmail.com>
On Fri, Jun 12, 2026 at 11:39:15PM +0800, Ritesh Harjani (IBM) wrote:
> On PowerPC Book3S64, MMU is selected at runtime, so macros like
> PMD_SHIFT are effectively runtime variables in the Book3S64 code. THP
> swap code uses these macros to size some of its array data structures
> based on PMD_ORDER e.g. SWAPFILE_CLUSTER macro is used for this very
> purpose.
> Hence this patch initializes SWAPFILE_CLUSTER at runtime and also
> modifies swap_table and swap_memcg_table which were earlier using this
> macro for defining the number of table entries.
>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
> mm/swap.h | 5 +++--
> mm/swap_table.h | 6 ++----
> mm/swapfile.c | 27 ++++++++++++++++++++++-----
> 3 files changed, 27 insertions(+), 11 deletions(-)
Hi Ritesh,
Thanks for the patch.
>
> diff --git a/mm/swap.h b/mm/swap.h
> index 77d2d14eda42..956879a69ddd 100644
> --- a/mm/swap.h
> +++ b/mm/swap.h
> @@ -26,11 +26,12 @@ extern int page_cluster;
> #define SWAP_TABLE_HAS_ZEROFLAG ((BITS_PER_LONG - SWAP_CACHE_PFN_MARK_BITS - \
> SWAP_CACHE_PFN_BITS) > SWAP_COUNT_MIN_BITS)
>
> +extern unsigned int swap_slots_in_cluster __read_mostly;
Maybe __ro_after_init is better for this kind of use case?
> +#define SWAPFILE_CLUSTER swap_slots_in_cluster
> +
> #ifdef CONFIG_THP_SWAP
> -#define SWAPFILE_CLUSTER HPAGE_PMD_NR
So on Book3S64, HPAGE_PMD_NR is also a variable right? Then we don't really
need to change the SWAPFILE_CLUSTER defination here? We just need to adjust
the users of this macro so the build will pass?
Or maybe use another macro instead of HPAGE_PMD_NR here, whichever is
more arch friendly.
That way if that is a build time constant, all users are folded to
just one mask/shift which is super efficient especially for inline helpers,
and there are a lot of them. Only special archs live with the dynamic
load overhead.
next prev parent reply other threads:[~2026-06-17 4:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 18:09 [PATCH v3 0/3] mm, swap: Enable THP SWAP for PowerPC Book3S64 Ritesh Harjani (IBM)
2026-06-12 18:09 ` [PATCH v3 1/3] mm, swap: make SWAPFILE_CLUSTER runtime Ritesh Harjani (IBM)
2026-06-17 4:23 ` Kairui Song [this message]
2026-06-19 4:06 ` Ritesh Harjani
2026-06-12 18:09 ` [PATCH v3 2/3] mm, swap: allow archs to override SWAP_NR_ORDERS via ARCH_MAX_PMD_ORDER Ritesh Harjani (IBM)
2026-06-12 18:09 ` [PATCH v3 3/3] powerpc: Kconfig: Enable THP_SWAP on Book3S64 Ritesh Harjani (IBM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ajIUVSWaQbFoez5Y@KASONG-MC4 \
--to=ryncsn@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chleroy@kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=nphamcs@gmail.com \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=sayalip@linux.ibm.com \
--cc=shikemeng@huaweicloud.com \
--cc=youngjun.park@lge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.