From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE62540D599 for ; Fri, 19 Jun 2026 04:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781842281; cv=none; b=Kq9KuFWgWGFG3yWnkm/XCfdLJHN0QrYB9HPG4dXa7CiW5YOCsb8MEtrHPmT0Jrd4PgXuaeMoWbbVnOlaCf1ghFZX20uDTOjzuwyXJG8hiTtk/hBu+AjoGC/SOiWvOhJuUr6uwJUllPle5PWeQz0j83+zYaqPUn4/niSG0E0lc5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781842281; c=relaxed/simple; bh=jXRXww+doYsYMzx/61TRuwB/0M491j6wdh9+WrmcZ9E=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=h7/kh4skYks1hL/RUBmQKWuN6loe9Muy/1Mv2hRpmJlHh6ymAjpHaPcqH2WdGv14peHdsbLn51EA106giZlBR7g0mtliKW6YMotYTSk5WNT+LKy+hGZeTWuFBlBWmXqY73sfMRaNC2i0YnxApSLp+9S7cUTwa07XYj63309TZek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=f3RETSoF; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f3RETSoF" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-84540eb70b2so870149b3a.2 for ; Thu, 18 Jun 2026 21:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781842279; x=1782447079; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ns7uFMdN8XmD+BmGhPlCgcUtZIHgSZf+bEO3nXaURYw=; b=f3RETSoF6Aj/hcFCUQJV1Edmf7JIOfgyq/xMU4Ij0MxmvUidnb9VreQGiXjrT+xRMb V15m7xKJzYVXj9CJguWbfTla1SAb9q36DhVjU8eKiCn4t7FeXiRfej0Dd4Ei8O6Uc63W n4ncqt+FYEOdCxax7ewzogoMrBDQO9NF0DpqAI8v1WlJgQiDQnsyvXL2gSNJDTsS3Aok lUnHV06g/ZH3UdsUgrSLEt08WRP5Krmw+C48bAf8WSh3/Rnpl6kVGUA6gcxEGQy2BbMD 8hG/J6AlImBeafDQwyP98xgrhxKmH+YsQm9J9cXgCkIVYJuwal6o/4tyj2N5O4ly8W52 wLUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781842279; x=1782447079; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ns7uFMdN8XmD+BmGhPlCgcUtZIHgSZf+bEO3nXaURYw=; b=oI63UQm+MrliSo3SJNSPjJKQXIYdySZVPQ8VUaeZgcPejk0+q+7TGLEFz7P25F+BKU hx7gifg6cwzS7jRnwSjvu9zFPGBTdQD4tL94NVy4CnVQKbtZpS/QOPv3rIPN8xIj50hf x0pOmbzlgXcaSyrqGKkiWUqGVHfHjsYoSOIWajicA0XxohRaq23US4Y4643YO7cUbtit qfW+FOcEus1H+MItgOeI40OjoNy1YAOf4ZYz0ED37cWVeV8sD7LYo4sgaDE50lIC59pV OHcKjzB2redHZaZoDi98wQN4fW5A/uMBaBnkeRCYfxUX+F9ee/JutFvHE9Gyc4Ol/ifn mcfQ== X-Forwarded-Encrypted: i=1; AFNElJ8tUbtFikjqGGrymGnrfj88OPxo9qN6q0Wbmtww0PHtqJl/CLgEKmds8klfOyl6zJy3BQxLO+Y+x6yWe/s=@vger.kernel.org X-Gm-Message-State: AOJu0Yze2sTpYAadn7nVA6hvI6nv/ltlV19STJRj492Xa/+JrMfSikcF WrhQoTv2llFwcYrMr9ggTukkMzdxWWqsD8NZM+/qK4XfS0F/vAj9Z7c2 X-Gm-Gg: AfdE7cmcKXYiQ37Dv/IMYDgoC4gj3JmoxDRbOrhON0CYzwLZMpSQ+gL+KDPcPNNTBD2 ycQgZBLzb8GPuYI8UepSxbNp7a8LQTMhu4MdzDH2w12O3cYFwKHoAkuSI/oUjgPadh6gp4x74ck rKExPEpDhR4W4/eibKmyuae9mtfBrp7ynrV3bl7xrMBmI15/L8HW229tSLbcnfOEsowO3X3FDyO E57aIz4H1p0damGVPpHclwMNaX7+X53k75J5qg9pYrm0jpyQM0fOJeWRWahlB58b361jnEJjSvF /AeBFaq4os5AdPtXu/KgeNsrJ1RfRPjDkr9pRilqcpUQJLyIdl8ZKKrAkbHjyFiNGNOjoocDBOv JtL26V7NzafXQ48AaPVzPKH4jCi9ykXKhXLcC4D3H4jCTJjSmxIYjgxk9xkp0+eHzP9vuasYLny O3SBGSNNBpXIcaiIU= X-Received: by 2002:a05:6a00:14d3:b0:835:4291:6975 with SMTP id d2e1a72fcca58-845508cce6amr2119845b3a.39.1781842279197; Thu, 18 Jun 2026 21:11:19 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8455382b766sm793864b3a.47.2026.06.18.21.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 21:11:17 -0700 (PDT) From: Ritesh Harjani (IBM) To: Kairui Song Cc: linux-mm@kvack.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , David Hildenbrand , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Sayali Patil Subject: Re: [PATCH v3 1/3] mm, swap: make SWAPFILE_CLUSTER runtime In-Reply-To: Date: Fri, 19 Jun 2026 09:36:17 +0530 Message-ID: <5x3fdvie.ritesh.list@gmail.com> References: <1e8d7e4d0bb1377277ae8b6561d89fa0e048e7de.1781287297.git.ritesh.list@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Kairui Song 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) >> --- >> 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