On Thu, 25 Jun 2020 22:36:11 -0400 Steven Rostedt <rost...@goodmis.org> wrote:
> +static void rb_time_set(rb_time_t *t, u64 val) > +{ > + struct rb_time_read r; > + > + rb_time_read_set(&r, val); > + > + do { > + r.start_cnt = local_inc_return(&t->start_cnt); > + local_set(&t->top, r.top); > + local_set(&t->bottom, r.bottom); > + local_set(&t->end_cnt, r.start_cnt); > + } while (r.start_cnt != local_read(&t->start_cnt)); > +} > + > +static bool rb_time_read_cmpxchg(local_t *l, unsigned long expect, unsigned > long set) > +{ > + unsigned long ret; > + > + ret = local_cmpxchg(l, expect, set); > + return ret == expect; > +} > + > +static bool rb_time_cmpxchg(rb_time_t *t, u64 expect, u64 set) > +{ > + struct rb_time_read e, s; > + > + rb_time_read_set(&e, expect); > + rb_time_read_set(&s, set); > + > + e.start_cnt = local_read(&t->start_cnt); > + e.end_cnt = local_read(&t->end_cnt); > + > + s.start_cnt = e.start_cnt + 1; > + s.end_cnt = e.start_cnt; > + > + if (!rb_time_read_cmpxchg(&t->start_cnt, e.start_cnt, s.start_cnt)) > + return false; > + if (!rb_time_read_cmpxchg(&t->top, e.top, s.top)) > + return false; > + if (!rb_time_read_cmpxchg(&t->bottom, e.bottom, s.bottom)) > + return false; > + return rb_time_read_cmpxchg(&t->end_cnt, e.end_cnt, s.end_cnt); > +} > + I have to think about this more, as I think there's a flaw in this cmpxchg algorithm. -- Steve