netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-2.6.22] [TCP]: Fix linkage errors.
@ 2007-04-24 15:17 YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 15:53 ` Adrian Bunk
  0 siblings, 1 reply; 18+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-24 15:17 UTC (permalink / raw)
  To: davem; +Cc: shemminger, netdev

Recent ktime_t changes had introduced linkage errors.

| WARNING: "__divdi3" [net/ipv4/tcp_veno.ko] undefined!
| WARNING: "__divdi3" [net/ipv4/tcp_vegas.ko] undefined!
| WARNING: "__divdi3" [net/ipv4/tcp_lp.ko] undefined!
| WARNING: "__divdi3" [net/ipv4/tcp_illinois.ko] undefined!

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

---
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..0cec615 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -87,10 +87,12 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
 {
 	struct illinois *ca = inet_csk_ca(sk);
 	u32 rtt;
+	struct timeval tv;
 
 	ca->acked = pkts_acked;
 
-	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+	tv = ktime_to_timeval(net_timedelta(last));
+	rtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
 	if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..0b990ea 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -265,8 +265,10 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
+	struct timeval tv;
 
-	tcp_lp_rtt_sample(sk,  ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+	tv = ktime_to_timeval(net_timedelta(last));
+	tcp_lp_rtt_sample(sk, tv.tv_sec * USEC_PER_SEC + tv.tv_usec);
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..c13dc16 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -116,9 +116,11 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 {
 	struct vegas *vegas = inet_csk_ca(sk);
 	u32 vrtt;
+	struct timeval tv;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	tv = ktime_to_timeval(net_timedelta(last));
+	vrtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..a439c49 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -73,9 +73,11 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 {
 	struct veno *veno = inet_csk_ca(sk);
 	u32 vrtt;
+	struct timeval tv;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	tv = ktime_to_timeval(net_timedelta(last));
+	vrtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 15:17 [net-2.6.22] [TCP]: Fix linkage errors YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 15:53 ` Adrian Bunk
  2007-04-24 15:58   ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 16:03   ` [net-2.6.22] [TCP]: Fix linkage errors Eric Dumazet
  0 siblings, 2 replies; 18+ messages in thread
From: Adrian Bunk @ 2007-04-24 15:53 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: davem, shemminger, netdev, Thomas Gleixner

On Wed, Apr 25, 2007 at 12:17:43AM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
> Recent ktime_t changes had introduced linkage errors.
> 
> | WARNING: "__divdi3" [net/ipv4/tcp_veno.ko] undefined!
> | WARNING: "__divdi3" [net/ipv4/tcp_vegas.ko] undefined!
> | WARNING: "__divdi3" [net/ipv4/tcp_lp.ko] undefined!
> | WARNING: "__divdi3" [net/ipv4/tcp_illinois.ko] undefined!
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> 
> ---
> diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
> index 8e31659..0cec615 100644
> --- a/net/ipv4/tcp_illinois.c
> +++ b/net/ipv4/tcp_illinois.c
> @@ -87,10 +87,12 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
>  {
>  	struct illinois *ca = inet_csk_ca(sk);
>  	u32 rtt;
> +	struct timeval tv;
>  
>  	ca->acked = pkts_acked;
>  
> -	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
> +	tv = ktime_to_timeval(net_timedelta(last));
> +	rtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
>  
>  	/* ignore bogus values, this prevents wraparound in alpha math */
>  	if (rtt > RTT_MAX)
>...

Couldn't this be better solved by adding something like the following 
to include/linux/ktime.h ?

static inline s64 ktime_to_us(const ktime_t kt)
{
   return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
}

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 15:53 ` Adrian Bunk
@ 2007-04-24 15:58   ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 16:10     ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 16:03   ` [net-2.6.22] [TCP]: Fix linkage errors Eric Dumazet
  1 sibling, 1 reply; 18+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-24 15:58 UTC (permalink / raw)
  To: bunk; +Cc: davem, shemminger, netdev, tglx, yoshfuji

In article <20070424155324.GL3468@stusta.de> (at Tue, 24 Apr 2007 17:53:24 +0200), Adrian Bunk <bunk@stusta.de> says:

> On Wed, Apr 25, 2007 at 12:17:43AM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
> > Recent ktime_t changes had introduced linkage errors.
> > 
> > | WARNING: "__divdi3" [net/ipv4/tcp_veno.ko] undefined!
> > | WARNING: "__divdi3" [net/ipv4/tcp_vegas.ko] undefined!
> > | WARNING: "__divdi3" [net/ipv4/tcp_lp.ko] undefined!
> > | WARNING: "__divdi3" [net/ipv4/tcp_illinois.ko] undefined!
> > 
> > Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> > 
> > ---
> > diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
> > index 8e31659..0cec615 100644
> > --- a/net/ipv4/tcp_illinois.c
> > +++ b/net/ipv4/tcp_illinois.c
> > @@ -87,10 +87,12 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
> >  {
> >  	struct illinois *ca = inet_csk_ca(sk);
> >  	u32 rtt;
> > +	struct timeval tv;
> >  
> >  	ca->acked = pkts_acked;
> >  
> > -	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
> > +	tv = ktime_to_timeval(net_timedelta(last));
> > +	rtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
> >  
> >  	/* ignore bogus values, this prevents wraparound in alpha math */
> >  	if (rtt > RTT_MAX)
> >...
> 
> Couldn't this be better solved by adding something like the following 
> to include/linux/ktime.h ?
> 
> static inline s64 ktime_to_us(const ktime_t kt)
> {
>    return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
> }
> 

That will introduce same error, won't it?

--yoshfuji

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 15:53 ` Adrian Bunk
  2007-04-24 15:58   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 16:03   ` Eric Dumazet
  2007-04-24 18:17     ` Adrian Bunk
  1 sibling, 1 reply; 18+ messages in thread
From: Eric Dumazet @ 2007-04-24 16:03 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: YOSHIFUJI Hideaki / ____________, davem, shemminger, netdev,
	Thomas Gleixner

On Tue, 24 Apr 2007 17:53:24 +0200
Adrian Bunk <bunk@stusta.de> wrote:
> Couldn't this be better solved by adding something like the following 
> to include/linux/ktime.h ?
> 
> static inline s64 ktime_to_us(const ktime_t kt)
> {
>    return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
> }
> 

Please check again include/linux/ktime.h

tv struct is defined inside 'ktime_t' only if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 15:58   ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 16:10     ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 16:38       ` Eric Dumazet
  0 siblings, 1 reply; 18+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-24 16:10 UTC (permalink / raw)
  To: bunk; +Cc: davem, shemminger, netdev, tglx, yoshfuji

In article <20070425.005845.113682267.yoshfuji@linux-ipv6.org> (at Wed, 25 Apr 2007 00:58:45 +0900 (JST)), YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> says:

> In article <20070424155324.GL3468@stusta.de> (at Tue, 24 Apr 2007 17:53:24 +0200), Adrian Bunk <bunk@stusta.de> says:
> 
> > On Wed, Apr 25, 2007 at 12:17:43AM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
> > > Recent ktime_t changes had introduced linkage errors.
> > > 
> > > | WARNING: "__divdi3" [net/ipv4/tcp_veno.ko] undefined!
> > > | WARNING: "__divdi3" [net/ipv4/tcp_vegas.ko] undefined!
> > > | WARNING: "__divdi3" [net/ipv4/tcp_lp.ko] undefined!
> > > | WARNING: "__divdi3" [net/ipv4/tcp_illinois.ko] undefined!
> > > 
> > > Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> > > 
> > > ---
> > > diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
> > > index 8e31659..0cec615 100644
> > > --- a/net/ipv4/tcp_illinois.c
> > > +++ b/net/ipv4/tcp_illinois.c
> > > @@ -87,10 +87,12 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
> > >  {
> > >  	struct illinois *ca = inet_csk_ca(sk);
> > >  	u32 rtt;
> > > +	struct timeval tv;
> > >  
> > >  	ca->acked = pkts_acked;
> > >  
> > > -	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
> > > +	tv = ktime_to_timeval(net_timedelta(last));
> > > +	rtt = tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
> > >  
> > >  	/* ignore bogus values, this prevents wraparound in alpha math */
> > >  	if (rtt > RTT_MAX)
> > >...
> > 
> > Couldn't this be better solved by adding something like the following 
> > to include/linux/ktime.h ?
> > 
> > static inline s64 ktime_to_us(const ktime_t kt)
> > {
> >    return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
> > }
> > 
> 
> That will introduce same error, won't it?

How about this?

Singed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 248305b..601a74e 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -259,6 +259,12 @@ static inline s64 ktime_to_ns(const ktime_t kt)
 
 #endif
 
+static inline s64 ktime_to_us(const ktime_t kt)
+{
+	struct timeval tv = ktime_to_timeval(kt);
+	return tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+}
+
 /*
  * The resolution of the clocks. The resolution value is returned in
  * the clock_getres() system call to give application programmers an
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..4adc47c 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -90,7 +90,7 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
 
 	ca->acked = pkts_acked;
 
-	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+	rtt = ktime_to_us(net_timedelta(last));
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
 	if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..43294ad 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -266,7 +266,7 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
 
-	tcp_lp_rtt_sample(sk,  ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+	tcp_lp_rtt_sample(sk,  ktime_to_us(net_timedelta(last)));
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..73e19cf 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -118,7 +118,7 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..9edb340 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -75,7 +75,7 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 16:10     ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 16:38       ` Eric Dumazet
  2007-04-24 17:04         ` [PATCH] Fix build errors on 32bit platforms with new ktime Stephen Hemminger
  0 siblings, 1 reply; 18+ messages in thread
From: Eric Dumazet @ 2007-04-24 16:38 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / ____________; +Cc: bunk, davem, shemminger, netdev, tglx

On Wed, 25 Apr 2007 01:10:28 +0900 (JST)
YOSHIFUJI Hideaki  <yoshfuji@linux-ipv6.org> wrote:

> How about this?
> 
>  
> +static inline s64 ktime_to_us(const ktime_t kt)
> +{
> +	struct timeval tv = ktime_to_timeval(kt);
> +	return tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
> +}
> +

Well, I am afraid it's not 100% correct.

If you really want to return s64 you should do

return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec;

But then it might be overkill to compute a full s64 for TCP use, since we use u32 vrtt


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 16:38       ` Eric Dumazet
@ 2007-04-24 17:04         ` Stephen Hemminger
  2007-04-24 18:19           ` Adrian Bunk
                             ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Stephen Hemminger @ 2007-04-24 17:04 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: YOSHIFUJI Hideaki / ____________, bunk, davem, netdev, tglx

Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
in a way that works on both 64 and 32bit platforms.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 include/linux/ktime.h   |   13 +++++++++++++
 net/ipv4/tcp_illinois.c |    2 +-
 net/ipv4/tcp_lp.c       |    2 +-
 net/ipv4/tcp_vegas.c    |    2 +-
 net/ipv4/tcp_veno.c     |    2 +-
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 248305b..c58683a 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -121,6 +121,8 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
 /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
 #define ktime_to_ns(kt)			((kt).tv64)
 
+#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
+
 #else
 
 /*
@@ -257,6 +259,17 @@ static inline s64 ktime_to_ns(const ktime_t kt)
 	return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
 }
 
+/**
+ * ktime_to_us - convert a ktime_t variable to scalar microseconds
+ * @kt:		the ktime_t variable to convert
+ *
+ * Returns the scalar nanoseconds representation of @kt
+ */
+static inline s64 ktime_to_us(const ktime_t kt)
+{
+	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
+}
+
 #endif
 
 /*
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..4adc47c 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -90,7 +90,7 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
 
 	ca->acked = pkts_acked;
 
-	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+	rtt = ktime_to_us(net_timedelta(last));
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
 	if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..43294ad 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -266,7 +266,7 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
 
-	tcp_lp_rtt_sample(sk,  ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+	tcp_lp_rtt_sample(sk,  ktime_to_us(net_timedelta(last)));
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..73e19cf 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -118,7 +118,7 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..9edb340 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -75,7 +75,7 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)
-- 
1.5.0.6


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [net-2.6.22] [TCP]: Fix linkage errors.
  2007-04-24 16:03   ` [net-2.6.22] [TCP]: Fix linkage errors Eric Dumazet
@ 2007-04-24 18:17     ` Adrian Bunk
  0 siblings, 0 replies; 18+ messages in thread
From: Adrian Bunk @ 2007-04-24 18:17 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: YOSHIFUJI Hideaki / ____________, davem, shemminger, netdev,
	Thomas Gleixner

On Tue, Apr 24, 2007 at 06:03:48PM +0200, Eric Dumazet wrote:
> On Tue, 24 Apr 2007 17:53:24 +0200
> Adrian Bunk <bunk@stusta.de> wrote:
> > Couldn't this be better solved by adding something like the following 
> > to include/linux/ktime.h ?
> > 
> > static inline s64 ktime_to_us(const ktime_t kt)
> > {
> >    return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
> > }
> > 
> 
> Please check again include/linux/ktime.h
> 
> tv struct is defined inside 'ktime_t' only if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)

That's the difference between a "what about" suggestion and an actual 
patch...

I was merely suggesting solvin it through a ktime_to_us(), not 
presenting a complete and tested patch.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 17:04         ` [PATCH] Fix build errors on 32bit platforms with new ktime Stephen Hemminger
@ 2007-04-24 18:19           ` Adrian Bunk
  2007-04-24 18:48           ` Eric Dumazet
  2007-04-24 21:55           ` YOSHIFUJI Hideaki / 吉藤英明
  2 siblings, 0 replies; 18+ messages in thread
From: Adrian Bunk @ 2007-04-24 18:19 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Eric Dumazet, YOSHIFUJI Hideaki, davem, netdev, tglx

On Tue, Apr 24, 2007 at 10:04:20AM -0700, Stephen Hemminger wrote:
>...
> +/**
> + * ktime_to_us - convert a ktime_t variable to scalar microseconds
> + * @kt:		the ktime_t variable to convert
> + *
> + * Returns the scalar nanoseconds representation of @kt
> + */
> +static inline s64 ktime_to_us(const ktime_t kt)
> +{
> +	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
>...                 kt.tv.sec                  kt.tv.nsec

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 17:04         ` [PATCH] Fix build errors on 32bit platforms with new ktime Stephen Hemminger
  2007-04-24 18:19           ` Adrian Bunk
@ 2007-04-24 18:48           ` Eric Dumazet
  2007-04-24 21:54             ` David Miller
  2007-04-24 21:55           ` YOSHIFUJI Hideaki / 吉藤英明
  2 siblings, 1 reply; 18+ messages in thread
From: Eric Dumazet @ 2007-04-24 18:48 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: YOSHIFUJI Hideaki / ____________, bunk, davem, netdev, tglx

Stephen Hemminger a écrit :
>  
> +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> +
>  #else

Oh dear... how many bogus patches are going to be posted today ?



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 18:48           ` Eric Dumazet
@ 2007-04-24 21:54             ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2007-04-24 21:54 UTC (permalink / raw)
  To: dada1; +Cc: shemminger, yoshfuji, bunk, netdev, tglx

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Tue, 24 Apr 2007 20:48:22 +0200

> Stephen Hemminger a écrit :
> >  
> > +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> > +
> >  #else
> 
> Oh dear... how many bogus patches are going to be posted today ?

Stephen please submit a working patch, thanks :-)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 17:04         ` [PATCH] Fix build errors on 32bit platforms with new ktime Stephen Hemminger
  2007-04-24 18:19           ` Adrian Bunk
  2007-04-24 18:48           ` Eric Dumazet
@ 2007-04-24 21:55           ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 21:57             ` Stephen Hemminger
  2 siblings, 1 reply; 18+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-24 21:55 UTC (permalink / raw)
  To: shemminger; +Cc: dada1, bunk, davem, netdev, tglx, yoshfuji

In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:

> Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
> in a way that works on both 64 and 32bit platforms.

No, this does not cure.
>  
> +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> +

NSEC_PER_USEC?

> +static inline s64 ktime_to_us(const ktime_t kt)
> +{
> +	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
> +}
> +

Please do NOT use division here, which was the source of the
linkage error, and the reason why I posted a patch to use
ktime_to_timeval().

--yoshfuji

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 21:55           ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 21:57             ` Stephen Hemminger
  2007-04-24 22:12               ` Eric Dumazet
  2007-04-24 22:15               ` Thomas Gleixner
  0 siblings, 2 replies; 18+ messages in thread
From: Stephen Hemminger @ 2007-04-24 21:57 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / 吉藤英明
  Cc: dada1, bunk, davem, netdev, tglx, yoshfuji

On Wed, 25 Apr 2007 06:55:39 +0900 (JST)
YOSHIFUJI Hideaki / 吉藤英明  <yoshfuji@linux-ipv6.org> wrote:

> In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:
> 
> > Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
> > in a way that works on both 64 and 32bit platforms.
> 
> No, this does not cure.
> >  
> > +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> > +
> 
> NSEC_PER_USEC?

On 64 bit platforms, ktime stores nano-seconds in a 64 bit value, so
this is correct.

> 
> > +static inline s64 ktime_to_us(const ktime_t kt)
> > +{
> > +	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
> > +}
> > +
> 
> Please do NOT use division here, which was the source of the
> linkage error, and the reason why I posted a patch to use
> ktime_to_timeval().

On 32 bit platforms, ktime stores as two 32 bit values. Therefore the
division is only 32bit and therefore okay.

Corrected patch.
---------------------------
From 04d3583fbb763deeb9d33c90239a8d35e66e0c1e Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Tue, 24 Apr 2007 12:44:33 -0700
Subject: [PATCH] ktime_to_us: for TCP usage.

Argh, Monday sucks.  Sorry, need to build on 32bit every time...

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 include/linux/ktime.h   |   13 +++++++++++++
 net/ipv4/tcp_illinois.c |    2 +-
 net/ipv4/tcp_lp.c       |    2 +-
 net/ipv4/tcp_vegas.c    |    2 +-
 net/ipv4/tcp_veno.c     |    2 +-
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 248305b..3793490 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -121,6 +121,8 @@ static inline ktime_t timeval_to_ktime(struct timeval tv)
 /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
 #define ktime_to_ns(kt)			((kt).tv64)
 
+#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
+
 #else
 
 /*
@@ -257,6 +259,17 @@ static inline s64 ktime_to_ns(const ktime_t kt)
 	return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
 }
 
+/**
+ * ktime_to_us - convert a ktime_t variable to scalar microseconds
+ * @kt:		the ktime_t variable to convert
+ *
+ * Returns the scalar nanoseconds representation of @kt
+ */
+static inline s64 ktime_to_us(const ktime_t kt)
+{
+	return (s64) kt.tv.sec * USEC_PER_SEC + kt.tv.nsec / NSEC_PER_USEC;
+}
+
 #endif
 
 /*
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..4adc47c 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -90,7 +90,7 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
 
 	ca->acked = pkts_acked;
 
-	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+	rtt = ktime_to_us(net_timedelta(last));
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
 	if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..43294ad 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -266,7 +266,7 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
 
-	tcp_lp_rtt_sample(sk,  ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+	tcp_lp_rtt_sample(sk,  ktime_to_us(net_timedelta(last)));
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..73e19cf 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -118,7 +118,7 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..9edb340 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -75,7 +75,7 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)
-- 
1.5.0.6


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 21:57             ` Stephen Hemminger
@ 2007-04-24 22:12               ` Eric Dumazet
  2007-04-24 22:29                 ` Stephen Hemminger
  2007-04-24 22:15               ` Thomas Gleixner
  1 sibling, 1 reply; 18+ messages in thread
From: Eric Dumazet @ 2007-04-24 22:12 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: YOSHIFUJI Hideaki / 吉藤英明, bunk, davem,
	netdev, tglx

Stephen Hemminger a écrit :
> On Wed, 25 Apr 2007 06:55:39 +0900 (JST)
> YOSHIFUJI Hideaki / 吉藤英明  <yoshfuji@linux-ipv6.org> wrote:
> 
>> In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:
>>
>>> Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
>>> in a way that works on both 64 and 32bit platforms.
>> No, this does not cure.
>>>  
>>> +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
>>> +
>> NSEC_PER_USEC?
> 
> On 64 bit platforms, ktime stores nano-seconds in a 64 bit value, so
> this is correct.

Really ? You introduce a 10^6 error and say it's correct ?

We believe the correct divisor is 10^3 to get usec from nsec, not 10^9


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 21:57             ` Stephen Hemminger
  2007-04-24 22:12               ` Eric Dumazet
@ 2007-04-24 22:15               ` Thomas Gleixner
  2007-04-24 22:49                 ` YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 1 reply; 18+ messages in thread
From: Thomas Gleixner @ 2007-04-24 22:15 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: YOSHIFUJI Hideaki / 吉藤英明, dada1, bunk,
	davem, netdev

On Tue, 2007-04-24 at 14:57 -0700, Stephen Hemminger wrote:
> On Wed, 25 Apr 2007 06:55:39 +0900 (JST)
> YOSHIFUJI Hideaki / 吉藤英明  <yoshfuji@linux-ipv6.org> wrote:
> 
> > In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:
> > 
> > > Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
> > > in a way that works on both 64 and 32bit platforms.
> > 
> > No, this does not cure.
> > >  
> > > +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> > > +
> > 
> > NSEC_PER_USEC?
> 
> On 64 bit platforms, ktime stores nano-seconds in a 64 bit value, so
> this is correct.

Err, nsec_value / NSEC_PER_SEC results in seconds AFAICS

nsec_value / NSEC_PER_USEC gives you microseconds

> > 
> > > +static inline s64 ktime_to_us(const ktime_t kt)
> > > +{
> > > +	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
> > > +}
> > > +
> > 
> > Please do NOT use division here, which was the source of the
> > linkage error, and the reason why I posted a patch to use
> > ktime_to_timeval().
> 
> On 32 bit platforms, ktime stores as two 32 bit values. Therefore the
> division is only 32bit and therefore okay.

Nope.

#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
....

and on i386

config KTIME_SCALAR
        bool
        default y

so you take the 

ktime_to_timeval is probably the right way for it.

	tglx



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 22:12               ` Eric Dumazet
@ 2007-04-24 22:29                 ` Stephen Hemminger
  0 siblings, 0 replies; 18+ messages in thread
From: Stephen Hemminger @ 2007-04-24 22:29 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: YOSHIFUJI Hideaki / 吉藤英明, bunk, davem,
	netdev, tglx

On Wed, 25 Apr 2007 00:12:38 +0200
Eric Dumazet <dada1@cosmosbay.com> wrote:

> Stephen Hemminger a écrit :
> > On Wed, 25 Apr 2007 06:55:39 +0900 (JST)
> > YOSHIFUJI Hideaki / 吉藤英明  <yoshfuji@linux-ipv6.org> wrote:
> > 
> >> In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:
> >>
> >>> Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
> >>> in a way that works on both 64 and 32bit platforms.
> >> No, this does not cure.
> >>>  
> >>> +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> >>> +
> >> NSEC_PER_USEC?
> > 
> > On 64 bit platforms, ktime stores nano-seconds in a 64 bit value, so
> > this is correct.
> 
> Really ? You introduce a 10^6 error and say it's correct ?
> 
> We believe the correct divisor is 10^3 to get usec from nsec, not 10^9
> 
Uh, whimper, your right

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 22:15               ` Thomas Gleixner
@ 2007-04-24 22:49                 ` YOSHIFUJI Hideaki / 吉藤英明
  2007-04-24 23:22                   ` David Miller
  0 siblings, 1 reply; 18+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-24 22:49 UTC (permalink / raw)
  To: tglx, davem; +Cc: shemminger, dada1, bunk, netdev, yoshfuji

In article <1177452915.30986.61.camel@localhost.localdomain> (at Wed, 25 Apr 2007 00:15:15 +0200), Thomas Gleixner <tglx@linutronix.de> says:

> On Tue, 2007-04-24 at 14:57 -0700, Stephen Hemminger wrote:
> > On Wed, 25 Apr 2007 06:55:39 +0900 (JST)
> > YOSHIFUJI Hideaki / 吉藤英明  <yoshfuji@linux-ipv6.org> wrote:
> > 
> > > In article <20070424100420.2860db68@dxpl.pdx.osdl.net> (at Tue, 24 Apr 2007 10:04:20 -0700), Stephen Hemminger <shemminger@linux-foundation.org> says:
> > > 
> > > > Yoshifuji-san had the right idea, but ktime_to_us needs to be defined
> > > > in a way that works on both 64 and 32bit platforms.
> > > 
> > > No, this does not cure.
> > > >  
> > > > +#define ktime_to_us(kt)			((kt).tv64 / NSEC_PER_SEC)
> > > > +
> > > 
> > > NSEC_PER_USEC?
> > 
> > On 64 bit platforms, ktime stores nano-seconds in a 64 bit value, so
> > this is correct.
> 
> Err, nsec_value / NSEC_PER_SEC results in seconds AFAICS
> 
> nsec_value / NSEC_PER_USEC gives you microseconds
> 
> > > 
> > > > +static inline s64 ktime_to_us(const ktime_t kt)
> > > > +{
> > > > +	return (s64) kt.tv_sec * USEC_PER_SEC + kt.tv_nsec / NSEC_PER_USEC;
> > > > +}
> > > > +
> > > 
> > > Please do NOT use division here, which was the source of the
> > > linkage error, and the reason why I posted a patch to use
> > > ktime_to_timeval().
> > 
> > On 32 bit platforms, ktime stores as two 32 bit values. Therefore the
> > division is only 32bit and therefore okay.
> 
> Nope.
> 
> #if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
> ....
> 
> and on i386
> 
> config KTIME_SCALAR
>         bool
>         default y
> 
> so you take the 
> 
> ktime_to_timeval is probably the right way for it.

----
[TCP]: Fix linkage errors on i386.

To avoid raw division, use ktime_to_timeval() to get usec.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

-- 
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 248305b..81bb9c7 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -259,6 +259,12 @@ static inline s64 ktime_to_ns(const ktime_t kt)
 
 #endif
 
+static inline s64 ktime_to_us(const ktime_t kt)
+{
+	struct timeval tv = ktime_to_timeval(kt);
+	return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+}
+
 /*
  * The resolution of the clocks. The resolution value is returned in
  * the clock_getres() system call to give application programmers an
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 8e31659..4adc47c 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -90,7 +90,7 @@ static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
 
 	ca->acked = pkts_acked;
 
-	rtt = ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC;
+	rtt = ktime_to_us(net_timedelta(last));
 
 	/* ignore bogus values, this prevents wraparound in alpha math */
 	if (rtt > RTT_MAX)
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index b4e062a..43294ad 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -266,7 +266,7 @@ static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last)
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct lp *lp = inet_csk_ca(sk);
 
-	tcp_lp_rtt_sample(sk,  ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC);
+	tcp_lp_rtt_sample(sk,  ktime_to_us(net_timedelta(last)));
 
 	/* calc inference */
 	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 0f0ee7f..73e19cf 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -118,7 +118,7 @@ void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 0b50d06..9edb340 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -75,7 +75,7 @@ static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last)
 	u32 vrtt;
 
 	/* Never allow zero rtt or baseRTT */
-	vrtt = (ktime_to_ns(net_timedelta(last)) / NSEC_PER_USEC) + 1;
+	vrtt = ktime_to_us(net_timedelta(last)) + 1;
 
 	/* Filter to find propagation delay: */
 	if (vrtt < veno->basertt)

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix build errors on 32bit platforms with new ktime
  2007-04-24 22:49                 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-24 23:22                   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2007-04-24 23:22 UTC (permalink / raw)
  To: yoshfuji; +Cc: tglx, shemminger, dada1, bunk, netdev

From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Date: Wed, 25 Apr 2007 07:49:32 +0900 (JST)

> [TCP]: Fix linkage errors on i386.
> 
> To avoid raw division, use ktime_to_timeval() to get usec.
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

This one looks good to me, patch applied.

Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2007-04-24 23:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-24 15:17 [net-2.6.22] [TCP]: Fix linkage errors YOSHIFUJI Hideaki / 吉藤英明
2007-04-24 15:53 ` Adrian Bunk
2007-04-24 15:58   ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-24 16:10     ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-24 16:38       ` Eric Dumazet
2007-04-24 17:04         ` [PATCH] Fix build errors on 32bit platforms with new ktime Stephen Hemminger
2007-04-24 18:19           ` Adrian Bunk
2007-04-24 18:48           ` Eric Dumazet
2007-04-24 21:54             ` David Miller
2007-04-24 21:55           ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-24 21:57             ` Stephen Hemminger
2007-04-24 22:12               ` Eric Dumazet
2007-04-24 22:29                 ` Stephen Hemminger
2007-04-24 22:15               ` Thomas Gleixner
2007-04-24 22:49                 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-24 23:22                   ` David Miller
2007-04-24 16:03   ` [net-2.6.22] [TCP]: Fix linkage errors Eric Dumazet
2007-04-24 18:17     ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).