netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
@ 2008-04-21  7:22 YOSHIFUJI Hideaki / 吉藤英明
  2008-04-21  9:35 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-04-21  7:22 UTC (permalink / raw)
  To: davem; +Cc: yoshfuji, netdev

What do_gettimeofday() does is to call getnstimeofday() and
to convert the result from timespec{} to timeval{}.
We do not always need timeval{} and we can convert timespec{}
when we really need (to print).

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 7053bb8..6e1df62 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -46,29 +46,24 @@ struct {
 	struct kfifo	  *fifo;
 	spinlock_t	  lock;
 	wait_queue_head_t wait;
-	struct timeval	  tstart;
+	struct timespec	  tstart;
 } dccpw;
 
 static void printl(const char *fmt, ...)
 {
 	va_list args;
 	int len;
-	struct timeval now;
+	struct timespec now;
 	char tbuf[256];
 
 	va_start(args, fmt);
-	do_gettimeofday(&now);
+	getnstimeofday(&now);
 
-	now.tv_sec -= dccpw.tstart.tv_sec;
-	now.tv_usec -= dccpw.tstart.tv_usec;
-	if (now.tv_usec < 0) {
-		--now.tv_sec;
-		now.tv_usec += 1000000;
-	}
+	now = timespec_sub(now, dccpw.tstart);
 
 	len = sprintf(tbuf, "%lu.%06lu ",
 		      (unsigned long) now.tv_sec,
-		      (unsigned long) now.tv_usec);
+		      (unsigned long) now.tv_nsec / NSEC_PER_USEC);
 	len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
 	va_end(args);
 
@@ -119,7 +114,7 @@ static struct jprobe dccp_send_probe = {
 static int dccpprobe_open(struct inode *inode, struct file *file)
 {
 	kfifo_reset(dccpw.fifo);
-	do_gettimeofday(&dccpw.tstart);
+	getnstimeofday(&dccpw.tstart);
 	return 0;
 }
 

-- 
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] 7+ messages in thread

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-21  7:22 [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday() YOSHIFUJI Hideaki / 吉藤英明
@ 2008-04-21  9:35 ` David Miller
  2008-04-21 13:48   ` Arnaldo Carvalho de Melo
  2008-04-21 14:03   ` gerrit
  0 siblings, 2 replies; 7+ messages in thread
From: David Miller @ 2008-04-21  9:35 UTC (permalink / raw)
  To: yoshfuji; +Cc: netdev, dccp

From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Date: Mon, 21 Apr 2008 16:22:27 +0900 (JST)

> What do_gettimeofday() does is to call getnstimeofday() and
> to convert the result from timespec{} to timeval{}.
> We do not always need timeval{} and we can convert timespec{}
> when we really need (to print).
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

This looks good too, but I'll be polite and wait for any
DCCP maintainer ACKs :-)

> diff --git a/net/dccp/probe.c b/net/dccp/probe.c
> index 7053bb8..6e1df62 100644
> --- a/net/dccp/probe.c
> +++ b/net/dccp/probe.c
> @@ -46,29 +46,24 @@ struct {
>  	struct kfifo	  *fifo;
>  	spinlock_t	  lock;
>  	wait_queue_head_t wait;
> -	struct timeval	  tstart;
> +	struct timespec	  tstart;
>  } dccpw;
>  
>  static void printl(const char *fmt, ...)
>  {
>  	va_list args;
>  	int len;
> -	struct timeval now;
> +	struct timespec now;
>  	char tbuf[256];
>  
>  	va_start(args, fmt);
> -	do_gettimeofday(&now);
> +	getnstimeofday(&now);
>  
> -	now.tv_sec -= dccpw.tstart.tv_sec;
> -	now.tv_usec -= dccpw.tstart.tv_usec;
> -	if (now.tv_usec < 0) {
> -		--now.tv_sec;
> -		now.tv_usec += 1000000;
> -	}
> +	now = timespec_sub(now, dccpw.tstart);
>  
>  	len = sprintf(tbuf, "%lu.%06lu ",
>  		      (unsigned long) now.tv_sec,
> -		      (unsigned long) now.tv_usec);
> +		      (unsigned long) now.tv_nsec / NSEC_PER_USEC);
>  	len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
>  	va_end(args);
>  
> @@ -119,7 +114,7 @@ static struct jprobe dccp_send_probe = {
>  static int dccpprobe_open(struct inode *inode, struct file *file)
>  {
>  	kfifo_reset(dccpw.fifo);
> -	do_gettimeofday(&dccpw.tstart);
> +	getnstimeofday(&dccpw.tstart);
>  	return 0;
>  }
>  
> 
> -- 
> YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
> GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

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

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-21  9:35 ` David Miller
@ 2008-04-21 13:48   ` Arnaldo Carvalho de Melo
  2008-04-21 21:28     ` David Miller
  2008-04-21 14:03   ` gerrit
  1 sibling, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2008-04-21 13:48 UTC (permalink / raw)
  To: David Miller; +Cc: yoshfuji, netdev, dccp

Em Mon, Apr 21, 2008 at 02:35:03AM -0700, David Miller escreveu:
> From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
> Date: Mon, 21 Apr 2008 16:22:27 +0900 (JST)
> 
> > What do_gettimeofday() does is to call getnstimeofday() and
> > to convert the result from timespec{} to timeval{}.
> > We do not always need timeval{} and we can convert timespec{}
> > when we really need (to print).
> > 
> > Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> 
> This looks good too, but I'll be polite and wait for any
> DCCP maintainer ACKs :-)

Thanks everybody:

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo

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

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-21  9:35 ` David Miller
  2008-04-21 13:48   ` Arnaldo Carvalho de Melo
@ 2008-04-21 14:03   ` gerrit
  1 sibling, 0 replies; 7+ messages in thread
From: gerrit @ 2008-04-21 14:03 UTC (permalink / raw)
  To: David Miller; +Cc: yoshfuji, netdev, dccp

> From: YOSHIFUJI Hideaki / ^[$B5HF#1QL@^[(B <yoshfuji@linux-ipv6.org>
> Date: Mon, 21 Apr 2008 16:22:27 +0900 (JST)
>
>> What do_gettimeofday() does is to call getnstimeofday() and
>> to convert the result from timespec{} to timeval{}.
>> We do not always need timeval{} and we can convert timespec{}
>> when we really need (to print).
>>
>> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>
> This looks good too, but I'll be polite and wait for any
> DCCP maintainer ACKs :-)
>
This mirrors a patch which is currently in the test tree and does the
update to timespec, apart from a few other changes. It is a good idea,
since that in turn mirrors tcp_probe.c
Hope Arnado will in some future have time to look at some of the test tree
patches, in any case this patch does not harm.



The University of Aberdeen is a charity registered in Scotland, No SC013683.


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

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-21 13:48   ` Arnaldo Carvalho de Melo
@ 2008-04-21 21:28     ` David Miller
  2008-04-22  2:40       ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2008-04-21 21:28 UTC (permalink / raw)
  To: acme; +Cc: yoshfuji, netdev, dccp

From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Mon, 21 Apr 2008 10:48:44 -0300

> Em Mon, Apr 21, 2008 at 02:35:03AM -0700, David Miller escreveu:
> > From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
> > Date: Mon, 21 Apr 2008 16:22:27 +0900 (JST)
> > 
> > > What do_gettimeofday() does is to call getnstimeofday() and
> > > to convert the result from timespec{} to timeval{}.
> > > We do not always need timeval{} and we can convert timespec{}
> > > when we really need (to print).
> > > 
> > > Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> > 
> > This looks good too, but I'll be polite and wait for any
> > DCCP maintainer ACKs :-)
> 
> Thanks everybody:
> 
> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Thanks for reviewing, patch applied.

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

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-21 21:28     ` David Miller
@ 2008-04-22  2:40       ` YOSHIFUJI Hideaki / 吉藤英明
  2008-04-22  2:45         ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-04-22  2:40 UTC (permalink / raw)
  To: davem; +Cc: acme, netdev, dccp, yoshfuji

In article <20080421.142857.234288906.davem@davemloft.net> (at Mon, 21 Apr 2008 14:28:57 -0700 (PDT)), David Miller <davem@davemloft.net> says:

> Thanks for reviewing, patch applied.

Sorry I have just realized set_normalized_timespec() (used in timespec_sub())
is not exported, and link will fail because of it...

What should I/we do?  Send the patch to LKML as well?

---

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
diff --git a/kernel/time.c b/kernel/time.c
index a5ec013..35d373a 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -379,6 +379,7 @@ void set_normalized_timespec(struct time
 	ts->tv_sec = sec;
 	ts->tv_nsec = nsec;
 }
+EXPORT_SYMBOL(set_normalized_timespec);
 
 /**
  * ns_to_timespec - Convert nanoseconds to timespec


--yoshfuji

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

* Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
  2008-04-22  2:40       ` YOSHIFUJI Hideaki / 吉藤英明
@ 2008-04-22  2:45         ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2008-04-22  2:45 UTC (permalink / raw)
  To: yoshfuji; +Cc: acme, netdev, dccp

From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Date: Tue, 22 Apr 2008 11:40:42 +0900 (JST)

> In article <20080421.142857.234288906.davem@davemloft.net> (at Mon, 21 Apr 2008 14:28:57 -0700 (PDT)), David Miller <davem@davemloft.net> says:
> 
> > Thanks for reviewing, patch applied.
> 
> Sorry I have just realized set_normalized_timespec() (used in timespec_sub())
> is not exported, and link will fail because of it...
> 
> What should I/we do?  Send the patch to LKML as well?

I'll apply and push this change, thank you.

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

end of thread, other threads:[~2008-04-22  2:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-21  7:22 [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday() YOSHIFUJI Hideaki / 吉藤英明
2008-04-21  9:35 ` David Miller
2008-04-21 13:48   ` Arnaldo Carvalho de Melo
2008-04-21 21:28     ` David Miller
2008-04-22  2:40       ` YOSHIFUJI Hideaki / 吉藤英明
2008-04-22  2:45         ` David Miller
2008-04-21 14:03   ` gerrit

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).