On 23/06/20(Tue) 12:04, Yuichiro NAITO wrote:
> Current btrace has `interval:hz:1` probe that makes periodically events.
> `interval:hz:1` looks to make events once per second (= 1Hz),
> but current implementation makes once per tick (= 100Hz on amd64).
> I think the interval should be counted by reciprocal of ticks so that fit to 
> Hz.

Indeed the current implementations assumes it's a number of ticks.  How
does other tracing tool behave?  Is the behavior you suggest similar to
bpftrace(8) or dtrace(1)?

Would it be complicated to add support for other units, like 'ms' or
'sec'?  In that case 'profile:s:10' would mean every 10sec while
'profile:hz:10' would mean every ~6sec, right?

> Following patch changes to calculate 'dp_maxtick' fit to Hz.
> 'dtrq_rate' has number of hz. I think it should be allowed same value of 'hz'
> so that we can use `interval:hz:100` that equals to once per tick on amd64.
> 
> Index: dt_prov_profile.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/dt/dt_prov_profile.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 dt_prov_profile.c
> --- dt_prov_profile.c 25 Mar 2020 14:59:23 -0000      1.2
> +++ dt_prov_profile.c 23 Jun 2020 02:02:27 -0000
> @@ -75,7 +75,7 @@ dt_prov_profile_alloc(struct dt_probe *d
>       KASSERT(TAILQ_EMPTY(plist));
>       KASSERT(dtp == dtpp_profile || dtp == dtpp_interval);
>  
> -     if (dtrq->dtrq_rate <= 0 || dtrq->dtrq_rate >= hz)
> +     if (dtrq->dtrq_rate <= 0 || dtrq->dtrq_rate > hz)
>               return EOPNOTSUPP;
>  
>       CPU_INFO_FOREACH(cii, ci) {
> @@ -88,7 +88,7 @@ dt_prov_profile_alloc(struct dt_probe *d
>                       return ENOMEM;
>               }
>  
> -             dp->dp_maxtick = dtrq->dtrq_rate;
> +             dp->dp_maxtick = hz / dtrq->dtrq_rate;
>               dp->dp_cpuid = ci->ci_cpuid;
>  
>               dp->dp_filter = dtrq->dtrq_filter;
> 
> -- 
> Yuichiro NAITO
>   [email protected]
> 

Reply via email to