[DTrace-devel] [PATCH 02/15] htab: support lookups for buckets with multiple entries
Nick Alcock
nick.alcock at oracle.com
Thu Feb 23 12:32:23 UTC 2023
On 23 Feb 2023, Kris Van Hees via DTrace-devel verbalised:
> Probes are represented by a quadruple naming scheme. For easy lookup,
> hashtables are kept based on each naming component. When performing
> lookups based on one of those hashtables, the head element was always
> returned which is obviously wrong.
Ohhh I wondered how you avoided that problem. It never occurred to me
that it simply wasn't being avoided yet!
> This patch introduced dt_htab_find() which provides for lookups using
> a template entry and a secondary comparison function that is used to
> evaluate the different entries in the bucket that match the template.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
> diff --git a/libdtrace/dt_htab.h b/libdtrace/dt_htab.h
> index 6dae0262..97bb0672 100644
> --- a/libdtrace/dt_htab.h
> +++ b/libdtrace/dt_htab.h
> @@ -97,6 +97,9 @@ extern dt_htab_t *dt_htab_create(struct dtrace_hdl *dtp, dt_htab_ops_t *ops);
> extern void dt_htab_destroy(struct dtrace_hdl *dtp, dt_htab_t *htab);
> extern int dt_htab_insert(dt_htab_t *htab, void *entry);
> extern void *dt_htab_lookup(const dt_htab_t *htab, const void *entry);
> +typedef int dt_htab_f(const void *entry, void *arg);
... except that this typedef name is a bit clumsy. It's not a hash table
function, it's an entry-comparing function. Maybe dt_htab_entry_cmp_fn?
(Elsewhere in this file, we seem to use _fn for function-pointer
typedefs, not _f.)
Rather long and clumsy name, but it's not used much...
--
NULL && (void)
More information about the DTrace-devel
mailing list