[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] xen/pcifront: Use monotonic clock



Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to user setting the time or due to NTP.

Monotonic time is constantly increasing time better suited for comparing two
timestamps.
---
Âdrivers/pci/xen-pcifront.c | Â 10 +++++-----
Â1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index f7197a7..5ef3eb7 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -114,7 +114,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;
+ struct timespec tv;
Â
 spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
Â
@@ -131,8 +131,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;
+ ktime_get_ts(&tv);
+ ns_timeout = timespec_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
Â
 xen_clear_irq_pending(irq);
Â
@@ -140,8 +140,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);
+ ktime_get_ts(&tv);
+ ns = timespec_to_ns(&tv);
 if (ns > ns_timeout) {
 dev_err(&pdev->xdev->dev,
 "pciback not responding!!!\n");
--Â
1.7.9.5

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.