Thanks for the acks. I pushed this series. Before I did, while testing, I figured out that I forgot to add code to set slow_path to true in timeval_warp_cb(), so I fixed that before pushing.
On Fri, Sep 13, 2013 at 01:30:36PM -0700, Ethan Jackson wrote: > Acked-by: Ethan Jackson <et...@nicira.com> > > > On Fri, Sep 13, 2013 at 1:01 PM, Ben Pfaff <b...@nicira.com> wrote: > > Commit 31ef9f5178dee18 (timeval: Remove CACHE_TIME scheme.) inadvertently > > removed the ability to warp time forward, for use in tests, except when > > time is stopped. This fixes the problem. > > > > Signed-off-by: Ben Pfaff <b...@nicira.com> > > --- > > lib/timeval.c | 21 +++++++++++++++++++-- > > 1 file changed, 19 insertions(+), 2 deletions(-) > > > > diff --git a/lib/timeval.c b/lib/timeval.c > > index 64d65ea..8c6956e 100644 > > --- a/lib/timeval.c > > +++ b/lib/timeval.c > > @@ -44,6 +44,7 @@ struct clock { > > > > /* Features for use by unit tests. Protected by 'rwlock'. */ > > struct ovs_rwlock rwlock; > > + atomic_bool slow_path; /* True if warped or stopped. */ > > struct timespec warp OVS_GUARDED; /* Offset added for unit tests. */ > > bool stopped OVS_GUARDED; /* Disable real-time updates if > > true. */ > > struct timespec cache OVS_GUARDED; /* Last time read from kernel. */ > > @@ -76,6 +77,7 @@ init_clock(struct clock *c, clockid_t id) > > memset(c, 0, sizeof *c); > > c->id = id; > > ovs_rwlock_init(&c->rwlock); > > + atomic_init(&c->slow_path, false); > > xclock_gettime(c->id, &c->cache); > > } > > > > @@ -104,14 +106,28 @@ time_init(void) > > static void > > time_timespec__(struct clock *c, struct timespec *ts) > > { > > + bool slow_path; > > + > > time_init(); > > > > - if (!c->stopped) { > > + atomic_read_explicit(&c->slow_path, &slow_path, memory_order_relaxed); > > + if (!slow_path) { > > xclock_gettime(c->id, ts); > > } else { > > + struct timespec warp; > > + struct timespec cache; > > + bool stopped; > > + > > ovs_rwlock_rdlock(&c->rwlock); > > - timespec_add(ts, &c->cache, &c->warp); > > + stopped = c->stopped; > > + warp = c->warp; > > + cache = c->cache; > > ovs_rwlock_unlock(&c->rwlock); > > + > > + if (!stopped) { > > + xclock_gettime(c->id, &cache); > > + } > > + timespec_add(ts, &cache, &warp); > > } > > } > > > > @@ -461,6 +477,7 @@ timeval_stop_cb(struct unixctl_conn *conn, > > void *aux OVS_UNUSED) > > { > > ovs_rwlock_wrlock(&monotonic_clock.rwlock); > > + atomic_store(&monotonic_clock.slow_path, true); > > monotonic_clock.stopped = true; > > xclock_gettime(monotonic_clock.id, &monotonic_clock.cache); > > ovs_rwlock_unlock(&monotonic_clock.rwlock); > > -- > > 1.7.10.4 > > > > _______________________________________________ > > dev mailing list > > dev@openvswitch.org > > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev