From: Gabriele Monaco <gmonaco@redhat.com>
To: wen.yang@linux.dev
Cc: Nam Cao <namcao@linutronix.de>,
linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 08/14] rv: Support embedded target types in per-object DA storage
Date: Fri, 20 Nov 2026 09:12:30 +0100 [thread overview]
Message-ID: <0a593f7ba6372245497cb9ac58dad1b71f9a2f4b.camel@redhat.com> (raw)
In-Reply-To: <49fd8e0482d2cf1f9c690031ab0cf9cc1eb1c5ad.1793900349.git.wen.yang@linux.dev>
On Fri, 2026-11-06 at 01:49 +0800, wen.yang@linux.dev wrote:
> From: Wen Yang <wen.yang@linux.dev>
>
> A PER_OBJ monitor usually typedefs monitor_target itself, as a pointer to
> the monitored object (borrowed: the object exists independently of the
> monitor and outlives the storage).
>
> A monitor whose target is monitor-owned data can instead define
> DA_OBJ_EMBEDDED_TYPE with a complete struct type: the framework then
> derives monitor_target as a pointer to it, embeds one instance in each
> per-object storage, and allocates and frees it together with the storage.
> On storage creation the caller-supplied target is shallow-copied into
> the storage before it is published, so it may be a fully initialised
> stack object.
>
> This allows per-object monitors to manage custom per-instance data without
> maintaining private mempools, complex multi-stage reference counting, or
> out-of-band teardown state machines.
>
> Suggested-by: Gabriele Monaco <gmonaco@redhat.com>
> Signed-off-by: Wen Yang <wen.yang@linux.dev>
> ---
Looks good, just a minor comment.
> /*
> * da_get_target - return the object associated to the monitor
> + *
> + * NULL for an embedded target whose storage was pre-allocated but not filled
> + * yet: a manual-allocation monitor publishes its storage before it has one.
> */
> static inline monitor_target da_get_target(struct da_monitor *da_mon)
> {
> - return container_of(da_mon, struct da_monitor_storage, rv.da_mon)-
> >target;
> + struct da_monitor_storage *mon_storage =
> + container_of(da_mon, struct da_monitor_storage, rv.da_mon);
> +
> +#ifdef DA_OBJ_EMBEDDED_TYPE
> + if (unlikely(da_storage_is_empty(mon_storage)))
> + return NULL;
> +#endif
We usually avoid ifdeffery inside functions like plague..
Could you embed this in TARGET_PTR?
#define TARGET_PTR(storage) (unlikely(da_storage_is_empty(mon_storage)) ? NULL : &(storage)->target)
> + return TARGET_PTR(mon_storage);
> }
>
> /*
> @@ -572,8 +635,11 @@ static inline struct da_monitor
> *da_fill_empty_storage(da_id_type id,
> monitor_target target,
> struct da_monitor
> *da_mon)
> {
> - if (unlikely(da_mon && !da_get_target(da_mon)))
> - container_of(da_mon, struct da_monitor_storage, rv.da_mon)-
> >target = target;
> + struct da_monitor_storage *mon_storage =
> + container_of(da_mon, struct da_monitor_storage, rv.da_mon);
> +
> + if (unlikely(da_mon && da_storage_is_empty(mon_storage)))
> + da_storage_set_target(mon_storage, target);
> return da_mon;
> }
>
> @@ -589,7 +655,11 @@ static inline monitor_target
> da_get_target_by_id(da_id_type id)
>
> if (unlikely(!mon_storage))
> return NULL;
> - return mon_storage->target;
> +#ifdef DA_OBJ_EMBEDDED_TYPE
> + if (unlikely(da_storage_is_empty(mon_storage)))
> + return NULL;
> +#endif
Same here.
> + return TARGET_PTR(mon_storage);
> }
Thanks,
Gabriele
>
> static void da_kfree_cb(struct rcu_head *head)
> @@ -635,7 +705,7 @@ da_create_pool_storage(da_id_type id, monitor_target
> target,
> memset(mon_storage, 0, sizeof(*mon_storage));
>
> mon_storage->id = id;
> - mon_storage->target = target;
> + da_storage_set_target(mon_storage, target);
>
> hash_add_rcu(da_monitor_ht, &mon_storage->node, id);
> return &mon_storage->rv.da_mon;
next prev parent reply other threads:[~2026-11-20 8:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 17:49 [PATCH v8 00/14] rv: Add task latency over budget RV monitor wen.yang
2026-11-05 17:49 ` [PATCH v8 01/14] rv: Force environment reset action on HA monitor start wen.yang
2026-11-05 17:49 ` [PATCH v8 02/14] rv: Fix ha_monitor timer and invariant underflow wen.yang
2026-11-19 14:34 ` Gabriele Monaco
2026-11-05 17:49 ` [PATCH v8 03/14] rv: Add a KUnit test for the HA timer underflow wen.yang
2026-11-19 15:07 ` Gabriele Monaco
2026-11-05 17:49 ` [PATCH v8 04/14] rv: Disarm HA timers on the storage free path wen.yang
2026-11-05 17:49 ` [PATCH v8 05/14] rv: Add a KUnit test for " wen.yang
2026-11-05 17:49 ` [PATCH v8 06/14] rv: Make da_monitor_reset_hook, sync_hook and EVENT_NONE_LBL overridable wen.yang
2026-11-05 17:49 ` [PATCH v8 07/14] rv: Introduce DA_MON_ALLOCATION_STRATEGY wen.yang
2026-11-05 17:49 ` [PATCH v8 08/14] rv: Support embedded target types in per-object DA storage wen.yang
2026-11-20 8:12 ` Gabriele Monaco [this message]
2026-11-05 17:49 ` [PATCH v8 09/14] rv: Add generic uprobe infrastructure for RV monitors wen.yang
2026-11-05 17:49 ` [PATCH v8 10/14] rv: Add tlob model DOT file wen.yang
2026-11-05 17:49 ` [PATCH v8 11/14] rv: Add tlob hybrid automaton monitor wen.yang
2026-11-05 17:49 ` [PATCH v8 12/14] rv: Add KUnit tests for the tlob monitor wen.yang
2026-11-05 17:49 ` [PATCH v8 13/14] selftests/verification: Add tlob selftests wen.yang
2026-11-05 17:49 ` [PATCH v8 14/14] selftests/ftrace: Walk up parent dirs to find test.d/functions wen.yang
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=0a593f7ba6372245497cb9ac58dad1b71f9a2f4b.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=wen.yang@linux.dev \
/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