netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: yoshfuji@linux-ipv6.org
Cc: netdev@vger.kernel.org, dccp@vger.kernel.org
Subject: Re: [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday().
Date: Mon, 21 Apr 2008 02:35:03 -0700 (PDT)	[thread overview]
Message-ID: <20080421.023503.242108516.davem@davemloft.net> (raw)
In-Reply-To: <20080421.162227.63020853.yoshfuji@linux-ipv6.org>

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

  reply	other threads:[~2008-04-21  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21  7:22 [PATCH] [DCCP]: Convert do_gettimeofday() to getnstimeofday() YOSHIFUJI Hideaki / 吉藤英明
2008-04-21  9:35 ` David Miller [this message]
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

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=20080421.023503.242108516.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dccp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).