From: Peter Zijlstra <peterz@infradead.org>
To: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: colyli@suse.de, kent.overstreet@linux.dev, msakai@redhat.com,
mingo@redhat.com, acme@kernel.org, namhyung@kernel.org,
akpm@linux-foundation.org, 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, linux-bcache@vger.kernel.org,
linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev,
linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 04/17] lib min_heap: Add type safe interface
Date: Fri, 12 Apr 2024 09:30:17 +0200 [thread overview]
Message-ID: <20240412073017.GE30852@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20240406164727.577914-5-visitorckw@gmail.com>
On Sun, Apr 07, 2024 at 12:47:14AM +0800, Kuan-Wei Chiu wrote:
> -struct min_heap {
> - void *data;
> - int nr;
> - int size;
> -};
> +#define MIN_HEAP_PREALLOCATED(_type, _name, _nr) \
> +struct _name { \
> + int nr; \
> + int size; \
> + _type *data; \
> + _type preallocated[_nr]; \
> +}
> @@ -3738,7 +3739,7 @@ static noinline int visit_groups_merge(struct perf_event_context *ctx,
> struct perf_cpu_context *cpuctx = NULL;
> /* Space for per CPU and/or any CPU event iterators. */
> struct perf_event *itrs[2];
> - struct min_heap event_heap;
> + struct perf_event_min_heap event_heap;
> struct perf_event **evt;
> int ret;
>
> @@ -3747,11 +3748,9 @@ static noinline int visit_groups_merge(struct perf_event_context *ctx,
>
> if (!ctx->task) {
> cpuctx = this_cpu_ptr(&perf_cpu_context);
> - event_heap = (struct min_heap){
> - .data = cpuctx->heap,
> - .nr = 0,
> - .size = cpuctx->heap_size,
> - };
> + event_heap.data = cpuctx->heap;
> + event_heap.nr = 0;
> + event_heap.size = cpuctx->heap_size;
>
> lockdep_assert_held(&cpuctx->ctx.lock);
>
> @@ -3760,11 +3759,9 @@ static noinline int visit_groups_merge(struct perf_event_context *ctx,
> css = &cpuctx->cgrp->css;
> #endif
> } else {
> - event_heap = (struct min_heap){
> - .data = itrs,
> - .nr = 0,
> - .size = ARRAY_SIZE(itrs),
> - };
> + event_heap.data = itrs;
> + event_heap.nr = 0;
> + event_heap.size = ARRAY_SIZE(itrs);
> /* Events not within a CPU context may be on any CPU. */
> __heap_add(&event_heap, perf_event_groups_first(groups, -1, pmu, NULL));
> }
Not too happy about these. If you ever add more fields they will go
uninitialized. Why not keep the existing form and fix the struct name?
next prev parent reply other threads:[~2024-04-12 7:30 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 16:47 [PATCH v3 00/17] treewide: Refactor heap related implementation Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 01/17] perf/core: Fix several typos Kuan-Wei Chiu
2024-04-06 17:30 ` Randy Dunlap
2024-04-06 16:47 ` [PATCH v3 02/17] bcache: Fix typo Kuan-Wei Chiu
2024-04-06 17:31 ` Randy Dunlap
2024-04-06 16:47 ` [PATCH v3 03/17] bcachefs: " Kuan-Wei Chiu
2024-04-06 17:31 ` Randy Dunlap
2024-04-06 16:47 ` [PATCH v3 04/17] lib min_heap: Add type safe interface Kuan-Wei Chiu
2024-04-12 7:30 ` Peter Zijlstra [this message]
2024-04-15 17:35 ` Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 05/17] lib min_heap: Add min_heap_init() Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 06/17] lib min_heap: Add min_heap_peek() Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 07/17] lib min_heap: Add min_heap_full() Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 08/17] lib min_heap: Add args for min_heap_callbacks Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 09/17] lib min_heap: Add min_heap_sift_up() Kuan-Wei Chiu
2024-04-07 19:10 ` Ian Rogers
2024-04-06 16:47 ` [PATCH v3 10/17] lib min_heap: Add min_heap_del() Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 11/17] lib min_heap: Update min_heap_push() and min_heap_pop() to return bool values Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 12/17] lib min_heap: Rename min_heapify() to min_heap_sift_down() Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 13/17] lib min_heap: Update min_heap_push() to use min_heap_sift_up() Kuan-Wei Chiu
2024-04-07 19:11 ` Ian Rogers
2024-04-06 16:47 ` [PATCH v3 14/17] lib/test_min_heap: Use min_heap_init() for initializing Kuan-Wei Chiu
2024-04-06 16:47 ` [PATCH v3 15/17] lib/test_min_heap: Add test for heap_del() Kuan-Wei Chiu
2024-04-07 19:23 ` Ian Rogers
2024-04-06 16:47 ` [PATCH v3 16/17] bcache: Remove heap-related macros and switch to generic min_heap Kuan-Wei Chiu
2024-04-09 8:00 ` Coly Li
2024-04-09 8:11 ` Coly Li
2024-04-06 16:47 ` [PATCH v3 17/17] bcachefs: " Kuan-Wei Chiu
2024-04-09 3:40 ` [PATCH v3 00/17] treewide: Refactor heap related implementation Kent Overstreet
2024-04-09 8:17 ` Coly Li
2024-04-22 20:20 ` Kent Overstreet
2024-04-23 9:35 ` 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=20240412073017.GE30852@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--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=visitorckw@gmail.com \
/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