From 39aaf091ae0a88a7f84c50d52aff84c36caeadaa Mon Sep 17 00:00:00 2001 From: Dmitry Rokosov Date: Tue, 6 Feb 2024 22:25:33 +0300 Subject: [PATCH] package/linux-tools: introduce linux mm tools This toolset was designed to facilitate the testing, monitoring, and tracing of various things with virtual memory, pages, and slab objects. It is an invaluable resource for identifying and analyzing memory-related issues, such as leaks and bottlenecks, and can greatly enhance one's understanding of memory utilization within a system. The mm toolset includes: - page_owner_sort: userspace helper to sort the output of /sys/kernel/debug/page_owner, which helps to know who allocates the page from kernel context - slabinfo: the tool which gets reports about slabs, for example show empty slabs, modify of slab debug options at runtime, display all information about a slabcache - page-types: a handy tool for querying page flags Signed-off-by: Dmitry Rokosov Signed-off-by: Alexey Romanov [yann.morin.1998@free.fr: - don't depend on linux, already a patch dependency - don't set CC: default is based on CROSS_COMPILE - no need to fully recheck at install time - move the option for alphabetical ordering - fix check-package ] Signed-off-by: Yann E. MORIN --- package/linux-tools/Config.in | 19 +++++++++++++ package/linux-tools/linux-tool-mm.mk.in | 37 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 package/linux-tools/linux-tool-mm.mk.in diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in index fb158f84d4..5a38f6dafe 100644 --- a/package/linux-tools/Config.in +++ b/package/linux-tools/Config.in @@ -38,6 +38,25 @@ config BR2_PACKAGE_LINUX_TOOLS_IIO These tools are available only from kernel version 4.7. +config BR2_PACKAGE_LINUX_TOOLS_MM + bool "mm" + select BR2_PACKAGE_LINUX_TOOLS + help + mm is a toolset for testing/monitoring/tracing vm/pages/slabs + objects. + + - page_owner_sort: userspace helper to sort the output of + /sys/kernel/debug/page_owner, which helps to know who + allocates the page from kernel context + + - slabinfo: the tool which gets reports about slabs, for + example show empty slabs, modify of slab debug options at + runtime, display all information about a slabcache + + - page-types: a handy tool for querying page flags + + These tools are available only from kernel version 3.4. + config BR2_PACKAGE_LINUX_TOOLS_PCI bool "pci" select BR2_PACKAGE_LINUX_TOOLS diff --git a/package/linux-tools/linux-tool-mm.mk.in b/package/linux-tools/linux-tool-mm.mk.in new file mode 100644 index 0000000000..b2ec090fc0 --- /dev/null +++ b/package/linux-tools/linux-tool-mm.mk.in @@ -0,0 +1,37 @@ +################################################################################ +# +# mm +# +################################################################################ + +LINUX_TOOLS += mm + +define MM_BUILD_CMDS + $(Q)if test -f $(LINUX_DIR)/tools/vm/Makefile ; then \ + MM_SUBDIR=vm; \ + elif test -f $(LINUX_DIR)/tools/mm/Makefile ; then \ + MM_SUBDIR=mm; \ + else \ + echo "Your kernel version is too old and does not have the mm tool." ; \ + echo "At least kernel 3.4 must be used." ; \ + exit 1 ; \ + fi ; \ + $(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR)/tools \ + $(MM_MAKE_OPTS) $${MM_SUBDIR} +endef + +# For install no need to recheck both cases: we know at least one +# exists, because that was checked at build time already; we just +# need to find which of the two: if not one, then the other. +define MM_INSTALL_TARGET_CMDS + $(Q)if test -f $(LINUX_DIR)/tools/vm/Makefile ; then \ + MM_SUBDIR=vm; \ + else \ + MM_SUBDIR=mm; \ + fi ; \ + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(LINUX_MAKE_FLAGS) \ + INSTALL_ROOT=$(TARGET_DIR) \ + DESTDIR=$(TARGET_DIR) \ + $${MM_SUBDIR}_install +endef