Thread (8 messages) 8 messages, 2 authors, 2019-07-09

Re: [PATCH next] softirq: enable MAX_SOFTIRQ_TIME tuning with sysctl max_softirq_time_usecs

From: Zhiqiang Liu <hidden>
Date: 2019-07-09 01:26:20
Also in: linux-fsdevel, lkml


On 2019/7/8 22:14, Thomas Gleixner wrote:
Zhiqiang,
quoted
If HZ satisfies the condition: HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC %
HZ), the return value of _msecs_to_jiffies func with m=0 is different
with different HZ setting.
quoted
------------------------------------
| HZ |	MSEC_PER_SEC / HZ | return |
------------------------------------
|1000|		1	  |   0	   |
|500 |		2	  |   1	   |
|200 |		5	  |   1	   |
|100 |		10	  |   1	   |
------------------------------------

Why only the return value of HZ=1000 is equal to 0 with m=0 ?
I don't know how you tested that, but obviously all four HZ values use
this variant:
quoted
    #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
    static inline unsigned long _msecs_to_jiffies(const unsigned int m)
    {
            return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
    }
and for all four HZ values the result is 0. Why?

For m = 0 the calculation reduces to:

      ((MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ)

i.e.

	(x - 1) / x	where x = [1, 2, 5, 10]

which is guaranteed to be 0 for integer math. If not, you have a compiler
problem.

Thanks,

	tglx
Thanks for your reply. Actually, I have made a low-level mistake.
I am really sorry for that.
Thanks again.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help