Re: [PATCH RFC] perf kvm stat live: cache mmap()ed events

From: David Ahern
Date: Mon Sep 15 2014 - 10:23:27 EST


On 9/15/14, 6:57 AM, Alexander Yarygin wrote:
David Ahern <dsahern@xxxxxxxxx> writes:

On 9/12/14, 10:27 AM, Alexander Yarygin wrote:
During mmap() process 'perf kvm stat live' gets a pointer to events and
passes them to the session queue. Events are stored in shared memory and
eventually they will be overwritten by the kernel. The problem is, that
when events come too fast, old events can be overwritten before they
have been processed that can lead to perf crash.

To prevent that happening, we can copy upcoming events and pass a copy
to the session queue. There is a safe place to copy event: before
perf_evlist__mmap_consume() is executed. There are 3 places to free it:
when event is processed, when it's lost and on exit, if it's turned out
unprocessed.

Did you see what I proposed a year ago:
https://lkml.org/lkml/2013/9/6/388

The intent is to keep the copy generic and not local a command since
conceptually other live commands need the same.

David

Hello,

Yes, your patch works fine. But as far as I understand, right now only
the 'perf kvm stat live' is infected: other 'live' tools were fixed by
the patch "PERF: The tail position of the event buffer should only be modified
after actually use that event." and since they don't use ordered queue
they don't need a copying. That's why I came up with 'perf kvm stat
live' specific approach. Maybe I missed something...

No, you understand the problem. My point is that the key issue with the code (overwriting events in the mmap'ed buffers) really has nothing to do with perf-kvm. It might be the only command in-tree today but others could come along, so might as well fix the issue in the event processing code.


Anyhow, having >30K events is a quite usual situation on s390 and the
'perf kvm stat live' command hardly works there, so it would be good to
have at least some working solution. Any ideas? :)

Sure. With nested VMs on x86 I see 100,000's of events per second. That use case is what drove me to look at copying events. I just have not had time to come back to that one.

David

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/