[Buildroot] [PATCH v2 1/2] package/linux-tools: introduce linux mm tools

Dmitry Rokosov ddrokosov at salutedevices.com
Tue Feb 6 19:25:33 UTC 2024


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 <ddrokosov at salutedevices.com>
Signed-off-by: Alexey Romanov <avromanov at salutedevices.com>
---
 package/linux-tools/Config.in           | 18 +++++++++++
 package/linux-tools/linux-tool-mm.mk.in | 41 +++++++++++++++++++++++++
 2 files changed, 59 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 8a0b6d5802cc..ede966ec792d 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -185,4 +185,22 @@ config BR2_PACKAGE_LINUX_TOOLS_HV_VSS_DAEMON
 
 endif # BR2_PACKAGE_LINUX_TOOLS_HV
 
+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.
+
 endmenu
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 000000000000..5431e0574b04
--- /dev/null
+++ b/package/linux-tools/linux-tool-mm.mk.in
@@ -0,0 +1,41 @@
+################################################################################
+#
+# mm
+#
+################################################################################
+
+LINUX_TOOLS += mm
+
+MM_DEPENDENCIES = linux
+MM_MAKE_OPTS = $(LINUX_MAKE_FLAGS) CC="$(TARGET_CC)"
+
+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) -C $(LINUX_DIR)/tools \
+		$(MM_MAKE_OPTS) $${MM_SUBDIR}
+endef
+
+define MM_INSTALL_TARGET_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) -C $(LINUX_DIR)/tools \
+		$(MM_MAKE_OPTS) \
+		INSTALL_ROOT=$(TARGET_DIR) \
+		DESTDIR=$(TARGET_DIR) \
+		$${MM_SUBDIR}_install
+endef
-- 
2.43.0




More information about the buildroot mailing list