[1/1] hugetlb: add timing to hugetlb allocations on boot

Message ID 20231208025617.5299-1-gang.li@linux.dev
State New
Headers
Series [1/1] hugetlb: add timing to hugetlb allocations on boot |

Commit Message

Gang Li Dec. 8, 2023, 2:56 a.m. UTC
  Add timing to hugetlb allocations for further optimization.

Debug only.

Signed-off-by: Gang Li <gang.li@linux.dev>
---
 mm/hugetlb.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 1169ef2f2176f..51f50bb3dc092 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4490,6 +4490,7 @@  static inline void hugetlb_sysctl_init(void) { }
 static int __init hugetlb_init(void)
 {
 	int i;
+	unsigned long start;
 
 	BUILD_BUG_ON(sizeof_field(struct page, private) * BITS_PER_BYTE <
 			__NR_HPAGEFLAGS);
@@ -4536,8 +4537,11 @@  static int __init hugetlb_init(void)
 	}
 
 	hugetlb_cma_check();
+	start = jiffies;
 	hugetlb_init_hstates();
 	gather_bootmem_prealloc();
+	pr_info("HugeTLB: 2M alloc, init and 1G init takes %u ms\n",
+		jiffies_to_msecs(jiffies - start));
 	report_hugepages();
 
 	hugetlb_sysfs_init();
@@ -4682,6 +4686,7 @@  static int __init hugepages_setup(char *s)
 		}
 	}
 
+	unsigned long start = jiffies;
 	/*
 	 * Global state is always initialized later in hugetlb_init.
 	 * But we need to allocate gigantic hstates here early to still
@@ -4692,6 +4697,7 @@  static int __init hugepages_setup(char *s)
 
 	last_mhp = mhp;
 
+	pr_info("HugeTLB: 1G alloc takes %u ms\n", jiffies_to_msecs(jiffies - start));
 	return 1;
 
 invalid: