ANDROID: mm: Added early_param pcp_thp_order

Added early param "pcp_thp_order", which specifies the order of pcp used by THP.
This allows vendors to customize the order different from HPAGE_PMD_ORDER for
THP to use.

Bug: 431672372
Change-Id: Id2c8f3b03b74added54827ffbc33fd4e4bdf619e
Signed-off-by: Pengfei Li <pengfei.kernel@vivo.corp-partner.google.com>
This commit is contained in:
Pengfei Li
2025-07-07 15:10:58 +08:00
committed by T.J. Mercier
parent 1195471b19
commit e3489f30ee
2 changed files with 29 additions and 3 deletions
@@ -4759,6 +4759,11 @@
pcmv= [HW,PCMCIA] BadgePAD 4
pcp_thp_order= [MM]
Specify the order of the pcp used by THP.
The specified value must be no greater than HPAGE_PMD_ORDER
(default) and greater than 3 (PAGE_ALLOC_COSTLY_ORDER).
pd_ignore_unused
[PM]
Keep all power-domains already enabled by bootloader on,
+24 -3
View File
@@ -599,6 +599,27 @@ out:
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
}
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
static unsigned int pcp_thp_order __read_mostly = HPAGE_PMD_ORDER;
static int __init parse_pcp_thp_order(char *s)
{
int err;
unsigned int order;
err = kstrtouint(s, 0, &order);
if (err)
return err;
if (order <= PAGE_ALLOC_COSTLY_ORDER || order > HPAGE_PMD_ORDER)
return -EINVAL;
pcp_thp_order = order;
return 0;
}
early_param("pcp_thp_order", parse_pcp_thp_order);
#endif
static inline unsigned int order_to_pindex(int migratetype, int order)
{
bool __maybe_unused movable;
@@ -614,7 +635,7 @@ static inline unsigned int order_to_pindex(int migratetype, int order)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (order > PAGE_ALLOC_COSTLY_ORDER) {
VM_BUG_ON(order != HPAGE_PMD_ORDER);
VM_BUG_ON(order != pcp_thp_order);
movable = migratetype == MIGRATE_MOVABLE;
#ifdef CONFIG_CMA
@@ -636,7 +657,7 @@ static inline int pindex_to_order(unsigned int pindex)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (pindex >= NR_LOWORDER_PCP_LISTS)
order = HPAGE_PMD_ORDER;
order = pcp_thp_order;
#else
VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
#endif
@@ -649,7 +670,7 @@ static inline bool pcp_allowed_order(unsigned int order)
if (order <= PAGE_ALLOC_COSTLY_ORDER)
return true;
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (order == HPAGE_PMD_ORDER)
if (order == pcp_thp_order)
return true;
#endif
return false;