Skip to contentSkip to conversation

alloc_tag-support-for-page-allocation-tag-compression.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Nov 6, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: alloc_tag: support for page allocation tag compression
has been removed from the -mm tree. Its filename was
alloc_tag-support-for-page-allocation-tag-compression.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Suren Baghdasaryan <[email protected]>
Subject: alloc_tag: support for page allocation tag compression
Date: Wed, 23 Oct 2024 10:07:59 -0700

Implement support for storing page allocation tag references directly in the page flags instead of page extensions. sysctl.vm.mem_profiling boot parameter it extended to provide a way for a user to request this mode. Enabling compression eliminates memory overhead caused by page_ext and results in better performance for page allocations. However this mode will not work if the number of available page flag bits is insufficient to address all kernel allocations. Such condition can happen during boot or when loading a module. If this condition is detected, memory allocation profiling gets disabled with an appropriate warning. By default compression mode is disabled.

Cc Ard Biesheuvel <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Borislav Petkov (AMD) <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Daniel Gomez <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Davidlohr Bueso <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc John Hubbard <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kalesh Singh <[email protected]>
Cc Kees Cook <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport (Microsoft) <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Petr Pavlu <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Sami Tolvanen <[email protected]>
Cc Sourav Panda <[email protected]>
Cc Steven Rostedt (Google) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Uladzislau Rezki (Sony) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Xiongwei Song <[email protected]>
Cc Yu Zhao <[email protected]>

---

 Documentation/mm/allocation-profiling.rst |    7 
 include/linux/alloc_tag.h                 |   10 +
 include/linux/codetag.h                   |    3 
 include/linux/page-flags-layout.h         |    7 
 include/linux/pgalloc_tag.h               |  143 +++++++++++++++++---
 lib/alloc_tag.c                           |  142 ++++++++++++++++++-
 lib/codetag.c                             |    4 
 mm/mm_init.c                              |    5 
 8 files changed, 289 insertions(+), 32 deletions(-)
Documentation/mm/allocation-profiling.rst renamed from Documentation/mm/allocation-profiling.rst~alloc_tag-support-for-page-allocation-tag-compression +6 -1
@@ -18,12 +18,17 @@ kconfig options:
   missing annotation
 
 Boot parameter:
-  sysctl.vm.mem_profiling=0|1|never
+  sysctl.vm.mem_profiling={0|1|never}[,compressed]
 
   When set to "never", memory allocation profiling overhead is minimized and it
   cannot be enabled at runtime (sysctl becomes read-only).
   When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, default value is "1".
   When CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=n, default value is "never".
+  "compressed" optional parameter will try to store page tag references in a
+  compact format, avoiding page extensions. This results in improved performance
+  and memory consumption, however it might fail depending on system configuration.
+  If compression fails, a warning is issued and memory allocation profiling gets
+  disabled.
 
 sysctl:
   /proc/sys/vm/mem_profiling
include/linux/alloc_tag.h renamed from include/linux/alloc_tag.h~alloc_tag-support-for-page-allocation-tag-compression +9 -1
@@ -30,8 +30,16 @@ struct alloc_tag {
 	struct alloc_tag_counters __percpu	*counters;
 } __aligned(8);
 
+struct alloc_tag_kernel_section {
+	struct alloc_tag *first_tag;
+	unsigned long count;
+};
+
 struct alloc_tag_module_section {
-	unsigned long start_addr;
+	union {
+		unsigned long start_addr;
+		struct alloc_tag *first_tag;
+	};
 	unsigned long end_addr;
 	/* used size */
 	unsigned long size;
include/linux/codetag.h renamed from include/linux/codetag.h~alloc_tag-support-for-page-allocation-tag-compression +3 -0
@@ -13,6 +13,9 @@ struct codetag_module;
 struct seq_buf;
 struct module;
 
+#define CODETAG_SECTION_START_PREFIX	"__start_"
+#define CODETAG_SECTION_STOP_PREFIX	"__stop_"
+
 /*
  * An instance of this structure is created in a special ELF section at every
  * code location being tagged.  At runtime, the special section is treated as
include/linux/page-flags-layout.h renamed from include/linux/page-flags-layout.h~alloc_tag-support-for-page-allocation-tag-compression +7 -0
@@ -111,5 +111,12 @@
 			    ZONES_WIDTH - LRU_GEN_WIDTH - SECTIONS_WIDTH - \
 			    NODES_WIDTH - KASAN_TAG_WIDTH - LAST_CPUPID_WIDTH)
 
+#define NR_NON_PAGEFLAG_BITS	(SECTIONS_WIDTH + NODES_WIDTH + ZONES_WIDTH + \
+				LAST_CPUPID_SHIFT + KASAN_TAG_WIDTH + \
+				LRU_GEN_WIDTH + LRU_REFS_WIDTH)
+
+#define NR_UNUSED_PAGEFLAG_BITS	(BITS_PER_LONG - \
+				(NR_NON_PAGEFLAG_BITS + NR_PAGEFLAGS))
+
 #endif
 #endif /* _LINUX_PAGE_FLAGS_LAYOUT */
include/linux/pgalloc_tag.h renamed from include/linux/pgalloc_tag.h~alloc_tag-support-for-page-allocation-tag-compression +127 -16

184 lines not on this page · raw message

lib/alloc_tag.c renamed from lib/alloc_tag.c~alloc_tag-support-for-page-allocation-tag-compression +133 -9

241 lines not on this page · raw message

lib/codetag.c renamed from lib/codetag.c~alloc_tag-support-for-page-allocation-tag-compression +2 -2
@@ -149,8 +149,8 @@ static struct codetag_range get_section_
 					      const char *section)
 {
 	return (struct codetag_range) {
-		get_symbol(mod, "__start_", section),
-		get_symbol(mod, "__stop_", section),
+		get_symbol(mod, CODETAG_SECTION_START_PREFIX, section),
+		get_symbol(mod, CODETAG_SECTION_STOP_PREFIX, section),
 	};
 }
 
mm/mm_init.c renamed from mm/mm_init.c~alloc_tag-support-for-page-allocation-tag-compression +2 -3
@@ -83,8 +83,7 @@ void __init mminit_verify_pageflags_layo
 	unsigned long or_mask, add_mask;
 
 	shift = BITS_PER_LONG;
-	width = shift - SECTIONS_WIDTH - NODES_WIDTH - ZONES_WIDTH
-		- LAST_CPUPID_SHIFT - KASAN_TAG_WIDTH - LRU_GEN_WIDTH - LRU_REFS_WIDTH;
+	width = shift - NR_NON_PAGEFLAG_BITS;
 	mminit_dprintk(MMINIT_TRACE, "pageflags_layout_widths",
 		"Section %d Node %d Zone %d Lastcpupid %d Kasantag %d Gen %d Tier %d Flags %d\n",
 		SECTIONS_WIDTH,
@@ -2639,7 +2638,7 @@ void __init mm_core_init(void)
 	BUILD_BUG_ON(MAX_ZONELISTS > 2);
 	build_all_zonelists(NULL);
 	page_alloc_init_cpuhp();
-
+	alloc_tag_sec_init();
 	/*
 	 * page_ext requires contiguous pages,
 	 * bigger than MAX_PAGE_ORDER unless SPARSEMEM.

_

Patches currently in -mm which might be from [email protected] are

mm-convert-mm_lock_seq-to-a-proper-seqcount.patch
mm-introduce-mmap_lock_speculation_beginend.patch