lkml.org 
[lkml]   [2020]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] ring-buffer: Have nested events still record running time stamp
On Thu, 25 Jun 2020 22:36:11 -0400
Steven Rostedt <rostedt@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

\
 
 \ /
  Last update: 2020-06-26 05:36    [W:0.423 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site