Skip to content

Commit b296fda

Browse files
riteshharjanimaddy-kerneldev
authored andcommitted
powerpc/64s/hash: Update directMap page counters for Hash
Update the directMap page counters for Hash. Hash by default always uses mmu_linear_psize only, for it's directMap. However, once the kernel has booted and the dmesg log is wrapped over there is no way of knowing the kernel linear pagesize with Hash mmu. Features like debug_page_alloc can make mmu_linear_psize to be PAGE_SIZE instead of PMD / PUD mappings. It would be easier if we have this info printed in proc meminfo similar to Radix for debugging purposes. Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/208e6f946d2ba9c1e2b8b4f665728abe5c891e7c.1761834163.git.ritesh.list@gmail.com
1 parent b80691e commit b296fda

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

arch/powerpc/mm/book3s64/hash_utils.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <asm/mmu.h>
4848
#include <asm/mmu_context.h>
4949
#include <asm/page.h>
50+
#include <asm/pgalloc.h>
5051
#include <asm/types.h>
5152
#include <linux/uaccess.h>
5253
#include <asm/machdep.h>
@@ -449,6 +450,7 @@ static __init void hash_kfence_map_pool(void)
449450
{
450451
unsigned long kfence_pool_start, kfence_pool_end;
451452
unsigned long prot = pgprot_val(PAGE_KERNEL);
453+
unsigned int pshift = mmu_psize_defs[mmu_linear_psize].shift;
452454

453455
if (!kfence_pool)
454456
return;
@@ -459,6 +461,7 @@ static __init void hash_kfence_map_pool(void)
459461
BUG_ON(htab_bolt_mapping(kfence_pool_start, kfence_pool_end,
460462
kfence_pool, prot, mmu_linear_psize,
461463
mmu_kernel_ssize));
464+
update_page_count(mmu_linear_psize, KFENCE_POOL_SIZE >> pshift);
462465
memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE);
463466
}
464467

@@ -1234,6 +1237,7 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
12341237
int nid, pgprot_t prot)
12351238
{
12361239
int rc;
1240+
unsigned int pshift = mmu_psize_defs[mmu_linear_psize].shift;
12371241

12381242
if (end >= H_VMALLOC_START) {
12391243
pr_warn("Outside the supported range\n");
@@ -1251,17 +1255,22 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
12511255
mmu_kernel_ssize);
12521256
BUG_ON(rc2 && (rc2 != -ENOENT));
12531257
}
1258+
update_page_count(mmu_linear_psize, (end - start) >> pshift);
12541259
return rc;
12551260
}
12561261

12571262
int hash__remove_section_mapping(unsigned long start, unsigned long end)
12581263
{
1264+
unsigned int pshift = mmu_psize_defs[mmu_linear_psize].shift;
1265+
12591266
int rc = htab_remove_mapping(start, end, mmu_linear_psize,
12601267
mmu_kernel_ssize);
12611268

12621269
if (resize_hpt_for_hotplug(memblock_phys_mem_size()) == -ENOSPC)
12631270
pr_warn("Hash collision while resizing HPT\n");
12641271

1272+
if (!rc)
1273+
update_page_count(mmu_linear_psize, -((end - start) >> pshift));
12651274
return rc;
12661275
}
12671276
#endif /* CONFIG_MEMORY_HOTPLUG */
@@ -1304,6 +1313,7 @@ static void __init htab_initialize(void)
13041313
unsigned long prot;
13051314
phys_addr_t base = 0, size = 0, end, limit = MEMBLOCK_ALLOC_ANYWHERE;
13061315
u64 i;
1316+
unsigned int pshift = mmu_psize_defs[mmu_linear_psize].shift;
13071317

13081318
DBG(" -> htab_initialize()\n");
13091319

@@ -1404,6 +1414,8 @@ static void __init htab_initialize(void)
14041414

14051415
BUG_ON(htab_bolt_mapping(base, base + size, __pa(base),
14061416
prot, mmu_linear_psize, mmu_kernel_ssize));
1417+
1418+
update_page_count(mmu_linear_psize, size >> pshift);
14071419
}
14081420
hash_kfence_map_pool();
14091421
memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);
@@ -1425,6 +1437,8 @@ static void __init htab_initialize(void)
14251437
BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end,
14261438
__pa(tce_alloc_start), prot,
14271439
mmu_linear_psize, mmu_kernel_ssize));
1440+
update_page_count(mmu_linear_psize,
1441+
(tce_alloc_end - tce_alloc_start) >> pshift);
14281442
}
14291443

14301444

0 commit comments

Comments
 (0)