From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux kernel <linux-kernel@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH] Introduce jiffies_32 and related compare functions
Date: Mon, 11 Dec 2006 23:58:06 +0100 [thread overview]
Message-ID: <457DE27E.5000100@cosmosbay.com> (raw)
In-Reply-To: <457DCC60.3050006@cosmosbay.com>
[-- Attachment #1: Type: text/plain, Size: 648 bytes --]
Some subsystems dont need more than 32bits timestamps.
See for example net/ipv4/inetpeer.c and include/net/tcp.h :
#define tcp_time_stamp ((__u32)(jiffies))
Because most timeouts should work with 'normal jiffies' that are 32bits on
32bits platforms, it makes sense to be able to use only 32bits to store them
and not 64 bits, to save ram.
This patch introduces jiffies_32, and related comparison functions
time_after32(), time_before32(), time_after_eq32() and time_before_eq32().
I plan to use this infrastructure in network code for example (struct
dst_entry comes to mind).
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: jiffies_32.patch --]
[-- Type: text/plain, Size: 1172 bytes --]
--- linux-2.6.19/include/linux/jiffies.h 2006-12-12 00:32:00.000000000 +0100
+++ linux-2.6.19-ed/include/linux/jiffies.h 2006-12-12 00:41:40.000000000 +0100
@@ -80,6 +80,11 @@
*/
extern u64 __jiffy_data jiffies_64;
extern unsigned long volatile __jiffy_data jiffies;
+/*
+ * Some subsystems need small deltas and can store 32 bits timestamps
+ * instead of 'long', to save space on 64bits platforms.
+ */
+#define jiffies_32 ((u32)jiffies)
#if (BITS_PER_LONG < 64)
u64 get_jiffies_64(void);
@@ -131,6 +136,22 @@ static inline u64 get_jiffies_64(void)
#define time_before_eq64(a,b) time_after_eq64(b,a)
/*
+ * Same as above, but does so with 32bits types.
+ * These must be used when using jiffies_32
+ */
+#define time_after32(a,b) \
+ (typecheck(__u32, a) && \
+ typecheck(__u32, b) && \
+ ((__s32)(b) - (__s32)(a) < 0))
+#define time_before32(a,b) time_after32(b,a)
+
+#define time_after_eq32(a,b) \
+ (typecheck(__u32, a) && \
+ typecheck(__u32, b) && \
+ ((__s32)(a) - (__s32)(b) >= 0))
+#define time_before_eq32(a,b) time_after_eq32(b,a)
+
+/*
* Have the 32 bit jiffies value wrap 5 minutes after boot
* so jiffies wrap bugs show up earlier.
*/
next prev parent reply other threads:[~2006-12-11 22:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200612112027.kBBKR4nG006298@shell0.pdx.osdl.net>
2006-12-11 21:23 ` [PATCH] reorder struct pipe_buf_operations Eric Dumazet
2006-12-11 22:58 ` Eric Dumazet [this message]
2006-12-12 1:31 ` [PATCH] Introduce jiffies_32 and related compare functions David Miller
2006-12-12 3:47 ` Eric Dumazet
2006-12-12 3:57 ` David Miller
2006-12-12 4:09 ` Eric Dumazet
2006-12-12 4:27 ` David Miller
2006-12-12 6:56 ` Eric Dumazet
2006-12-12 8:00 ` David Miller
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=457DE27E.5000100@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.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