Thread (10 messages) 10 messages, 3 authors, 2020-03-30

Re: [RFC PATCH v1 13/50] Avoid some useless msecs/jiffies conversions

flat view

From: George Spelvin <hidden>
Date: 2020-03-29 17:56:07
Also in: alsa-devel, linux-scsi, lkml

On Sun, Mar 29, 2020 at 07:13:33PM +0200, Takashi Iwai wrote:
On Sun, 29 Mar 2020 14:11:29 +0200, George Spelvin wrote:
quoted
On Sun, Mar 29, 2020 at 09:52:23AM +0200, Takashi Iwai wrote:
quoted
I thought the compiler already optimizes to the constant calculation
for the above case?
It optimizes that if the entire argument, including "seconds", is
a compile-time constant.

However, given "msecs_to_jiffies(hdev->rpa_timeout * 1000);",
the computatin is non-trivial.
Fair enough.  But it's still a question whether an open code X * HZ is
good at all...
I'm sorry, I don't understand what you mean by "good at all" here.
The value computed is exactly the same.

msecs_to_jiffies(x) is basically (x * HZ + 999) / 1000, so
  msecs_to_jiffies(s * 1000)
= (s * 1000 * HZ + 999) / 1000
= s * HZ + 999/1000
= s * HZ.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help