From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24014 invoked by alias); 17 Mar 2006 16:20:50 -0000 Received: (qmail 24004 invoked by uid 22791); 17 Mar 2006 16:20:49 -0000 X-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_05,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 17 Mar 2006 16:20:48 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k2HGKllt023920 for ; Fri, 17 Mar 2006 11:20:47 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id k2HGKl101680; Fri, 17 Mar 2006 11:20:47 -0500 Received: from [172.16.59.162] (dhcp59-162.rdu.redhat.com [172.16.59.162]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id k2HGKkGx017395; Fri, 17 Mar 2006 11:20:46 -0500 Message-ID: <441AE1DE.2040207@redhat.com> Date: Fri, 17 Mar 2006 16:20:00 -0000 From: William Cohen User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Frank Ch. Eigler" CC: systemtap@sources.redhat.com Subject: Re: Proposed systemtap access to perfmon hardware References: <44183FCF.6010809@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q1/txt/msg00821.txt.bz2 To try to get a feel on how the performance monitoring hardware support would work in SystemTap I wrote some simple examples. Below are examples for computing IPC, average cycle count, and sampling within a function. The IPC and average cycle count function need a bit of rework to work for a SMP machines. Let me know if there are comments or questions on the examples. -Will COMPUTING IPC global cycles_h global instr_retired_h probe perfmon.event("cycles") {cycles_h = $handle;} probe perfmon.event("intr_retired") {instr_retired_h = $handle;} probe begin {print ("start probe");} probe end { factor=100; ipc = (factor*perfmon_get_counter(intr_retired_h))/ perfmon_get_counter(cycles_h); print ("ipc is %d.%d \n", ipc/factor, ipc % factor); } DETERMINING AVERAGE CYCLE COUNT FOR FUNCTION (AND CHILDREN) global cycles_h probe perfmon.event("cycles") { cycles_h = $handle; perfmon_stop_counter(cycles_h); } global count probe kernel.function("blah"){ ++count; perfmon_start_counter(cycles_h); } probe kernel.function.return("blah"){ perfmon_stop_counter(cycles_h); } probe begin {print ("start probe");} probe end { total_cycles=perfmon_stop_counter(cycles_h); print ("average count in blah %d\n", total_cycles/count); } SAMPLING WITHIN A FUNCTION (AND CHILDREN) global cycles_h global where_am_i probe perfmon.event("cycles").sample(100000) { cycles_h = $handle; # record where sample occured where_am_i[instruction_pointer()]++; } global count probe kernel.function("blah"){ ++count; perfmon_start_counter(cycles_h); } probe kernel.function("blah").return{ perfmon_stop_counter(cycles_h); } probe begin { # turn off the sampling perfmon_stop_counter(cycles_h); print("start probe"); } probe end { #write out the where_am_i entries print("address\tcount\n"); foreach ([+ip] in where_am_i) { print("0x%x\t%d\n", ip, where_am_i[ip]); } }