From a2562801187aafd4e45469f5374e8b8dac8b5f0d Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Mon, 6 Mar 2017 14:05:18 +0900 Subject: [PATCH] PROFILE_mmap_XXX: more detailed mmap profiling --- kernel/include/profile.h | 3 +++ kernel/profile.c | 3 +++ kernel/syscall.c | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/kernel/include/profile.h b/kernel/include/profile.h index 2b3152c2..ccfac9a7 100644 --- a/kernel/include/profile.h +++ b/kernel/include/profile.h @@ -34,7 +34,10 @@ struct profile_event { enum profile_event_type { PROFILE_page_fault = PROFILE_EVENT_MIN, PROFILE_mpol_alloc_missed, + PROFILE_mmap_anon_contig_phys, PROFILE_mmap_anon_no_contig_phys, + PROFILE_mmap_regular_file, + PROFILE_mmap_device_file, PROFILE_EVENT_MAX /* Should be the last event type */ }; diff --git a/kernel/profile.c b/kernel/profile.c index 6afdaa5b..61d393bb 100644 --- a/kernel/profile.c +++ b/kernel/profile.c @@ -59,7 +59,10 @@ char *profile_event_names[] = { "page_fault", "mpol_alloc_missed", + "mmap_anon_contig_phys", "mmap_anon_no_contig_phys", + "mmap_regular_file", + "mmap_device_file", "" }; diff --git a/kernel/syscall.c b/kernel/syscall.c index 414edd13..e52a17cb 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1189,6 +1189,11 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot, error = -ENODEV; } #endif +#ifdef PROFILE_ENABLE + if (!error) { + profile_event_add(PROFILE_mmap_regular_file, len); + } +#endif // PROFILE_ENABLE if (error == -ESRCH) { dkprintf("do_mmap:hit non VREG\n"); /* @@ -1205,6 +1210,9 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot, prot, (flags & (MAP_POPULATE | MAP_LOCKED))); if (!error) { +#ifdef PROFILE_ENABLE + profile_event_add(PROFILE_mmap_device_file, len); +#endif // PROFILE_ENABLE dkprintf("%s: device fd: %d off: %lu mapping at %p - %p\n", __FUNCTION__, fd, off, addr, addr + len); } @@ -1253,6 +1261,9 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot, } } else { +#ifdef PROFILE_ENABLE + profile_event_add(PROFILE_mmap_anon_contig_phys, len); +#endif // PROFILE_ENABLE dkprintf("%s: 0x%x:%lu MAP_ANONYMOUS " "allocated %d pages, p2align: %lx\n", __FUNCTION__, addr, len, npages, p2align);