summaryrefslogtreecommitdiffstats
path: root/include/linux/jiffies.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-08-08 21:13:53 +0000
committerDavid S. Miller <davem@davemloft.net>2012-08-09 16:17:03 -0700
commita399a8053164ec8bcb06fed52be9941a26ecde11 (patch)
treec60402a77d08c82630d63e972d32b038919b827f /include/linux/jiffies.h
parent79cda75a107da0d49732b5cb642b456264dd7e0e (diff)
downloadop-kernel-dev-a399a8053164ec8bcb06fed52be9941a26ecde11.zip
op-kernel-dev-a399a8053164ec8bcb06fed52be9941a26ecde11.tar.gz
time: jiffies_delta_to_clock_t() helper to the rescue
Various /proc/net files sometimes report crazy timer values, expressed in clock_t units. This happens when an expired timer delta (expires - jiffies) is passed to jiffies_to_clock_t(). This function has an overflow in : return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ); commit cbbc719fccdb8cb (time: Change jiffies_to_clock_t() argument type to unsigned long) only got around the problem. As we cant output negative values in /proc/net/tcp without breaking various tools, I suggest adding a jiffies_delta_to_clock_t() wrapper that caps the negative delta to a 0 value. Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Maciej Żenczykowski <maze@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: hank <pyu@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/jiffies.h')
-rw-r--r--include/linux/jiffies.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 265e2c3..aded9b1 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -303,7 +303,13 @@ extern void jiffies_to_timespec(const unsigned long jiffies,
extern unsigned long timeval_to_jiffies(const struct timeval *value);
extern void jiffies_to_timeval(const unsigned long jiffies,
struct timeval *value);
+
extern clock_t jiffies_to_clock_t(unsigned long x);
+static inline clock_t jiffies_delta_to_clock_t(long delta)
+{
+ return jiffies_to_clock_t(max(0L, delta));
+}
+
extern unsigned long clock_t_to_jiffies(unsigned long x);
extern u64 jiffies_64_to_clock_t(u64 x);
extern u64 nsec_to_clock_t(u64 x);
OpenPOWER on IntegriCloud