1 #include <sys/sysctl.h> 2 3 #include <darwintest.h> 4 #include <darwintest_perf.h> 5 #include "test_utils.h" 6 7 T_GLOBAL_META( 8 T_META_NAMESPACE("xnu.arm"), 9 T_META_RADAR_COMPONENT_NAME("xnu"), 10 T_META_RADAR_COMPONENT_VERSION("arm"), 11 T_META_OWNER("jharmening"), 12 XNU_T_META_SOC_SPECIFIC); 13 14 T_DECL(pmap_call_benchmark, "pmap call overhead benchmark", T_META_TAG_VM_NOT_ELIGIBLE) 15 { 16 int num_loops = 100000; 17 dt_stat_time_t s = dt_stat_time_create("average pmap function call overhead for %d calls", num_loops); 18 while (!dt_stat_stable(s)) { 19 dt_stat_token start = dt_stat_time_begin(s); 20 T_QUIET; T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.pmap_call_overhead_test", NULL, NULL, 21 &num_loops, sizeof(num_loops)), "invoke pmap call overhead test sysctl"); 22 dt_stat_time_end_batch(s, num_loops, start); 23 } 24 dt_stat_finalize(s); 25 } 26 27 T_DECL(pmap_page_protect_benchmark, "pmap_page_protect() overhead benchmark", T_META_TAG_VM_NOT_ELIGIBLE) 28 { 29 struct { 30 unsigned int num_loops; 31 unsigned int num_aliases; 32 } ppo_in; 33 ppo_in.num_loops = 1000; 34 uint64_t duration; 35 size_t duration_size = sizeof(duration); 36 for (ppo_in.num_aliases = 1; ppo_in.num_aliases <= 128; ppo_in.num_aliases <<= 1) { 37 T_QUIET; T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.pmap_page_protect_overhead_test", 38 &duration, &duration_size, &ppo_in, sizeof(ppo_in)), 39 "invoke pmap_page_protect() overhead test sysctl"); 40 T_LOG("%u-loop duration (in ticks) for %u aliases: %llu", ppo_in.num_loops, ppo_in.num_aliases, duration); 41 } 42 } 43