From: Takashi Iwai <tiwai@suse.de>
To: George Spelvin <lkml@SDF.ORG>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
linux-kernel@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
linux-scsi@vger.kernel.org,
Marek Lindner <mareklindner@neomailbox.ch>,
Simon Wunderlich <sw@simonwunderlich.de>,
Antonio Quartulli <a@unstable.cc>,
Sven Eckelmann <sven@narfation.org>,
b.a.t.m.a.n@diktynna.open-mesh.org,
Johannes Berg <johannes@sipsolutions.net>,
linux-wireless@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, lkml@sdf.org
Subject: Re: [RFC PATCH v1 13/50] Avoid some useless msecs/jiffies conversions
Date: Mon, 30 Mar 2020 09:29:20 +0200 [thread overview]
Message-ID: <s5hv9mmb8rz.wl-tiwai@suse.de> (raw)
In-Reply-To: <20200330065105.GB9333@SDF.ORG>
On Mon, 30 Mar 2020 08:51:05 +0200,
George Spelvin wrote:
>
> On Mon, Mar 30, 2020 at 08:27:01AM +0200, Takashi Iwai wrote:
> > On Sun, 29 Mar 2020 20:16:47 +0200, James Bottomley wrote:
> >> We all assume that msecs_to_jiffies is properly optimized so there
> >> should be no need to open code it like you're proposing.
> >
> > Yes, it'd be best if the compiler can handle it properly.
>
> I've tried, and can't figure out how to get the compiler to detect this
> special case and not invoke the general code. In particular, for a
> variable x, __builtin_constant_p(x * 1000 % 1000) is false. Even if x is
> signed and ANSI lets the compiler assume that overflow doesn't happen.
>
> If you can do it, I'm most curious how!
Actually in the very early version of msecs_to_jiffies() was all
inlined, so the compiler could optimize such a case, I guess. Now it
was factored out to an external function in commit ca42aaf0c861, so it
became difficult.
> > But also I meant to keep using the macro for consistency reason.
> > IIRC, we wanted to eliminate the explicit use of HZ in the past, and
> > it's how many lines have been converted with *_to_jiffies() calls.
> > I don't know whether the eliminate of HZ is still wished, but
> > reverting to the open code is a step backward for that.
>
> Well, you could always add a secs_to_jiffies(x) wrapper. But given
> that it expands to basically x * HZ, some people might wonder why
> you're bothering.
Well, comparing with the expanded result doesn't make always sense.
With such a logic, you can argue why BIT(x) macro is needed, too.
After all, it's a matter of semantics.
> I assumed that open-coding x * HZ was the preferred style, so that's
> what I did.
That's my question, too -- whether the open code is preferred for this
particular purpose.
thanks,
Takashi
prev parent reply other threads:[~2020-03-30 7:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 0:25 [RFC PATCH v1 13/50] Avoid some useless msecs/jiffies conversions George Spelvin
2020-03-29 7:52 ` Takashi Iwai
2020-03-29 12:11 ` George Spelvin
2020-03-29 17:13 ` Takashi Iwai
2020-03-29 17:50 ` George Spelvin
2020-03-29 18:16 ` James Bottomley
2020-03-29 21:18 ` George Spelvin
2020-03-30 6:27 ` Takashi Iwai
2020-03-30 6:51 ` George Spelvin
2020-03-30 7:29 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hv9mmb8rz.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=James.Bottomley@HansenPartnership.com \
--cc=a@unstable.cc \
--cc=alsa-devel@alsa-project.org \
--cc=b.a.t.m.a.n@diktynna.open-mesh.org \
--cc=hare@suse.de \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lkml@SDF.ORG \
--cc=mareklindner@neomailbox.ch \
--cc=perex@perex.cz \
--cc=sven@narfation.org \
--cc=sw@simonwunderlich.de \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox