LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Kairui Song <ryncsn@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: Fri, 19 Jun 2026 09:36:17 +0530	[thread overview]
Message-ID: <5x3fdvie.ritesh.list@gmail.com> (raw)
In-Reply-To: <ajIUVSWaQbFoez5Y@KASONG-MC4>

Kairui Song <ryncsn@gmail.com> writes:

> 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.
>

Thanks Kairui for taking a look at this. Sorry about the delayed
response, (was on travel to #OSSMumbai).

>> 
>> 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?
>

yup. I can change that.

>> +#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?
>

Right. Earlier I was playing with different values of this via an
arch_xxx variant. But for book3s64 usecase, the default values are fine.

So, I agree, we need not change SWAPFILE_CLUSTER here. I can update the
patch with the suggested changes in v4. 


-ritesh


  reply	other threads:[~2026-06-19  4:11 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
2026-06-19  4:06     ` Ritesh Harjani [this message]
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=5x3fdvie.ritesh.list@gmail.com \
    --to=ritesh.list@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=ryncsn@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox