[DTrace-devel] [PATCH 2/7] Implement the sched provider

Kris Van Hees kris.van.hees at oracle.com
Mon May 15 03:55:36 UTC 2023


On Sun, May 14, 2023 at 07:45:01PM -0400, Eugene Loh via DTrace-devel wrote:
> Sorry, another question:
> 
> On 5/9/23 18:29, Kris Van Hees via DTrace-devel wrote:
> > +static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
> > +		      int *argcp, dt_argdesc_t **argvp)
> > +{
> > +	int		i;
> > +	int		pidx = -1;
> > +	int		argc = 0;
> > +	dt_argdesc_t	*argv = NULL;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(probe_args); i++) {
> > +		probe_arg_t	*arg = &probe_args[i];
> > +
> > +		if (strcmp(arg->name, prp->desc->prb) == 0) {
> > +			if (pidx == -1) {
> > +				pidx = i;
> > +
> > +				if (arg->argdesc.native == NULL)
> > +					break;
> 
> What is the argdest.native check all about?  Is it necessary for
> correctness?  A vestigial check?  An attempt to optimize (short-circuit the
> loop)?

It is a convenient way to determine the difference between a probe that has
zero arguments and one that has one or more arguments.  If the first argument
descriptor for a given probe has native type NULL, then it is a probe without
any arguments (because all arguments must have a native type).

> > +			}
> > +
> > +			argc++;
> > +		}
> > +	}
> > +
> > +	if (argc == 0)
> > +		goto done;
> > +
> > +	argv = dt_zalloc(dtp, argc * sizeof(dt_argdesc_t));
> > +	if (!argv)
> > +		return -ENOMEM;
> > +
> > +	for (i = pidx; i < pidx + argc; i++) {
> > +		probe_arg_t	*arg = &probe_args[i];
> > +
> > +		argv[arg->argno] = arg->argdesc;
> > +	}
> > +
> > +done:
> > +	*argcp = argc;
> > +	*argvp = argv;
> > +
> > +	return 0;
> > +}
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list