All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr
@ 2015-05-05  6:37 Tina Ruchandani
  2015-05-05 14:52 ` Alan Stern
  0 siblings, 1 reply; 4+ messages in thread
From: Tina Ruchandani @ 2015-05-05  6:37 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-usb, Linux Kernel List

> but the timestamp will also overflow. So what is the point?
>

The 32-bit timestamp obtained using do_gettimeofday() will overflow in
year 2038. However, with 64-bit timestamps, we get practically
infinite time. mon_bin_hdr already has support for a 64-bit seconds
timestamp. This patch changes how it is populated.

Thanks,
Tina

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

* Re: [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr
  2015-05-05  6:37 [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr Tina Ruchandani
@ 2015-05-05 14:52 ` Alan Stern
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2015-05-05 14:52 UTC (permalink / raw)
  To: Tina Ruchandani
  Cc: Oliver Neukum, Arnd Bergmann, Greg Kroah-Hartman, linux-usb,
	Linux Kernel List

On Mon, 4 May 2015, Tina Ruchandani wrote:

> > but the timestamp will also overflow. So what is the point?
> >
> 
> The 32-bit timestamp obtained using do_gettimeofday() will overflow in
> year 2038. However, with 64-bit timestamps, we get practically
> infinite time. mon_bin_hdr already has support for a 64-bit seconds
> timestamp. This patch changes how it is populated.

Surely the real point was mentioned in the patch description:

> ... This patch is part of a larger
> attempt to remove instances of struct timeval and other 32-bit timekeeping
> (time_t, struct timespec) from the kernel.

The point is to get rid of 32-bit timekeeping routines.  Overflow and 
the exact nature of the timestamps in usbmon are irrelevant.

Alan Stern


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

* Re: [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr
  2015-05-05  6:20 Tina Ruchandani
@ 2015-05-05  6:25 ` Oliver Neukum
  0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2015-05-05  6:25 UTC (permalink / raw)
  To: Tina Ruchandani
  Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-usb, linux-kernel

On Tue, 2015-05-05 at 11:50 +0530, Tina Ruchandani wrote:
> struct mon_bin_hdr allows for a 64-bit seconds timestamp. The code 
> currently uses 'struct timeval' to populate the timestamp in mon_bin_hdr, 
> which has a 32-bit seconds field and will overflow in year 2038 and beyond.
> This patch replaces 'struct timeval' with 'struct timespec64' which is 
> y2038 safe.

Hi,

but the timestamp will also overflow. So what is the point?

	Regards
		Oliver



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

* [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr
@ 2015-05-05  6:20 Tina Ruchandani
  2015-05-05  6:25 ` Oliver Neukum
  0 siblings, 1 reply; 4+ messages in thread
From: Tina Ruchandani @ 2015-05-05  6:20 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

struct mon_bin_hdr allows for a 64-bit seconds timestamp. The code 
currently uses 'struct timeval' to populate the timestamp in mon_bin_hdr, 
which has a 32-bit seconds field and will overflow in year 2038 and beyond.
This patch replaces 'struct timeval' with 'struct timespec64' which is 
y2038 safe.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/usb/mon/mon_bin.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 9a62e89..bfc2ebd 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -18,6 +18,7 @@
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
+#include <linux/time64.h>
 
 #include <asm/uaccess.h>
 
@@ -483,7 +484,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
     char ev_type, int status)
 {
 	const struct usb_endpoint_descriptor *epd = &urb->ep->desc;
-	struct timeval ts;
+	struct timespec64 ts;
 	unsigned long flags;
 	unsigned int urb_length;
 	unsigned int offset;
@@ -494,7 +495,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
 	struct mon_bin_hdr *ep;
 	char data_tag = 0;
 
-	do_gettimeofday(&ts);
+	getnstimeofday64(&ts);
 
 	spin_lock_irqsave(&rp->b_lock, flags);
 
@@ -568,7 +569,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
 	ep->busnum = urb->dev->bus->busnum;
 	ep->id = (unsigned long) urb;
 	ep->ts_sec = ts.tv_sec;
-	ep->ts_usec = ts.tv_usec;
+	ep->ts_usec = ts.tv_nsec / NSEC_PER_USEC;
 	ep->status = status;
 	ep->len_urb = urb_length;
 	ep->len_cap = length + lendesc;
@@ -629,12 +630,12 @@ static void mon_bin_complete(void *data, struct urb *urb, int status)
 static void mon_bin_error(void *data, struct urb *urb, int error)
 {
 	struct mon_reader_bin *rp = data;
-	struct timeval ts;
+	struct timespec64 ts;
 	unsigned long flags;
 	unsigned int offset;
 	struct mon_bin_hdr *ep;
 
-	do_gettimeofday(&ts);
+	getnstimeofday64(&ts);
 
 	spin_lock_irqsave(&rp->b_lock, flags);
 
@@ -656,9 +657,8 @@ static void mon_bin_error(void *data, struct urb *urb, int error)
 	ep->busnum = urb->dev->bus->busnum;
 	ep->id = (unsigned long) urb;
 	ep->ts_sec = ts.tv_sec;
-	ep->ts_usec = ts.tv_usec;
+	ep->ts_usec = ts.tv_nsec / NSEC_PER_USEC;
 	ep->status = error;
-
 	ep->flag_setup = '-';
 	ep->flag_data = 'E';
 
-- 
2.2.0.rc0.207.ga3a616c


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

end of thread, other threads:[~2015-05-05 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05  6:37 [PATCH] USB: usbmon: Use 64bit timestamp for mon_bin_hdr Tina Ruchandani
2015-05-05 14:52 ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2015-05-05  6:20 Tina Ruchandani
2015-05-05  6:25 ` Oliver Neukum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.