All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/pcifront: Remove usage of struct timeval
@ 2015-05-11  2:44 Tina Ruchandani
  2015-05-11 13:47 ` Konrad Rzeszutek Wilk
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tina Ruchandani @ 2015-05-11  2:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: y2038, Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	Bjorn Helgaas, xen-devel, linux-pci

struct timeval uses a 32-bit field for representing seconds,
which will overflow in the year 2038 and beyond. This patch replaces
struct timeval with 64-bit ktime_t which is 2038 safe.
The patch is part of a larger effort to remove instances of
32-bit timekeeping variables (timeval, time_t and timespec)
from the kernel.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/pci/xen-pcifront.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 7cfd2db..43d1d6c 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	evtchn_port_t port = pdev->evtchn;
 	unsigned irq = pdev->irq;
 	s64 ns, ns_timeout;
-	struct timeval tv;
+	ktime_t tv;
 
 	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +133,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	 * (in the latter case we end up continually re-executing poll() with a
 	 * timeout in the past). 1s difference gives plenty of slack for error.
 	 */
-	do_gettimeofday(&tv);
-	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+	tv = ktime_get_real();
+	ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;
 
 	xen_clear_irq_pending(irq);
 
@@ -141,8 +142,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 			(unsigned long *)&pdev->sh_info->flags)) {
 		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
 		xen_clear_irq_pending(irq);
-		do_gettimeofday(&tv);
-		ns = timeval_to_ns(&tv);
+		tv = ktime_get_real();
+		ns = ktime_to_ns(tv);
 		if (ns > ns_timeout) {
 			dev_err(&pdev->xdev->dev,
 				"pciback not responding!!!\n");
-- 
2.2.0.rc0.207.ga3a616c


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

* Re: [PATCH] xen/pcifront: Remove usage of struct timeval
  2015-05-11  2:44 [PATCH] xen/pcifront: Remove usage of struct timeval Tina Ruchandani
  2015-05-11 13:47 ` Konrad Rzeszutek Wilk
@ 2015-05-11 13:47 ` Konrad Rzeszutek Wilk
  2015-05-11 15:13 ` [Y2038] " Arnd Bergmann
  2015-05-11 15:13 ` Arnd Bergmann
  3 siblings, 0 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-11 13:47 UTC (permalink / raw)
  To: Tina Ruchandani
  Cc: Arnd Bergmann, y2038, Boris Ostrovsky, David Vrabel,
	Bjorn Helgaas, xen-devel, linux-pci

On Mon, May 11, 2015 at 08:14:48AM +0530, Tina Ruchandani wrote:
> struct timeval uses a 32-bit field for representing seconds,
> which will overflow in the year 2038 and beyond. This patch replaces
> struct timeval with 64-bit ktime_t which is 2038 safe.
> The patch is part of a larger effort to remove instances of
> 32-bit timekeeping variables (timeval, time_t and timespec)
> from the kernel.
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>


Looks OK to me.
> ---
>  drivers/pci/xen-pcifront.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 7cfd2db..43d1d6c 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -20,6 +20,7 @@
>  #include <linux/workqueue.h>
>  #include <linux/bitops.h>
>  #include <linux/time.h>
> +#include <linux/ktime.h>
>  #include <xen/platform_pci.h>
>  
>  #include <asm/xen/swiotlb-xen.h>
> @@ -115,7 +116,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  	evtchn_port_t port = pdev->evtchn;
>  	unsigned irq = pdev->irq;
>  	s64 ns, ns_timeout;
> -	struct timeval tv;
> +	ktime_t tv;
>  
>  	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
>  
> @@ -132,8 +133,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  	 * (in the latter case we end up continually re-executing poll() with a
>  	 * timeout in the past). 1s difference gives plenty of slack for error.
>  	 */
> -	do_gettimeofday(&tv);
> -	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
> +	tv = ktime_get_real();
> +	ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;
>  
>  	xen_clear_irq_pending(irq);
>  
> @@ -141,8 +142,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  			(unsigned long *)&pdev->sh_info->flags)) {
>  		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
>  		xen_clear_irq_pending(irq);
> -		do_gettimeofday(&tv);
> -		ns = timeval_to_ns(&tv);
> +		tv = ktime_get_real();
> +		ns = ktime_to_ns(tv);
>  		if (ns > ns_timeout) {
>  			dev_err(&pdev->xdev->dev,
>  				"pciback not responding!!!\n");
> -- 
> 2.2.0.rc0.207.ga3a616c
> 

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

* Re: [PATCH] xen/pcifront: Remove usage of struct timeval
  2015-05-11  2:44 [PATCH] xen/pcifront: Remove usage of struct timeval Tina Ruchandani
@ 2015-05-11 13:47 ` Konrad Rzeszutek Wilk
  2015-05-11 13:47 ` Konrad Rzeszutek Wilk
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-05-11 13:47 UTC (permalink / raw)
  To: Tina Ruchandani
  Cc: Arnd Bergmann, y2038, linux-pci, David Vrabel, Bjorn Helgaas,
	xen-devel, Boris Ostrovsky

On Mon, May 11, 2015 at 08:14:48AM +0530, Tina Ruchandani wrote:
> struct timeval uses a 32-bit field for representing seconds,
> which will overflow in the year 2038 and beyond. This patch replaces
> struct timeval with 64-bit ktime_t which is 2038 safe.
> The patch is part of a larger effort to remove instances of
> 32-bit timekeeping variables (timeval, time_t and timespec)
> from the kernel.
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>


Looks OK to me.
> ---
>  drivers/pci/xen-pcifront.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
> index 7cfd2db..43d1d6c 100644
> --- a/drivers/pci/xen-pcifront.c
> +++ b/drivers/pci/xen-pcifront.c
> @@ -20,6 +20,7 @@
>  #include <linux/workqueue.h>
>  #include <linux/bitops.h>
>  #include <linux/time.h>
> +#include <linux/ktime.h>
>  #include <xen/platform_pci.h>
>  
>  #include <asm/xen/swiotlb-xen.h>
> @@ -115,7 +116,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  	evtchn_port_t port = pdev->evtchn;
>  	unsigned irq = pdev->irq;
>  	s64 ns, ns_timeout;
> -	struct timeval tv;
> +	ktime_t tv;
>  
>  	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
>  
> @@ -132,8 +133,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  	 * (in the latter case we end up continually re-executing poll() with a
>  	 * timeout in the past). 1s difference gives plenty of slack for error.
>  	 */
> -	do_gettimeofday(&tv);
> -	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
> +	tv = ktime_get_real();
> +	ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;
>  
>  	xen_clear_irq_pending(irq);
>  
> @@ -141,8 +142,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
>  			(unsigned long *)&pdev->sh_info->flags)) {
>  		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
>  		xen_clear_irq_pending(irq);
> -		do_gettimeofday(&tv);
> -		ns = timeval_to_ns(&tv);
> +		tv = ktime_get_real();
> +		ns = ktime_to_ns(tv);
>  		if (ns > ns_timeout) {
>  			dev_err(&pdev->xdev->dev,
>  				"pciback not responding!!!\n");
> -- 
> 2.2.0.rc0.207.ga3a616c
> 

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

* Re: [Y2038] [PATCH] xen/pcifront: Remove usage of struct timeval
  2015-05-11  2:44 [PATCH] xen/pcifront: Remove usage of struct timeval Tina Ruchandani
                   ` (2 preceding siblings ...)
  2015-05-11 15:13 ` [Y2038] " Arnd Bergmann
@ 2015-05-11 15:13 ` Arnd Bergmann
  3 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-05-11 15:13 UTC (permalink / raw)
  To: y2038
  Cc: Tina Ruchandani, Konrad Rzeszutek Wilk, linux-pci, David Vrabel,
	Bjorn Helgaas, xen-devel, Boris Ostrovsky

On Monday 11 May 2015 08:14:48 Tina Ruchandani wrote:
> struct timeval uses a 32-bit field for representing seconds,
> which will overflow in the year 2038 and beyond. This patch replaces
> struct timeval with 64-bit ktime_t which is 2038 safe.
> The patch is part of a larger effort to remove instances of
> 32-bit timekeeping variables (timeval, time_t and timespec)
> from the kernel.

The patch looks correct to me, just two minor points:

> +       tv = ktime_get_real();
> +       ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;

* We have a macro for doing this in one line, so you can just use

	ns_timeout = ktime_get_real_ns() + 2 * (s64)NSEC_PER_SEC;

* As the time is not stored anywhere and only used in a local function,
  using monotonic time instead of real time would slightly more appropriate,
  the only difference being the handling of a concurrent settimeofday()
  system call. That means calling ktime_get_ns() instead of ktime_get_real_ns().

	Arnd

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

* Re: [Y2038] [PATCH] xen/pcifront: Remove usage of struct timeval
  2015-05-11  2:44 [PATCH] xen/pcifront: Remove usage of struct timeval Tina Ruchandani
  2015-05-11 13:47 ` Konrad Rzeszutek Wilk
  2015-05-11 13:47 ` Konrad Rzeszutek Wilk
@ 2015-05-11 15:13 ` Arnd Bergmann
  2015-05-11 15:13 ` Arnd Bergmann
  3 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-05-11 15:13 UTC (permalink / raw)
  To: y2038
  Cc: linux-pci, Tina Ruchandani, David Vrabel, Bjorn Helgaas,
	xen-devel, Boris Ostrovsky

On Monday 11 May 2015 08:14:48 Tina Ruchandani wrote:
> struct timeval uses a 32-bit field for representing seconds,
> which will overflow in the year 2038 and beyond. This patch replaces
> struct timeval with 64-bit ktime_t which is 2038 safe.
> The patch is part of a larger effort to remove instances of
> 32-bit timekeeping variables (timeval, time_t and timespec)
> from the kernel.

The patch looks correct to me, just two minor points:

> +       tv = ktime_get_real();
> +       ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;

* We have a macro for doing this in one line, so you can just use

	ns_timeout = ktime_get_real_ns() + 2 * (s64)NSEC_PER_SEC;

* As the time is not stored anywhere and only used in a local function,
  using monotonic time instead of real time would slightly more appropriate,
  the only difference being the handling of a concurrent settimeofday()
  system call. That means calling ktime_get_ns() instead of ktime_get_real_ns().

	Arnd

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

* [PATCH] xen/pcifront: Remove usage of struct timeval
@ 2015-05-11  2:44 Tina Ruchandani
  0 siblings, 0 replies; 6+ messages in thread
From: Tina Ruchandani @ 2015-05-11  2:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: y2038, linux-pci, David Vrabel, Bjorn Helgaas, xen-devel,
	Boris Ostrovsky

struct timeval uses a 32-bit field for representing seconds,
which will overflow in the year 2038 and beyond. This patch replaces
struct timeval with 64-bit ktime_t which is 2038 safe.
The patch is part of a larger effort to remove instances of
32-bit timekeeping variables (timeval, time_t and timespec)
from the kernel.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/pci/xen-pcifront.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 7cfd2db..43d1d6c 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -115,7 +116,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	evtchn_port_t port = pdev->evtchn;
 	unsigned irq = pdev->irq;
 	s64 ns, ns_timeout;
-	struct timeval tv;
+	ktime_t tv;
 
 	spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +133,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 	 * (in the latter case we end up continually re-executing poll() with a
 	 * timeout in the past). 1s difference gives plenty of slack for error.
 	 */
-	do_gettimeofday(&tv);
-	ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+	tv = ktime_get_real();
+	ns_timeout = ktime_to_ns(tv) + 2 * (s64)NSEC_PER_SEC;
 
 	xen_clear_irq_pending(irq);
 
@@ -141,8 +142,8 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
 			(unsigned long *)&pdev->sh_info->flags)) {
 		xen_poll_irq_timeout(irq, jiffies + 3*HZ);
 		xen_clear_irq_pending(irq);
-		do_gettimeofday(&tv);
-		ns = timeval_to_ns(&tv);
+		tv = ktime_get_real();
+		ns = ktime_to_ns(tv);
 		if (ns > ns_timeout) {
 			dev_err(&pdev->xdev->dev,
 				"pciback not responding!!!\n");
-- 
2.2.0.rc0.207.ga3a616c

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

end of thread, other threads:[~2015-05-11 15:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11  2:44 [PATCH] xen/pcifront: Remove usage of struct timeval Tina Ruchandani
2015-05-11 13:47 ` Konrad Rzeszutek Wilk
2015-05-11 13:47 ` Konrad Rzeszutek Wilk
2015-05-11 15:13 ` [Y2038] " Arnd Bergmann
2015-05-11 15:13 ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2015-05-11  2:44 Tina Ruchandani

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.