Skip to content

Commit b6fd177

Browse files
dcpleungnashif
authored andcommitted
test: mem_protect/demand_paging: support using timing funcs
This adds bits to support using timing functions for displaying paging histograms. Currently on qemu_x86_tiny is supported. Also shorten the test names. Signed-off-by: Daniel Leung <[email protected]>
1 parent 09e8db3 commit b6fd177

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

tests/kernel/mem_protect/demand_paging/src/main.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <ztest.h>
88
#include <sys/mem_manage.h>
9+
#include <timing/timing.h>
910
#include <mmu.h>
1011

1112
#ifdef CONFIG_BACKING_STORE_RAM_PAGES
@@ -14,6 +15,44 @@
1415
#error "Unsupported configuration"
1516
#endif
1617

18+
#ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM
19+
#ifdef CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS
20+
21+
#ifdef CONFIG_BOARD_QEMU_X86
22+
unsigned long
23+
z_eviction_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
24+
10000,
25+
20000,
26+
30000,
27+
40000,
28+
50000,
29+
60000,
30+
70000,
31+
80000,
32+
100000,
33+
ULONG_MAX
34+
};
35+
36+
unsigned long
37+
z_backing_store_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
38+
10000,
39+
50000,
40+
100000,
41+
150000,
42+
200000,
43+
250000,
44+
500000,
45+
750000,
46+
1000000,
47+
ULONG_MAX
48+
};
49+
#else
50+
#error "Need to define paging histogram bounds"
51+
#endif
52+
53+
#endif /* CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS */
54+
#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
55+
1756
size_t arena_size;
1857
char *arena;
1958

@@ -316,7 +355,11 @@ bool print_histogram(struct k_mem_paging_histogram_t *hist)
316355
for (idx = 0;
317356
idx < CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS;
318357
idx++) {
358+
#ifdef CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS
359+
time_ns = timing_cycles_to_ns(hist->bounds[idx]);
360+
#else
319361
time_ns = k_cyc_to_ns_ceil64(hist->bounds[idx]);
362+
#endif
320363
printk(" <= %llu ns (%lu cycles): %lu\n", time_ns,
321364
hist->bounds[idx], hist->counts[idx]);
322365
if (hist->counts[idx] > 0U) {
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
tests:
2-
kernel.memory_protection.demand_paging:
2+
kernel.demand_paging:
33
tags: kernel mmu demand_paging ignore_faults
44
filter: CONFIG_DEMAND_PAGING
5+
kernel.demand_paging.timing_funcs:
6+
tags: kernel mmu demand_paging ignore_faults
7+
platform_allow: qemu_x86_tiny
8+
filter: CONFIG_DEMAND_PAGING
9+
extra_configs:
10+
# The timing functions take up some more memory.
11+
# So need to shrink an even number of page to
12+
# compensate for that (default is 16).
13+
- CONFIG_BACKING_STORE_RAM_PAGES=14
14+
- CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS=y

0 commit comments

Comments
 (0)