git: b9fd884a8d0b - main - sys/vm: Add TSLOG to some functions

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Fri, 12 Aug 2022 23:53:17 UTC
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=b9fd884a8d0b249f77519a2c7f156b786fcc1c62

commit b9fd884a8d0b249f77519a2c7f156b786fcc1c62
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2022-08-12 23:52:47 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2022-08-12 23:53:04 +0000

    sys/vm: Add TSLOG to some functions
    
    The functions pbuf_init, kva_alloc, and keg_alloc_slab are significant
    contributors to the kernel boot time when FreeBSD boots inside the
    Firecracker VMM.  Instrument them so they show up on flamecharts.
---
 sys/vm/uma_core.c | 3 +++
 sys/vm/vm_kern.c  | 2 ++
 sys/vm/vm_pager.c | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 1afcb45c4d2b..1351a54345d9 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1762,6 +1762,8 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
 	uint8_t sflags;
 	int i;
 
+	TSENTER();
+
 	KASSERT(domain >= 0 && domain < vm_ndomains,
 	    ("keg_alloc_slab: domain %d out of range", domain));
 
@@ -1858,6 +1860,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
 	dom->ud_pages += keg->uk_ppera;
 	dom->ud_free_items += keg->uk_ipers;
 
+	TSEXIT();
 	return (slab);
 
 fail:
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index ac132f8ec0f3..7a61a29c81a4 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -148,9 +148,11 @@ kva_alloc(vm_size_t size)
 {
 	vm_offset_t addr;
 
+	TSENTER();
 	size = round_page(size);
 	if (vmem_alloc(kernel_arena, size, M_BESTFIT | M_NOWAIT, &addr))
 		return (0);
+	TSEXIT();
 
 	return (addr);
 }
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 2f8afd69a1b4..cc0be174987d 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -495,6 +495,8 @@ pbuf_init(void *mem, int size, int flags)
 {
 	struct buf *bp = mem;
 
+	TSENTER();
+
 	bp->b_kvabase = (void *)kva_alloc(ptoa(PBUF_PAGES));
 	if (bp->b_kvabase == NULL)
 		return (ENOMEM);
@@ -504,6 +506,8 @@ pbuf_init(void *mem, int size, int flags)
 	bp->b_rcred = bp->b_wcred = NOCRED;
 	bp->b_xflags = 0;
 
+	TSEXIT();
+
 	return (0);
 }