<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Martin Doucha <<a href="mailto:mdoucha@suse.cz">mdoucha@suse.cz</a>> wrote:<br></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 04. 11. 22 15:13, Cyril Hrubis wrote: </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> As ITIMER_VIRTUAL and ITIMER_PROF counts CPU time the precision would be<br>
> the same as the COARSE clocks which depends on jiffies and on the<br>
> compile time option CONFIG_HZ. That is because in the scheduller the CPU<br>
> time is quantized into chunks based on CONFIG_HZ.<br>
> <br>
> And the ITIMER_REAL runs on hrtimers which would be the same precision<br>
> as CLOCK_REALTIME or CLOCK_MONOTONIC.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">This description of the rationale is what I was trying to confirm.</div><div class="gmail_default" style="font-size:small">Thanks for sharing.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
The kernel mangles the new timer values for ITIMER_PROF and <br>
ITIMER_VIRTUAL. It'll always add one extra jiffy to the actual timer <br>
value you've passed. For ITIMER_REAL, the timer value gets set as is.<br></blockquote><div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">Right, but I don't think it could be said as "mangles" cause that is</div><div class="gmail_default" style="font-size:small">on purpose, in case people give a very tiny 'tv_usec' to setiitimer(),</div><div class="gmail_default" style="font-size:small">so plus one jiffy to guarantee at least the timer takes effect.</div></div><div><div class="gmail_default" style="font-size:small"><br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
 From set_cpu_itimer() in kernel/time/itimer.c:<br>
<br>
if (oval || nval) {<br>
        if (nval > 0)<br>
                nval += TICK_NSEC;<br>
        set_process_cpu_timer(tsk, clock_id, &nval, &oval);<br>
}<br>
<br>
nval = new timer value passed to setitimer() converted to nanoseconds<br>
TICK_NSEC = 1 jiffy in nanoseconds<br>
<br>
-- <br>
Martin Doucha   <a href="mailto:mdoucha@suse.cz" target="_blank">mdoucha@suse.cz</a><br>
QA Engineer for Software Maintenance<br>
SUSE LINUX, s.r.o.<br>
CORSO IIa<br>
Krizikova 148/34<br>
186 00 Prague 8<br>
Czech Republic<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>