Re: [PATCH RFC] hist lookups

From: Jiri Olsa
Date: Tue Nov 06 2018 - 15:43:01 EST


On Mon, Nov 05, 2018 at 08:53:42PM -0800, David Miller wrote:
>
> Jiri,
>
> Because you now run queued_events__queue() lockless with that condvar
> trick, it is possible for top->qe.in to be seen as one past the data[]
> array, this is because the rotate_queues() code goes:
>
> if (++top->qe.in > &top->qe.data[1])
> top->qe.in = &top->qe.data[0];
>
> So for a brief moment top->qe.in is out of range and thus
> perf_top__mmap_read_idx() can try to enqueue to top->qe.data[2]
>
> We can just do:
>
> if (top->qe.in == &top->qe.data[1])
> top->qe.in = &top->qe.data[0];
> else
> top->qe.in = &top->qe.data[1];
>
> Or, make top->qe.in an index, and simply go:
>
> top->qe.in ^= 1;
>
> Either way will fix the bug.

I pushed that fix in perf/fixes branch, but I'm still occasionaly
hitting the namespace crash.. working on it ;-)

[root@krava perf]# ./perf top -d 1 -g
perf: Segmentation fault
-------- backtrace --------
./perf[0x5956aa]
/lib64/libc.so.6(+0x36f2f)[0x7f99d05d3f2f]
/lib64/libc.so.6(+0x15ce60)[0x7f99d06f9e60]
./perf(namespaces__new+0x5a)[0x4fdeaa]
./perf(thread__set_namespaces+0x55)[0x4ff335]
./perf(machine__process_namespaces_event+0xa5)[0x4f1c95]
./perf[0x44c78b]
./perf(queued_events__flush+0xcd)[0x4fd46d]
./perf[0x44c25b]
/lib64/libpthread.so.0(+0x7593)[0x7f99d2928593]
/lib64/libc.so.6(clone+0x3e)[0x7f99d0696e6e]

jirka