[DTrace-devel] [PATCH 1/7] htab reduction: kernpath

Eugene Loh eugene.loh at oracle.com
Fri Oct 8 11:14:30 PDT 2021


One other thing.  (All this falls under "I'm curious now that I'm 
reading this stuff"... not "I am outraged and you need to make changes.")

On 10/5/21 9:38 AM, Nick Alcock wrote:
> diff --git a/libdtrace/dt_kernel_module.c b/libdtrace/dt_kernel_module.c
> @@ -29,6 +29,34 @@
> +static dt_kern_path_t *
> +dt_kern_path_lookup(dtrace_hdl_t *dtp, const char *name)
> +{
> +	dt_kern_path_t tmpl;
> +
> +	if (_dt_unlikely_(!dtp->dt_kernpaths))
> +		return NULL;
> +
> +	tmpl.dkp_name = (char *) name;
> +	return dt_htab_lookup(dtp->dt_kernpaths, &tmpl);
> +}
This short function can perhaps simply be inlined into its two call 
sites.  I mean, why both lookup(dtp,name) and lookup_by_name(dtp,name)?

The code to be inlined is even shorter if the "if(!dtp->dt_kernpaths)" 
check is eliminated, which makes sense given that the callers already 
check.  Further, why do we even check?  If dt_htab_lookup(NULL, foo) is 
called, it segfaults. Wouldn't it make more sense for dt_htab_lookup() 
to check for htab==NULL and return NULL in that case?

I'm just asking.  I'm still trying to understand what a coherent use of 
htabs would look like.



More information about the DTrace-devel mailing list