From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Wiki docs on counting and tracing KVM perf events Date: Thu, 20 May 2010 15:14:52 +0300 Message-ID: <4BF527BC.2030709@redhat.com> References: <4BEC1345.7040408@redhat.com> <4BF4EF97.5060705@redhat.com> <4BF4F07F.4020007@redhat.com> <4BF4F1D1.6030203@redhat.com> <4BF518C1.60304@redhat.com> <4BF519FE.6040208@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Jes Sorensen , kvm To: Stefan Hajnoczi Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42596 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754974Ab0ETMO4 (ORCPT ); Thu, 20 May 2010 08:14:56 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 05/20/2010 02:23 PM, Stefan Hajnoczi wrote: > On Thu, May 20, 2010 at 12:16 PM, Jes Sorensen wrote: > >> On 05/20/10 13:10, Avi Kivity wrote: >> >>> What's wrong with starting perf after the warm-up period and stopping it >>> before it's done? >>> >> It's pretty hard to script. >> > I use the following. It ain't pretty: > > #!/bin/bash > cleanup() { > trap - 2 > kill -2 $sleep_pid > echo 0>/sys/kernel/debug/tracing/events/kvm/enable > kill $cat_pid > } > > perf stat -a -e 'kvm:*' sleep 1h>results/perf_stat 2>&1& > sleep_pid=$(sleep 1&& pgrep -x -f "sleep 1h") # sleep 1 is to avoid > race with forked perf process > trap cleanup 2 > echo 1>/sys/kernel/debug/tracing/events/kvm/enable > cat /sys/kernel/debug/tracing/trace_pipe>results/trace& > cat_pid=$! > > # ...do stuff here... > > cleanup > perf will enable the events by itself (no?), so all you need is is the perf call in the middle. What's missing is vmstat-like or kvm_stat-like output, but that's another thing. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.