Introduce in kernel benchmarks
Subsystems (2)
cover Introduce in kernel benchmarks
In kernel benchmarks are benchmarks that directly run in kernel space.
The test modules are regular kernel modules that can be loaded with
modprobe slab_test
or so.
The initialization function of the module will then run the test and fail so that the module is not loaded. The output of the test results will be written to the system log.
This is a rough draft. I have used these in the past to benchmark page allocator, slab allocator and vmstat performance.
RFC 1/3 Add slab performance tests
This is a test of slab allocator performance tests.
Run
modprobe slab_test
to execute. Output will be written to the syslog.
--- Makefile | 2 include/Kbuild | 1 lib/Kconfig.debug | 1 tests/Kconfig | 19 ++ tests/Makefile | 2 tests/slab_test.c | 373 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 tests/Makefile create mode 100644 tests/slab_test.c
Makefile +1 -1
@@ -686,7 +686,7 @@ export mod_strip_cmd ifeq ($(KBUILD_EXTMOD),) -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ tests/ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
include/Kbuild +1 -0
@@ -10,3 +10,4 @@ header-y += video/ header-y += drm/ header-y += xen/ header-y += scsi/ +header-y += tests/
tests/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_BENCHMARK_SLAB) += slab_test.o +
tests/slab_test.c new file +373 -0
373 lines not on this page · raw message
lib/Kconfig.debug +1 -0
@@ -920,6 +920,7 @@ config SYSCTL_SYSCALL_CHECK source mm/Kconfig.debug source kernel/trace/Kconfig +source tests/Kconfig config PROVIDE_OHCI1394_DMA_INIT bool "Remote debugging over FireWire early on boot"
tests/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +menuconfig BENCHMARKS + bool "In kernel benchmarks" + def_bool n + help + Includes in kernel benchmark modules in the build. These modules can + be loaded later to trigger benchmarking kernel subsystems. + Output will be generated in the system log. + +if BENCHMARKS + +config BENCHMARK_SLAB + tristate "Slab allocator Benchmark" + depends on m + default m + help + A benchmark that measures slab allocator performance. + +endif # BENCHMARKS +
RFC 2/3 Vm statistics performance test
In reply to Christoph LameterTests the performance of some key vm statistics functions.
--- tests/Kconfig | 7 +++ tests/Makefile | 1 tests/vmstat_test.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 tests/vmstat_test.c
tests/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_BENCHMARK_SLAB) += slab_test.o +obj-#(CONFIG_BENCHMARK_VMSTAT) += vmstat_test.o
tests/vmstat_test.c new file +97 -0
97 lines not on this page · raw message
tests/Kconfig +7 -0
@@ -15,5 +15,12 @@ config BENCHMARK_SLAB help A benchmark that measures slab allocator performance. +config BENCHMARK_VMSTAT + tristate "VM statistics Benchmark" + default m + depends on m + help + A benchmark measuring the performance of vm statistics. + endif # BENCHMARKS
RFC 3/3 Page allocator test
In reply to Christoph LameterImplement a test of the page allocator speed in the same way as for the slab allocators.
--- tests/Kconfig | 7 + tests/Makefile | 3 tests/pagealloc_test.c | 334 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 tests/page_test.c
tests/Makefile +2 -1
@@ -1,3 +1,4 @@ obj-$(CONFIG_BENCHMARK_SLAB) += slab_test.o -obj-#(CONFIG_BENCHMARK_VMSTAT) += vmstat_test.o +obj-$(CONFIG_BENCHMARK_VMSTAT) += vmstat_test.o +obj-$(CONFIG_BENCHMARK_PAGEALLOC) += pagealloc_test.o
tests/pagealloc_test.c new file +334 -0
334 lines not on this page · raw message
tests/Kconfig +7 -0
@@ -22,5 +22,12 @@ config BENCHMARK_VMSTAT help A benchmark measuring the performance of vm statistics. +config BENCHMARK_PAGEALLOC + tristate "Page Allocator Benchmark" + default m + depends on m + help + A benchmark measuring the performance of the page allocator. + endif # BENCHMARKS
Quoted 6 lines · Christoph Lameter
In kernel benchmarks are benchmarks that directly run in kernel space.
The test modules are regular kernel modules that can be loaded with
modprobe
slab_test
Quoted 9 lines
or so.
The initialization function of the module will then run the test and fail so that the module is not loaded. The output of the test results will be written to the system log.
This is a rough draft. I have used these in the past to benchmark page allocator, slab allocator and vmstat performance.
I like the addition of these benchmarks to the kernel source, I've been adding Mathieu's slab benchmark to my tree for a while. It looks like they all need some degree of cleanup, though: they have checkpatch warnings, they frequently do not handle memory allocation failures, and it would be nice to have a consistent loglevel for all the results.