Skip to contentSkip to conversation

lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions.patch removed from -mm tree

merged mm-nonmm-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: lib/min_heap: introduce non-inline versions of min heap API functions
has been removed from the -mm tree. Its filename was
lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions.patch

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

------------------------------------------------------
From: Kuan-Wei Chiu <[email protected]>
Subject: lib/min_heap: introduce non-inline versions of min heap API functions
Date: Sun, 20 Oct 2024 12:01:51 +0800

Patch series "Enhance min heap API with non-inline functions and optimizations", v2.

Add non-inline versions of the min heap API functions in lib/min_heap.c and updates all users outside of kernel/events/core.c to use these non-inline versions. To mitigate the performance impact of indirect function calls caused by the non-inline versions of the swap and compare functions, a builtin swap has been introduced that swaps elements based on their size. Additionally, it micro-optimizes the efficiency of the min heap by pre-scaling the counter, following the same approach as in lib/sort.c. Documentation for the min heap API has also been added to the core-api section.

This patch (of 10):

All current min heap API functions are marked with '__always_inline'. However, as the number of users increases, inlining these functions everywhere leads to a increase in kernel size.

In performance-critical paths, such as when perf events are enabled and min heap functions are called on every context switch, it is important to retain the inline versions for optimal performance. To balance this, the original inline functions are kept, and additional non-inline versions of the functions have been added in lib/min_heap.c.

Cc Adrian Hunter <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Ching-Chun (Jim) Huang <[email protected]>
Cc Coly Li <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Kent Overstreet <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc "Liang, Kan" <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Matthew Sakai <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>

---

 drivers/md/bcache/Kconfig |    1 
 drivers/md/dm-vdo/Kconfig |    1 
 fs/bcachefs/Kconfig       |    1 
 include/linux/min_heap.h  |  129 ++++++++++++++++++++++++------------
 kernel/events/core.c      |    6 -
 lib/Kconfig               |    3 
 lib/Kconfig.debug         |    1 
 lib/Makefile              |    1 
 lib/min_heap.c            |   70 +++++++++++++++++++
 9 files changed, 167 insertions(+), 46 deletions(-)
drivers/md/bcache/Kconfig renamed from drivers/md/bcache/Kconfig~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +1 -0
@@ -5,6 +5,7 @@ config BCACHE
 	select BLOCK_HOLDER_DEPRECATED if SYSFS
 	select CRC64
 	select CLOSURES
+	select MIN_HEAP
 	help
 	Allows a block device to be used as cache for other devices; uses
 	a btree for indexing and the layout is optimized for SSDs.
drivers/md/dm-vdo/Kconfig renamed from drivers/md/dm-vdo/Kconfig~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +1 -0
@@ -7,6 +7,7 @@ config DM_VDO
 	select DM_BUFIO
 	select LZ4_COMPRESS
 	select LZ4_DECOMPRESS
+	select MIN_HEAP
 	help
 	  This device mapper target presents a block device with
 	  deduplication, compression and thin-provisioning.
fs/bcachefs/Kconfig renamed from fs/bcachefs/Kconfig~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +1 -0
@@ -24,6 +24,7 @@ config BCACHEFS_FS
 	select XXHASH
 	select SRCU
 	select SYMBOLIC_ERRNAME
+	select MIN_HEAP
 	help
 	The bcachefs filesystem - a modern, copy on write filesystem, with
 	support for multiple devices, compression, checksumming, etc.
include/linux/min_heap.h renamed from include/linux/min_heap.h~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +86 -43

231 lines not on this page · raw message

kernel/events/core.c renamed from kernel/events/core.c~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +3 -3
@@ -3870,7 +3870,7 @@ static noinline int visit_groups_merge(s
 		perf_assert_pmu_disabled((*evt)->pmu_ctx->pmu);
 	}
 
-	min_heapify_all(&event_heap, &perf_min_heap, NULL);
+	min_heapify_all_inline(&event_heap, &perf_min_heap, NULL);
 
 	while (event_heap.nr) {
 		ret = func(*evt, data);
@@ -3879,9 +3879,9 @@ static noinline int visit_groups_merge(s
 
 		*evt = perf_event_groups_next(*evt, pmu);
 		if (*evt)
-			min_heap_sift_down(&event_heap, 0, &perf_min_heap, NULL);
+			min_heap_sift_down_inline(&event_heap, 0, &perf_min_heap, NULL);
 		else
-			min_heap_pop(&event_heap, &perf_min_heap, NULL);
+			min_heap_pop_inline(&event_heap, &perf_min_heap, NULL);
 	}
 
 	return 0;
lib/Kconfig renamed from lib/Kconfig~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +3 -0
@@ -780,3 +780,6 @@ config FIRMWARE_TABLE
 
 config UNION_FIND
 	bool
+
+config MIN_HEAP
+	bool
lib/Kconfig.debug renamed from lib/Kconfig.debug~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +1 -0
@@ -2279,6 +2279,7 @@ config TEST_LIST_SORT
 config TEST_MIN_HEAP
 	tristate "Min heap test"
 	depends on DEBUG_KERNEL || m
+	select MIN_HEAP
 	help
 	  Enable this to turn on min heap function tests. This test is
 	  executed only once during system boot (so affects only boot time),
lib/Makefile renamed from lib/Makefile~lib-min_heap-introduce-non-inline-versions-of-min-heap-api-functions +1 -0
@@ -40,6 +40,7 @@ lib-y := ctype.o string.o vsprintf.o cmd
 lib-$(CONFIG_UNION_FIND) += union_find.o
 lib-$(CONFIG_PRINTK) += dump_stack.o
 lib-$(CONFIG_SMP) += cpumask.o
+lib-$(CONFIG_MIN_HEAP) += min_heap.o
 
 lib-y	+= kobject.o klist.o
 obj-y	+= lockref.o
lib/min_heap.c new file +70 -0

70 lines not on this page · raw message

_

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