[LTP] [PATCH v1] Correctly handle user time in setitimer01

Li Wang liwang@redhat.com
Sat Nov 5 03:32:14 CET 2022


Martin Doucha <mdoucha@suse.cz> wrote:

On 04. 11. 22 15:13, Cyril Hrubis wrote:

> As ITIMER_VIRTUAL and ITIMER_PROF counts CPU time the precision would be
> > the same as the COARSE clocks which depends on jiffies and on the
> > compile time option CONFIG_HZ. That is because in the scheduller the CPU
> > time is quantized into chunks based on CONFIG_HZ.
> >
> > And the ITIMER_REAL runs on hrtimers which would be the same precision
> > as CLOCK_REALTIME or CLOCK_MONOTONIC.
>

This description of the rationale is what I was trying to confirm.
Thanks for sharing.



>
> The kernel mangles the new timer values for ITIMER_PROF and
> ITIMER_VIRTUAL. It'll always add one extra jiffy to the actual timer
> value you've passed. For ITIMER_REAL, the timer value gets set as is.
>


Right, but I don't think it could be said as "mangles" cause that is
on purpose, in case people give a very tiny 'tv_usec' to setiitimer(),
so plus one jiffy to guarantee at least the timer takes effect.



>
>  From set_cpu_itimer() in kernel/time/itimer.c:
>
> if (oval || nval) {
>         if (nval > 0)
>                 nval += TICK_NSEC;
>         set_process_cpu_timer(tsk, clock_id, &nval, &oval);
> }
>
> nval = new timer value passed to setitimer() converted to nanoseconds
> TICK_NSEC = 1 jiffy in nanoseconds
>
> --
> Martin Doucha   mdoucha@suse.cz
> QA Engineer for Software Maintenance
> SUSE LINUX, s.r.o.
> CORSO IIa
> Krizikova 148/34
> 186 00 Prague 8
> Czech Republic
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221105/055fd547/attachment-0001.htm>


More information about the ltp mailing list