From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: colyli@suse.de, kent.overstreet@linux.dev, msakai@redhat.com,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org, akpm@linux-foundation.org
Cc: bfoster@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
jserv@ccns.ncku.edu.tw, dm-devel@lists.linux.dev,
linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org,
Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH v2 12/15] lib min_heap: Rename min_heapify() to min_heap_sift_down()
Date: Wed, 20 Mar 2024 22:54:14 +0800 [thread overview]
Message-ID: <20240320145417.336208-13-visitorckw@gmail.com> (raw)
In-Reply-To: <20240320145417.336208-1-visitorckw@gmail.com>
After adding min_heap_sift_up(), the naming convention has been
adjusted to maintain consistency with the min_heap_sift_up().
Consequently, min_heapify() has been renamed to min_heap_sift_down().
Link: https://lkml.kernel.org/CAP-5=fVcBAxt8Mw72=NCJPRJfjDaJcqk4rjbadgouAEAHz_q1A@mail.gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
drivers/md/dm-vdo/repair.c | 2 +-
include/linux/min_heap.h | 14 +++++++-------
kernel/events/core.c | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/md/dm-vdo/repair.c b/drivers/md/dm-vdo/repair.c
index 6acaebcd305d..e99f908bbdb9 100644
--- a/drivers/md/dm-vdo/repair.c
+++ b/drivers/md/dm-vdo/repair.c
@@ -183,7 +183,7 @@ static struct numbered_block_mapping *sort_next_heap_element(struct repair_compl
*/
last = &repair->entries[--heap->heap.nr];
swap_mappings(heap->heap.data, last, NULL);
- min_heapify(heap, 0, &repair_min_heap, NULL);
+ min_heap_sift_down(heap, 0, &repair_min_heap, NULL);
return last;
}
diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h
index 586965977104..436997070f4e 100644
--- a/include/linux/min_heap.h
+++ b/include/linux/min_heap.h
@@ -78,7 +78,7 @@ bool __min_heap_full(struct __min_heap *heap)
/* Sift the element at pos down the heap. */
static __always_inline
-void __min_heapify(struct __min_heap *heap, int pos, size_t elem_size,
+void __min_heap_sift_down(struct __min_heap *heap, int pos, size_t elem_size,
const struct min_heap_callbacks *func, void *args)
{
void *left, *right;
@@ -111,8 +111,8 @@ void __min_heapify(struct __min_heap *heap, int pos, size_t elem_size,
}
}
-#define min_heapify(_heap, _pos, _func, _args) \
- __min_heapify(&(_heap)->heap, _pos, __minheap_obj_size(_heap), _func, _args)
+#define min_heap_sift_down(_heap, _pos, _func, _args) \
+ __min_heap_sift_down(&(_heap)->heap, _pos, __minheap_obj_size(_heap), _func, _args)
/* Floyd's approach to heapification that is O(nr). */
static __always_inline
@@ -122,7 +122,7 @@ void __min_heapify_all(struct __min_heap *heap, size_t elem_size,
int i;
for (i = heap->nr / 2 - 1; i >= 0; i--)
- __min_heapify(heap, i, elem_size, func, args);
+ __min_heap_sift_down(heap, i, elem_size, func, args);
}
#define min_heapify_all(_heap, _func, _args) \
@@ -141,7 +141,7 @@ bool __min_heap_pop(struct __min_heap *heap, size_t elem_size,
/* Place last element at the root (position 0) and then sift down. */
heap->nr--;
memcpy(data, data + (heap->nr * elem_size), elem_size);
- __min_heapify(heap, 0, elem_size, func, args);
+ __min_heap_sift_down(heap, 0, elem_size, func, args);
return true;
}
@@ -161,7 +161,7 @@ void __min_heap_pop_push(struct __min_heap *heap,
void *args)
{
memcpy(heap->data, element, elem_size);
- __min_heapify(heap, 0, elem_size, func, args);
+ __min_heap_sift_down(heap, 0, elem_size, func, args);
}
#define min_heap_pop_push(_heap, _element, _func, _args) \
@@ -235,7 +235,7 @@ bool __min_heap_del(struct __min_heap *heap, size_t elem_size, size_t idx,
return true;
memcpy(data, data + (heap->nr * elem_size), elem_size);
__min_heap_sift_up(heap, elem_size, idx, func, args);
- __min_heapify(heap, idx, elem_size, func, args);
+ __min_heap_sift_down(heap, idx, elem_size, func, args);
return true;
}
diff --git a/kernel/events/core.c b/kernel/events/core.c
index c32a78c489f3..314fb7ea4ec3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3788,7 +3788,7 @@ static noinline int visit_groups_merge(struct perf_event_context *ctx,
*evt = perf_event_groups_next(*evt, pmu);
if (*evt)
- min_heapify(&event_heap, 0, &perf_min_heap, NULL);
+ min_heap_sift_down(&event_heap, 0, &perf_min_heap, NULL);
else
min_heap_pop(&event_heap, &perf_min_heap, NULL);
}
--
2.34.1
next prev parent reply other threads:[~2024-03-20 14:55 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 14:54 [PATCH v2 00/15] treewide: Refactor heap related implementation Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 01/15] perf/core: Fix several typos Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 02/15] bcache: Fix typo Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 03/15] bcachefs: " Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 04/15] lib min_heap: Add type safe interface Kuan-Wei Chiu
2024-03-20 20:56 ` Kent Overstreet
2024-03-21 11:57 ` Kuan-Wei Chiu
2024-03-21 21:22 ` Kent Overstreet
2024-03-22 17:02 ` Kuan-Wei Chiu
2024-03-22 18:23 ` Kent Overstreet
2024-03-23 1:53 ` Kuan-Wei Chiu
2024-03-23 2:08 ` Kent Overstreet
2024-03-23 2:19 ` Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 05/15] lib min_heap: Add min_heap_init() Kuan-Wei Chiu
2024-03-20 17:13 ` Ian Rogers
2024-03-20 17:17 ` Ian Rogers
2024-03-20 14:54 ` [PATCH v2 06/15] lib min_heap: Add min_heap_peek() Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 07/15] lib min_heap: Add min_heap_full() Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 08/15] lib min_heap: Add min_heap_del() Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 09/15] lib min_heap: Add min_heap_sift_up() Kuan-Wei Chiu
2024-03-20 17:15 ` Ian Rogers
2024-03-21 7:00 ` Kuan-Wei Chiu
2024-03-20 14:54 ` [PATCH v2 10/15] lib min_heap: Add args for min_heap_callbacks Kuan-Wei Chiu
2024-03-20 17:15 ` Ian Rogers
2024-03-20 14:54 ` [PATCH v2 11/15] lib min_heap: Update min_heap_push() and min_heap_pop() to return bool values Kuan-Wei Chiu
2024-03-20 14:54 ` Kuan-Wei Chiu [this message]
2024-03-20 17:17 ` [PATCH v2 12/15] lib min_heap: Rename min_heapify() to min_heap_sift_down() Ian Rogers
2024-03-20 14:54 ` [PATCH v2 13/15] lib/test_min_heap: Use min_heap_init() for initializing Kuan-Wei Chiu
2024-03-20 17:16 ` Ian Rogers
2024-03-20 14:54 ` [PATCH v2 14/15] bcache: Remove heap-related macros and switch to generic min_heap Kuan-Wei Chiu
2024-03-20 17:19 ` Ian Rogers
2024-03-20 14:54 ` [PATCH v2 15/15] bcachefs: " Kuan-Wei Chiu
2024-03-20 17:20 ` Ian Rogers
2024-03-20 19:57 ` [PATCH v2 00/15] treewide: Refactor heap related implementation Kent Overstreet
2024-03-21 7:08 ` Kuan-Wei Chiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240320145417.336208-13-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bfoster@redhat.com \
--cc=colyli@suse.de \
--cc=dm-devel@lists.linux.dev \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=jserv@ccns.ncku.edu.tw \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=msakai@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).