mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: davidm@hpl.hp.com, schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: sparse warning, or why does jifies_to_msecs() return an int?
Date: Fri, 14 Jan 2005 21:57:40 -0800	[thread overview]
Message-ID: <16872.45268.823377.293250@napali.hpl.hp.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0501142020130.2310@ppc970.osdl.org>

>>>>> On Fri, 14 Jan 2005 20:29:07 -0800 (PST), Linus Torvalds <torvalds@osdl.org> said:

  >> Is there are a good reason to constrain the return value to 4
  >> billion msecs?  If so, what's the proper way to shut up sparse?

  Linus> There's no good way to shut up sparse, I think. The fact is,
  Linus> we _are_ losing bits, but it doesn't matter much in this
  Linus> case.

Yes, you're right.

  Linus> I think "jiffies_to_msecs(MAX_JIFFY_OFFSET)" is fundamentally
  Linus> a suspect operation (since the ranges are different for the
  Linus> two types), and I think that the sparse warnign is correct,
  Linus> but it's one of those "doing the wrong thing is not always
  Linus> wrogn enough to matter".

How about something along the lines of the attached?  The test in
msecs_to_jiffies is non-sensical for HZ>=1000 because

 (a) jiffies_to_msecs(x) <= x, if HZ >= 1000, and
 (b) MAX_UINT <= MAX_ULONG

	--david

===== include/linux/jiffies.h 1.11 vs edited =====
--- 1.11/include/linux/jiffies.h	2005-01-04 18:48:02 -08:00
+++ edited/include/linux/jiffies.h	2005-01-14 21:52:46 -08:00
@@ -276,8 +276,10 @@
 
 static inline unsigned long msecs_to_jiffies(const unsigned int m)
 {
+#if HZ < 1000
 	if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
 		return MAX_JIFFY_OFFSET;
+#endif
 #if HZ <= 1000 && !(1000 % HZ)
 	return (m + (1000 / HZ) - 1) / (1000 / HZ);
 #elif HZ > 1000 && !(HZ % 1000)

  reply	other threads:[~2005-01-15  5:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-15  2:21 David Mosberger
2005-01-15  4:29 ` Linus Torvalds
2005-01-15  5:57   ` David Mosberger [this message]
2005-01-15 18:05     ` Linus Torvalds
2005-01-20 23:46       ` David Mosberger
2005-05-03 18:43 ` Nish Aravamudan

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=16872.45268.823377.293250@napali.hpl.hp.com \
    --to=davidm@napali.hpl.hp.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=torvalds@osdl.org \
    /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

all inboxes | Powered by JetHome®