[RFC PATCH v1 3/4] hugetlb: add timing to hugetlb allocations on boot

Gang Li posted 4 patches 2 years, 1 month ago
[RFC PATCH v1 3/4] hugetlb: add timing to hugetlb allocations on boot
Posted by Gang Li 2 years, 1 month ago
From: Gang Li <ligang.bdlg@bytedance.com>

Add timing to hugetlb allocations for further optimization.

Signed-off-by: Gang Li <ligang.bdlg@bytedance.com>
---
 mm/hugetlb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7f9ff0855dd0..ac8558724cc2 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3563,7 +3563,7 @@ static unsigned long __init hugetlb_hstate_alloc_pages_non_gigantic(struct hstat
  */
 static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
 {
-	unsigned long allocated;
+	unsigned long allocated, start;
 
 	/* skip gigantic hugepages allocation if hugetlb_cma enabled */
 	if (hstate_is_gigantic(h) && hugetlb_cma_size) {
@@ -3576,11 +3576,13 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
 		return;
 
 	/* below will do all node balanced alloc */
+	start = jiffies;
 	if (!hstate_is_gigantic(h)) {
 		allocated = hugetlb_hstate_alloc_pages_non_gigantic(h);
 	} else {
 		allocated = hugetlb_hstate_alloc_pages_gigantic(h);
 	}
+	pr_info("HugeTLB: Allocation takes %u ms\n", jiffies_to_msecs(jiffies - start));
 
 	hugetlb_hstate_alloc_pages_report(allocated, h);
 }
-- 
2.20.1