2020-03-29 07:54:04

by Takashi Iwai

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

On Thu, 22 Aug 2019 02:25:10 +0200,
George Spelvin wrote:
> Likewise, "msecs_to_jiffies(seconds * 1000)" is more
> conveniently written "seconds * HZ".

I thought the compiler already optimizes to the constant calculation
for the above case?


thanks,

Takashi


2020-03-29 12:20:43

by George Spelvin

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

On Sun, Mar 29, 2020 at 09:52:23AM +0200, Takashi Iwai wrote:
> On Thu, 22 Aug 2019 02:25:10 +0200, George Spelvin wrote:
>> Likewise, "msecs_to_jiffies(seconds * 1000)" is more
>> conveniently written "seconds * HZ".
>
> 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.

2020-03-29 17:20:02

by Takashi Iwai

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

On Sun, 29 Mar 2020 14:11:29 +0200,
George Spelvin wrote:
>
> On Sun, Mar 29, 2020 at 09:52:23AM +0200, Takashi Iwai wrote:
> > On Thu, 22 Aug 2019 02:25:10 +0200, George Spelvin wrote:
> >> Likewise, "msecs_to_jiffies(seconds * 1000)" is more
> >> conveniently written "seconds * HZ".
> >
> > 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...


thanks,

Takashi