[DTrace-devel] [PATCH] Action clear() should clear only one aggregation

Eugene Loh eugene.loh at oracle.com
Thu Aug 15 17:14:27 UTC 2024


On 8/14/24 21:06, Kris Van Hees wrote:

> On Wed, Aug 14, 2024 at 07:05:44PM -0400, Eugene Loh wrote:
>> On 8/14/24 18:28, Kris Van Hees wrote:
>>> given that dtrace_aggregate_walk() is an API function that is exported
>>> by libdtrace, we should not change it.
>>>
>>> So, I'd propose that instead of introducing a new function, we can make use
>>> of the existing dtrace_aggregate_walk() by passing both dtp and the aid as an
>>> arg struct.  E.g.
>>>
>>> typedef struct dt_clear_arg {
>>> 	dtrace_hdl_t	*dtp;
>>> 	dtrace_aggid_t	aid;
>>> } dt_clear_arg_t;
>> Hmm.  Then both dt_consume.c and dt_aggregate.c need to know about this new
>> struct.  So, copy it to both files?  Introduce a new dt_aggregate.h?  Ick.
> It would be appropriate to add it to dt_aggregate.h because it is a struct that
> defines the callback argument.  There is enough precedent for that - in fact,
> it is the way this is typically done.
>
>> Maybe the thing to do is use dtrace_aggregate_walk() with a callback in
>> dt_consume.c.  The callback can filter on the agg id and call
>> dt_aggregate_clear_one() accordingly... I *think* that works.  Let me know
>> if you're on board with this approach.
> I think I'd rather see the dt_clear_arg_t thing.  I don't think a callback in
> dt_consume.c would work without this struct argument because you still would
> not be able to get both dtp and aid passed to that callback.

My point was not to avoid the struct arg, but only that by putting the 
callback in dt_consume.c the struct declaration could be in dt_consume.c 
instead of introducing a new file dt_aggregate.h. Anyhow, v2 of the 
patch coming up with a new dt_aggregate.h file.



More information about the DTrace-devel mailing list