From owner-kernprof@oss.sgi.com Thu Jul 11 14:09:56 2002 Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6BL9uRw029373 for ; Thu, 11 Jul 2002 14:09:56 -0700 Received: (from majordomo@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6BL9uLc029367 for kernprof-outgoing; Thu, 11 Jul 2002 14:09:56 -0700 X-Authentication-Warning: oss.sgi.com: majordomo set sender to owner-kernprof@oss.sgi.com using -f Received: from web10105.mail.yahoo.com (web10105.mail.yahoo.com [216.136.130.55]) by oss.sgi.com (8.12.5/8.12.5) with SMTP id g6BL9mRw029346 for ; Thu, 11 Jul 2002 14:09:49 -0700 Message-ID: <20020711211424.70160.qmail@web10105.mail.yahoo.com> Received: from [64.165.125.212] by web10105.mail.yahoo.com via HTTP; Thu, 11 Jul 2002 14:14:24 PDT Date: Thu, 11 Jul 2002 14:14:24 -0700 (PDT) From: Marko Kiiskila Subject: x86 profiling To: kernprof@oss.sgi.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-kernprof@oss.sgi.com Precedence: bulk Hi, I patched a 2.4.9 kernel with the profiling package, and the kernel crashes right away when I try to enable some other mode than PC sampling. Seems like the combination of regparm, -pg flag and -O2 flag are causing trouble. I tried Redhat's gcc 2.96, as well as their gcc 3.0.4, and I'm seeing this behavior with both of the compilers. If I compile kernel with '-O2', call to mcount is done as the very first thing with functions which are declared with 'asmlinkage'. c0142c20 : c0142c20: e8 2b c7 0c 00 call c020f350 c0142c25: 55 push %ebp c0142c26: 89 e5 mov %esp,%ebp c0142c28: 57 push %edi c0142c29: 56 push %esi c0142c2a: 53 push %ebx c0142c2b: 56 push %esi But if I drop the optimization level to -O, call to mcount is done after contents of esp have been moved to ebp. c0140fd0 : c0140fd0: 55 push %ebp c0140fd1: 89 e5 mov %esp,%ebp c0140fd3: 57 push %edi c0140fd4: 56 push %esi c0140fd5: 53 push %ebx c0140fd6: 83 ec 04 sub $0x4,%esp c0140fd9: e8 42 43 0c 00 call c0205320 c0140fde: 8b 7d 0c mov 0xc(%ebp),%edi c0140fe1: 8b 5d 10 mov 0x10(%ebp),%ebx I assume this is a gcc bug, but I'm a bit suprised that I haven't seen anybody else report this. Comments? -- M __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com From owner-kernprof@oss.sgi.com Thu Jul 11 14:21:43 2002 Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6BLLhRw029889 for ; Thu, 11 Jul 2002 14:21:43 -0700 Received: (from majordomo@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6BLLhA4029888 for kernprof-outgoing; Thu, 11 Jul 2002 14:21:43 -0700 X-Authentication-Warning: oss.sgi.com: majordomo set sender to owner-kernprof@oss.sgi.com using -f Received: from deliverator.sgi.com (deliverator.SGI.COM [204.94.214.10] (may be forged)) by oss.sgi.com (8.12.5/8.12.5) with SMTP id g6BLLeRw029885 for ; Thu, 11 Jul 2002 14:21:41 -0700 Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by deliverator.sgi.com (980327.SGI.8.8.8-aspam/980304.SGI-aspam: SGI does not authorize the use of its proprietary systems or networks for unsolicited or bulk email from the Internet.) via ESMTP id OAA04449 for ; Thu, 11 Jul 2002 14:26:14 -0700 (PDT) mail_from (hawkes@sgi.com) Received: from pchawkes (dhcp-163-154-5-201.engr.sgi.com [163.154.5.201]) by cthulhu.engr.sgi.com (SGI-8.9.3/8.9.3) with SMTP id OAA56871; Thu, 11 Jul 2002 14:24:59 -0700 (PDT) Message-ID: <006d01c22921$8d3deaa0$c9059aa3@engr.sgi.com> From: "John Hawkes" To: "Marko Kiiskila" , References: <20020711211424.70160.qmail@web10105.mail.yahoo.com> Subject: Re: x86 profiling Date: Thu, 11 Jul 2002 14:25:59 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Sender: owner-kernprof@oss.sgi.com Precedence: bulk > I patched a 2.4.9 kernel with the profiling package, > and the kernel crashes right away when I try to > enable some other mode than PC sampling. > > Seems like the combination of regparm, -pg flag and > -O2 flag are causing trouble. > I tried Redhat's gcc 2.96, as well as their gcc 3.0.4, > and I'm seeing this behavior with both of the > compilers. Yes, indeed. For gcc 2.96 you need the gcc patch that's on the kernprof website. I don't have much experience with gcc 3.x and kernprof, so I don't know how to solve that problem. John Hawkes From owner-kernprof@oss.sgi.com Thu Jul 11 16:35:34 2002 Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6BNZYRw026432 for ; Thu, 11 Jul 2002 16:35:34 -0700 Received: (from majordomo@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6BNZYl2026431 for kernprof-outgoing; Thu, 11 Jul 2002 16:35:34 -0700 X-Authentication-Warning: oss.sgi.com: majordomo set sender to owner-kernprof@oss.sgi.com using -f Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6BNZWRw026428 for ; Thu, 11 Jul 2002 16:35:32 -0700 Received: (from hawkes@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6BNZWlI026427 for kernprof@oss.sgi.com; Thu, 11 Jul 2002 16:35:32 -0700 Date: Thu, 11 Jul 2002 16:35:32 -0700 From: John Hawkes Message-Id: <200207112335.g6BNZWlI026427@oss.sgi.com> To: kernprof@oss.sgi.com Subject: Kernprof 0.12.2 (better call graph scalability) available Sender: owner-kernprof@oss.sgi.com Precedence: bulk FYI, a new kernprof kernel patch, version 0.12.2, is now available for 2.4.18, 2.5.8, 2.5.10, and 2.5.17. This differs from the previous v0.12.1 solely in changes to the file drivers/char/profile.c that greatly improve the scaling performance for the Call Graph and Annotated Call Graph modes. (Various global counters are now per-cpu counters on isolated cachelines.) John Hawkes hawkes@sgi.com From owner-kernprof@oss.sgi.com Thu Jul 18 17:22:53 2002 Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6J0MrRw011327 for ; Thu, 18 Jul 2002 17:22:53 -0700 Received: (from majordomo@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6J0MrP6011326 for kernprof-outgoing; Thu, 18 Jul 2002 17:22:53 -0700 X-Authentication-Warning: oss.sgi.com: majordomo set sender to owner-kernprof@oss.sgi.com using -f Received: from mcs.anl.gov (cliff.mcs.anl.gov [140.221.9.17]) by oss.sgi.com (8.12.5/8.12.5) with SMTP id g6J0MoRw011323 for ; Thu, 18 Jul 2002 17:22:51 -0700 Received: from capernicus.mcs.anl.gov (capernicus.mcs.anl.gov [140.221.11.67]) by mcs.anl.gov (8.9.3/8.9.3) with ESMTP id TAA162128 for ; Thu, 18 Jul 2002 19:23:21 -0500 Date: Thu, 18 Jul 2002 19:23:21 -0500 (CDT) From: Murali Vilayannur To: kernprof@oss.sgi.com Subject: Question? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-kernprof@oss.sgi.com Precedence: bulk Hi, I have kernprof 1.4 installed successfully on a 2.4.17 UP x86 machine. I am using gcc-2.95.3 patched as instructed on the website. I was wondering if there is currently anyway for kernprof to show dynamically loaded module symbols/names in the profile output. I do have /proc support and theoretically we should be able to map the numeric addresses to /proc/ksyms, but is adding such a feature feasible or am I missing something? I am not on the kernprof mailing list, so could you please cc the reply to me. Thanks a lot, Murali From owner-kernprof@oss.sgi.com Fri Jul 26 03:41:39 2002 Received: from oss.sgi.com (localhost [127.0.0.1]) by oss.sgi.com (8.12.5/8.12.5) with ESMTP id g6QAfdRw012322 for ; Fri, 26 Jul 2002 03:41:39 -0700 Received: (from majordomo@localhost) by oss.sgi.com (8.12.5/8.12.3/Submit) id g6QAfdiv012321 for kernprof-outgoing; Fri, 26 Jul 2002 03:41:39 -0700 X-Authentication-Warning: oss.sgi.com: majordomo set sender to owner-kernprof@oss.sgi.com using -f Received: from e21.nc.us.ibm.com (e21.nc.us.ibm.com [32.97.136.227]) by oss.sgi.com (8.12.5/8.12.5) with SMTP id g6QAfPRw012317 for ; Fri, 26 Jul 2002 03:41:25 -0700 Received: from westrelay03.boulder.ibm.com (westrelay03.boulder.ibm.com [9.17.194.24]) by e21.nc.us.ibm.com (8.12.2/8.12.2) with ESMTP id g6QAgORY159918; Fri, 26 Jul 2002 06:42:24 -0400 Received: from asterix.in.ibm.com (asterix.in.ibm.com [9.182.12.249]) by westrelay03.boulder.ibm.com (8.12.3/NCO/VER6.3) with ESMTP id g6QAgLUa026344; Fri, 26 Jul 2002 04:42:22 -0600 Received: (from kirant@localhost) by asterix.in.ibm.com (8.11.2/8.11.2) id g6QAhg719101; Fri, 26 Jul 2002 16:13:42 +0530 Date: Fri, 26 Jul 2002 16:13:42 +0530 From: Ravikiran G Thirumalai To: lse Cc: kernprof Subject: [patch 2.5.25] NMI patch for kernprof Message-ID: <20020726161342.A18570@in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-kernprof@oss.sgi.com Precedence: bulk Following patch works on top of Adam Litke's 2.5.25 Kernprof profiler available on lse. This patch modifies the PMC event generated interupts to be delivered in NMI mode. This works just like oprofile (oprofile uses PMCs for profiling too). With this patch and PMC domain profiling, Profilng is done from the NMI handler and not from the timer interrupt. Eg Usage: 1. kernprof -b -c all -d pmc -a 0x0020079 -f 8000 - To start profiling (in NMI mode with CPU_CLKS_UNHALTED event) the -f 8000 argument implies 8000 CPU_CLKS_UNHALTED event cause a profiling interrupt. i.e one profiling interrupt every 10 us on a 800MHz machine. (Event shown is for P6 family) 2. kernprof -i -m /boot/System.map for reporting as usual I made this for my use. But just in case anybody needs to use this..... Comments/flames welcome. Thanks, -Kiran diff -ruN -X dontdiff linux-2.5.25/arch/i386/Config.help profile-2.5.25/arch/i386/Config.help --- linux-2.5.25/arch/i386/Config.help Wed Jul 24 13:11:19 2002 +++ profile-2.5.25/arch/i386/Config.help Wed Jul 24 13:03:55 2002 @@ -950,6 +950,12 @@ The module will be called profile.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. +CONFIG_NMI_PROFILING + Saying Y here will set the interrupt delivery mode for PMC domain + profiling to NMI. This is useful if you want to profile kernel code + paths which mask interrputs (eg. code between spin_lock_irq and + spin_unlock_irq). + CONFIG_MCOUNT This will instrument the kernel with calls to mcount(), which enables call-graph and call-count profiling. Because mcount() is called at diff -ruN -X dontdiff linux-2.5.25/arch/i386/config.in profile-2.5.25/arch/i386/config.in --- linux-2.5.25/arch/i386/config.in Wed Jul 24 13:11:19 2002 +++ profile-2.5.25/arch/i386/config.in Wed Jul 24 13:03:55 2002 @@ -424,6 +424,7 @@ tristate 'Kernel Profiling Support' CONFIG_PROFILING if [ "$CONFIG_PROFILING" != "n" ]; then define_bool CONFIG_FRAME_POINTER y + bool ' Use NMI delivery for PMC events profiling' CONFIG_NMI_PROFILING fi bool 'Instrument kernel at entry to all C functions' CONFIG_MCOUNT if [ "$CONFIG_MCOUNT" = "y" ]; then diff -ruN -X dontdiff linux-2.5.25/arch/i386/kernel/apic.c profile-2.5.25/arch/i386/kernel/apic.c --- linux-2.5.25/arch/i386/kernel/apic.c Wed Jul 24 13:11:19 2002 +++ profile-2.5.25/arch/i386/kernel/apic.c Wed Jul 24 13:03:55 2002 @@ -30,6 +30,7 @@ #include #include #include +#include /* Using APIC to generate smp_local_timer_interrupt? */ int using_apic_timer = 0; @@ -984,7 +985,7 @@ void __init setup_APIC_perfctr_vector(void *unused) { (void) apic_read(APIC_LVTPC); - apic_write(APIC_LVTPC, PERFCTR_OVFL_VECTOR); + apic_write(APIC_LVTPC, PERFCTR_OVFL_VECTOR_MODE); } void __init setup_APIC_perfctr(void) diff -ruN -X dontdiff linux-2.5.25/arch/i386/kernel/traps.c profile-2.5.25/arch/i386/kernel/traps.c --- linux-2.5.25/arch/i386/kernel/traps.c Sat Jul 6 05:12:14 2002 +++ profile-2.5.25/arch/i386/kernel/traps.c Wed Jul 24 13:03:55 2002 @@ -491,6 +491,10 @@ return; } #endif +#if CONFIG_NMI_PROFILING + smp_apic_perfctr_overflow_interrupt(*regs); + return; +#endif unknown_nmi_error(reason, regs); return; } diff -ruN -X dontdiff linux-2.5.25/include/asm-i386/profile.h profile-2.5.25/include/asm-i386/profile.h --- linux-2.5.25/include/asm-i386/profile.h Wed Jul 24 13:11:19 2002 +++ profile-2.5.25/include/asm-i386/profile.h Wed Jul 24 13:03:55 2002 @@ -137,6 +137,12 @@ wrmsr(MSR_P6_EVNTSEL1, 0, 0); wrmsr(MSR_P6_EVNTSEL0, EVENTSEL0_ENABLE_MASK | (evt), 0); } +#ifdef CONFIG_NMI_PROFILING +#define PERFCTR_OVFL_VECTOR_MODE \ + SET_APIC_DELIVERY_MODE(PERFCTR_OVFL_VECTOR, APIC_MODE_NMI) +#else +#define PERFCTR_OVFL_VECTOR_MODE PERFCTR_OVFL_VECTOR +#endif #else #define have_perfctr() 0 #define valid_perfctr_event(e) 0