Re: [PATCH] NET : convert network timestamps to ktime_t
From: Eric Dumazet <[EMAIL PROTECTED]> Date: Mon, 05 Mar 2007 09:21:30 +0100 > I dont know very much this compat stuff, but I found > compat_sock_get_timestamp() only called from net/x25/af_x25.c Good point, I thought for some reason that this function was used for all SO_TIMESTAMP handling, but looking again I see that the main stuff is handled in put_cmsg() compat code. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
David Miller a écrit : From: Eric Dumazet <[EMAIL PROTECTED]> Date: Mon, 05 Mar 2007 08:40:03 +0100 Here is the second version of this patch, including missing bits spoted by Stephen. This is against net-2.6.22 Applied, thanks a lot. Note : this patch includes a bug correction in compat_sock_get_timestamp() where a "err = 0;" was missing (so this syscall returned -ENOENT instead of 0) Grrr, good spotting. Eric can you send me a version of just this bug fix against 2.6.21? I'll push that to Linus and 2.6.x-stable. Yes I will do it. But, are your sure its really used ? I dont know very much this compat stuff, but I found compat_sock_get_timestamp() only called from net/x25/af_x25.c I wonder how a 32 bit task on x86_64 can enter this compat code on other sockets ? - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
From: Eric Dumazet <[EMAIL PROTECTED]> Date: Mon, 05 Mar 2007 08:40:03 +0100 > Here is the second version of this patch, including missing bits spoted by > Stephen. This is against net-2.6.22 Applied, thanks a lot. > Note : this patch includes a bug correction in compat_sock_get_timestamp() > where a "err = 0;" was missing (so this syscall returned -ENOENT instead of > 0) Grrr, good spotting. Eric can you send me a version of just this bug fix against 2.6.21? I'll push that to Linus and 2.6.x-stable. I guess most applications don't even bother to check the getsockopt() return value. :-) Thanks a lot! - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] NET : convert network timestamps to ktime_t
Hi David Here is the second version of this patch, including missing bits spoted by Stephen. This is against net-2.6.22 Thank you [PATCH] NET : convert network timestamps to ktime_t We currently use a special structure (struct skb_timeval) and plain 'struct timeval' to store packet timestamps in sk_buffs and struct sock. This has some drawbacks : - Fixed resolution of micro second. - Waste of space on 64bit platforms where sizeof(struct timeval)=16 I suggest using ktime_t that is a nice abstraction of high resolution time services, currently capable of nanosecond resolution. As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits a 8 byte shrink of this structure on 64bit architectures. Some other structures also benefit from this size reduction (struct ipq in ipv4/ip_fragment.c, struct frag_queue in ipv6/reassembly.c, ...) Once this ktime infrastructure adopted, we can more easily provide nanosecond resolution on top of it. (ioctl SIOCGSTAMPNS and/or SO_TIMESTAMPNS/SCM_TIMESTAMPNS) Note : this patch includes a bug correction in compat_sock_get_timestamp() where a "err = 0;" was missing (so this syscall returned -ENOENT instead of 0) Signed-off-by: Eric Dumazet <[EMAIL PROTECTED]> CC: Stephen Hemminger <[EMAIL PROTECTED]> CC: John find <[EMAIL PROTECTED]> include/linux/skbuff.h | 26 -- include/net/sock.h | 18 +++ kernel/time.c |1 net/bridge/netfilter/ebt_ulog.c |6 +++-- net/compat.c| 15 net/core/dev.c | 19 +++- net/core/sock.c | 16 +++-- net/econet/af_econet.c |2 - net/ipv4/ip_fragment.c |8 +++--- net/ipv4/netfilter/ip_queue.c |6 +++-- net/ipv4/netfilter/ipt_ULOG.c |8 -- net/ipv6/exthdrs.c |2 - net/ipv6/netfilter/ip6_queue.c |6 +++-- net/ipv6/netfilter/nf_conntrack_reasm.c |6 ++--- net/ipv6/reassembly.c |6 ++--- net/ipx/af_ipx.c|4 +-- net/netfilter/nfnetlink_log.c |8 +++--- net/netfilter/nfnetlink_queue.c |8 +++--- net/packet/af_packet.c |8 -- net/sunrpc/svcsock.c| 10 ++-- 20 files changed, 85 insertions(+), 98 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 4ff3940..24dcbb3 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -27,6 +27,7 @@ #include #include #include #include +#include #define HAVE_ALLOC_SKB /* For the drivers to know */ #define HAVE_ALIGNABLE_SKB /* Ditto 8)*/ @@ -156,11 +157,6 @@ struct skb_shared_info { #define SKB_DATAREF_SHIFT 16 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) -struct skb_timeval { - u32 off_sec; - u32 off_usec; -}; - enum { SKB_FCLONE_UNAVAILABLE, @@ -233,7 +229,7 @@ struct sk_buff { struct sk_buff *prev; struct sock *sk; - struct skb_timeval tstamp; + ktime_t tstamp; struct net_device *dev; struct net_device *input_dev; @@ -1360,26 +1356,14 @@ extern void skb_add_mtu(int mtu); */ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) { - stamp->tv_sec = skb->tstamp.off_sec; - stamp->tv_usec = skb->tstamp.off_usec; + *stamp = ktime_to_timeval(skb->tstamp); } -/** - * skb_set_timestamp - set timestamp of a skb - * @skb: skb to set stamp of - * @stamp: pointer to struct timeval to get stamp from - * - * Timestamps are stored in the skb as offsets to a base timestamp. - * This function converts a struct timeval to an offset and stores - * it in the skb. - */ -static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp) +static inline void __net_timestamp(struct sk_buff *skb) { - skb->tstamp.off_sec = stamp->tv_sec; - skb->tstamp.off_usec = stamp->tv_usec; + skb->tstamp = ktime_get_real(); } -extern void __net_timestamp(struct sk_buff *skb); extern __sum16 __skb_checksum_complete(struct sk_buff *skb); diff --git a/include/net/sock.h b/include/net/sock.h index f352d22..59af9fc 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -244,7 +244,7 @@ #define sk_prot __sk_common.skc_prot struct sk_filter*sk_filter; void*sk_protinfo; struct timer_list sk_timer; - struct timeval sk_stamp; + ktime_t sk_stamp; struct socket *sk_socket; void*sk_user_d
Re: [PATCH] NET : convert network timestamps to ktime_t
David Miller a écrit : From: Eric Dumazet <[EMAIL PROTECTED]> Date: Fri, 02 Mar 2007 23:46:14 +0100 Stephen Hemminger a écrit : You missed a couple of spots. Arg yes... ... - } - skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); + svsk->sk_sk->sk_stamp = (skb->tstamp.tv64 != 0) ? skb->tstamp + : ktime_get_real(); Well, if we want to stay in the spirit of old code, we probably want to use current_kernel_time() (+ timespec_to_ktime()), because its less expensive. And also setting the skb tstamp, no ? Can you guys cook up an integrated patch with all the missing cases fixed up as desired, so I can add this to net-2.6.22, thanks? Yes, I will send the patch against net-2.6.22 this morning. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
From: Eric Dumazet <[EMAIL PROTECTED]> Date: Fri, 02 Mar 2007 23:46:14 +0100 > Stephen Hemminger a écrit : > > You missed a couple of spots. > > Arg yes... ... > > - } > > - skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); > > + svsk->sk_sk->sk_stamp = (skb->tstamp.tv64 != 0) ? skb->tstamp > > + : ktime_get_real(); > > Well, if we want to stay in the spirit of old code, we probably want to use > current_kernel_time() (+ timespec_to_ktime()), because its less expensive. > > And also setting the skb tstamp, no ? Can you guys cook up an integrated patch with all the missing cases fixed up as desired, so I can add this to net-2.6.22, thanks? - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
Stephen Hemminger a écrit : On Fri, 2 Mar 2007 15:38:41 +0100 Eric Dumazet <[EMAIL PROTECTED]> wrote: We currently use a special structure (struct skb_timeval) and plain 'struct timeval' to store packet timestamps in sk_buffs and struct sock. This has some drawbacks : - Fixed resolution of micro second. - Waste of space on 64bit platforms where sizeof(struct timeval)=16 I suggest using ktime_t that is a nice abstraction of high resolution time services, currently capable of nanosecond resolution. As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits a 8 byte shrink of this structure on 64bit architectures. Some other structures also benefit from this size reduction (struct ipq in ipv4/ip_fragment.c, struct frag_queue in ipv6/reassembly.c, ...) You missed a couple of spots. Arg yes... --- tcp-2.6.orig/net/sunrpc/svcsock.c 2007-03-02 12:50:45.0 -0800 +++ tcp-2.6/net/sunrpc/svcsock.c2007-03-02 12:58:28.0 -0800 @@ -805,16 +805,9 @@ /* possibly an icmp error */ dprintk("svc: recvfrom returned error %d\n", -err); } - if (skb->tstamp.off_sec == 0) { - struct timeval tv; - tv.tv_sec = xtime.tv_sec; - tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC; - skb_set_timestamp(skb, &tv); - /* Don't enable netstamp, sunrpc doesn't - need that much accuracy */ - } - skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); + svsk->sk_sk->sk_stamp = (skb->tstamp.tv64 != 0) ? skb->tstamp + : ktime_get_real(); Well, if we want to stay in the spirit of old code, we probably want to use current_kernel_time() (+ timespec_to_ktime()), because its less expensive. And also setting the skb tstamp, no ? - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
On Fri, 2 Mar 2007 15:38:41 +0100 Eric Dumazet <[EMAIL PROTECTED]> wrote: > We currently use a special structure (struct skb_timeval) and plain 'struct > timeval' to store packet timestamps in sk_buffs and struct sock. > > This has some drawbacks : > - Fixed resolution of micro second. > - Waste of space on 64bit platforms where sizeof(struct timeval)=16 > > I suggest using ktime_t that is a nice abstraction of high resolution time > services, currently capable of nanosecond resolution. > > As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits a 8 > byte > shrink of this structure on 64bit architectures. Some other structures also > benefit from this size reduction (struct ipq in ipv4/ip_fragment.c, struct > frag_queue in ipv6/reassembly.c, ...) > > You missed a couple of spots. --- tcp-2.6.orig/net/sunrpc/svcsock.c 2007-03-02 12:50:45.0 -0800 +++ tcp-2.6/net/sunrpc/svcsock.c2007-03-02 12:58:28.0 -0800 @@ -805,16 +805,9 @@ /* possibly an icmp error */ dprintk("svc: recvfrom returned error %d\n", -err); } - if (skb->tstamp.off_sec == 0) { - struct timeval tv; - tv.tv_sec = xtime.tv_sec; - tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC; - skb_set_timestamp(skb, &tv); - /* Don't enable netstamp, sunrpc doesn't - need that much accuracy */ - } - skb_get_timestamp(skb, &svsk->sk_sk->sk_stamp); + svsk->sk_sk->sk_stamp = (skb->tstamp.tv64 != 0) ? skb->tstamp + : ktime_get_real(); set_bit(SK_DATA, &svsk->sk_flags); /* there may be more data... */ /* --- tcp-2.6.orig/kernel/time.c 2007-03-02 12:59:55.0 -0800 +++ tcp-2.6/kernel/time.c 2007-03-02 13:00:08.0 -0800 @@ -469,6 +469,8 @@ return tv; } +EXPORT_SYMBOL(ns_to_timeval); + /* * Convert jiffies to milliseconds and back. -- Stephen Hemminger <[EMAIL PROTECTED]> - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] NET : convert network timestamps to ktime_t
On Fri, 2 Mar 2007 15:38:41 +0100 Eric Dumazet <[EMAIL PROTECTED]> wrote: > We currently use a special structure (struct skb_timeval) and plain 'struct > timeval' to store packet timestamps in sk_buffs and struct sock. > > This has some drawbacks : > - Fixed resolution of micro second. > - Waste of space on 64bit platforms where sizeof(struct timeval)=16 > > I suggest using ktime_t that is a nice abstraction of high resolution time > services, currently capable of nanosecond resolution. > > As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits a 8 > byte > shrink of this structure on 64bit architectures. Some other structures also > benefit from this size reduction (struct ipq in ipv4/ip_fragment.c, struct > frag_queue in ipv6/reassembly.c, ...) This is even better. Also comparing ktime_t's is easier if some code needs to do that. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] NET : convert network timestamps to ktime_t
We currently use a special structure (struct skb_timeval) and plain 'struct timeval' to store packet timestamps in sk_buffs and struct sock. This has some drawbacks : - Fixed resolution of micro second. - Waste of space on 64bit platforms where sizeof(struct timeval)=16 I suggest using ktime_t that is a nice abstraction of high resolution time services, currently capable of nanosecond resolution. As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits a 8 byte shrink of this structure on 64bit architectures. Some other structures also benefit from this size reduction (struct ipq in ipv4/ip_fragment.c, struct frag_queue in ipv6/reassembly.c, ...) Once this ktime infrastructure adopted, we can more easily provide nanosecond resolution on top of it. (ioctl SIOCGSTAMPNS and/or SO_TIMESTAMPNS/SCM_TIMESTAMPNS) Note : this patch includes a bug correction in compat_sock_get_timestamp() where a "err = 0;" was missing (so this syscall returned -ENOENT instead of 0) Signed-off-by: Eric Dumazet <[EMAIL PROTECTED]> CC: Stephen Hemminger <[EMAIL PROTECTED]> CC: John find <[EMAIL PROTECTED]> include/linux/skbuff.h | 26 -- include/net/sock.h | 18 +++ net/bridge/netfilter/ebt_ulog.c |6 +++-- net/compat.c| 15 net/core/dev.c | 19 +++- net/core/sock.c | 16 +++-- net/econet/af_econet.c |2 - net/ipv4/ip_fragment.c |6 ++--- net/ipv4/netfilter/ip_queue.c |6 +++-- net/ipv4/netfilter/ipt_ULOG.c |8 -- net/ipv6/exthdrs.c |2 - net/ipv6/netfilter/ip6_queue.c |6 +++-- net/ipv6/netfilter/nf_conntrack_reasm.c |6 ++--- net/ipv6/reassembly.c |6 ++--- net/ipx/af_ipx.c|4 +-- net/netfilter/nfnetlink_log.c |8 +++--- net/netfilter/nfnetlink_queue.c |8 +++--- net/packet/af_packet.c |8 -- 18 files changed, 80 insertions(+), 90 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 4ff3940..24dcbb3 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -27,6 +27,7 @@ #include #include #include #include +#include #define HAVE_ALLOC_SKB /* For the drivers to know */ #define HAVE_ALIGNABLE_SKB /* Ditto 8)*/ @@ -156,11 +157,6 @@ struct skb_shared_info { #define SKB_DATAREF_SHIFT 16 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) -struct skb_timeval { - u32 off_sec; - u32 off_usec; -}; - enum { SKB_FCLONE_UNAVAILABLE, @@ -233,7 +229,7 @@ struct sk_buff { struct sk_buff *prev; struct sock *sk; - struct skb_timeval tstamp; + ktime_t tstamp; struct net_device *dev; struct net_device *input_dev; @@ -1360,26 +1356,14 @@ extern void skb_add_mtu(int mtu); */ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) { - stamp->tv_sec = skb->tstamp.off_sec; - stamp->tv_usec = skb->tstamp.off_usec; + *stamp = ktime_to_timeval(skb->tstamp); } -/** - * skb_set_timestamp - set timestamp of a skb - * @skb: skb to set stamp of - * @stamp: pointer to struct timeval to get stamp from - * - * Timestamps are stored in the skb as offsets to a base timestamp. - * This function converts a struct timeval to an offset and stores - * it in the skb. - */ -static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp) +static inline void __net_timestamp(struct sk_buff *skb) { - skb->tstamp.off_sec = stamp->tv_sec; - skb->tstamp.off_usec = stamp->tv_usec; + skb->tstamp = ktime_get_real(); } -extern void __net_timestamp(struct sk_buff *skb); extern __sum16 __skb_checksum_complete(struct sk_buff *skb); diff --git a/include/net/sock.h b/include/net/sock.h index 2c7d60c..19f6540 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -244,7 +244,7 @@ #define sk_prot __sk_common.skc_prot struct sk_filter*sk_filter; void*sk_protinfo; struct timer_list sk_timer; - struct timeval sk_stamp; + ktime_t sk_stamp; struct socket *sk_socket; void*sk_user_data; struct page *sk_sndmsg_page; @@ -1307,19 +1307,19 @@ static inline int sock_intr_errno(long t static __inline__ void sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) { - struct timeval stamp; + ktime_t kt = skb->tstamp; - skb_get_timestamp(skb, &stamp); if (sock_flag(sk, SOCK_RCVTSTAMP)) {