Re: PMC (performance counters) problems - kernel panic in 6-beta1

From: Joseph Koshy <jkoshy_at_FreeBSD.ORG>
Date: Wed, 27 Jul 2005 03:59:28 +0000 (GMT)
>>>> "mc" == "Martin Cracauer" said:

mc> In FreeBSD 6-beta1, source of yesterday, on a Pentium-M I get a kernel
mc> panic. 

There are a few changes I need to MFC over still [patch at the end].

mc> I tried all values from `pmccontrol -L` (in a loop) and all of them
mc> are always zero (some fail with e.g. "pmcstat: ERROR: Cannot allocate
mc> process-mode pmc with specification
mc> "k8-nb-memory-controller-page-access-event": Invalid argument").

Do "system-mode/counting" PMCs work?  I.e. using "-s" instead of "-p".

mc> machine dmesg, kernel conf, pciconf etc is on:
mc> http://www.cons.org/cracauer/machines/wings/

Config option 'HWPMC_HOOKS' seems to be missing from this configuration
file, which might explain the observed behaviour.

Originally, the hwpmc(4) module would messily fail to load if a
kernel hadn't been compiled with option HWPMC_HOOKS since such a
kernel would be missing the symbols defined in "sys/kern/kern_pmc.c".
As of r1.2 of "sys/kern/kern_pmc.c", the symbols are always present
in the kernel so this particular method of preventing user foot-shooting
now fails to work.  I need to fix this.

Here is how things should be:

  # cat /tmp/chomp
  #!/bin/sh
  count=0
  while :; do
	  echo $count > /dev/null
	  count=`expr $count + 1`
	  sleep 1
  done

  # /tmp/chomp &
  [1] 6672

  # pmcstat -p k8-dc-l1-dtlb-miss-and-l2-dtlb-hit -p k8-dc-l1-dtlb-miss-and-l2-dtlb-miss -w1 -t 6672
					      248                                   4112 
					      247                                   3757 
					      245                                   4443 
					      258                                   3615 ^C
  # uname -a
  FreeBSD mindolluin 6.0-CURRENT FreeBSD 6.0-CURRENT #26: Wed Jul 13 19:34:17 IST 2005 \
      root_at_mindolluin:/home/obj/home/fcpi/src/sys/MINDOLLUIN-OPT  amd64
    
mc> Now the 6-beta 1 panic:

Could you please let me know if the following patch works?  The
patch is untested, sorry -- I had to return the borrowed P6 test
box I was using and am still in the process of arranging for a new
one.

Regards,
Koshy
<jkoshy_at_freebsd.org>

Index: hwpmc_mod.c
===================================================================
RCS file: /cvs/FreeBSD/src/sys/dev/hwpmc/hwpmc_mod.c,v
retrieving revision 1.10
diff -u -u -r1.10 hwpmc_mod.c
--- hwpmc_mod.c 9 Jul 2005 17:29:36 -0000       1.10
+++ hwpmc_mod.c 27 Jul 2005 03:20:44 -0000
_at__at_ -668,7 +668,7 _at__at_
        td = curthread;
        *fullpath = "unknown";
        *freepath = NULL;
-       vn_lock(v, LK_EXCLUSIVE | LK_RETRY, td);
+       vn_lock(v, LK_CANRECURSE | LK_EXCLUSIVE | LK_RETRY, td);
        vn_fullpath(td, v, fullpath, freepath);
        VOP_UNLOCK(v, 0, td);
 }
Index: hwpmc_ppro.c
===================================================================
RCS file: /cvs/FreeBSD/src/sys/dev/hwpmc/hwpmc_ppro.c,v
retrieving revision 1.8
diff -u -u -r1.8 hwpmc_ppro.c
--- hwpmc_ppro.c        9 Jul 2005 17:29:36 -0000       1.8
+++ hwpmc_ppro.c        27 Jul 2005 03:20:45 -0000
_at__at_ -294,9 +294,9 _at__at_
 
 struct p6_cpu {
        struct pmc_cpu  pc_common;
-       uint32_t        pc_state;
        struct pmc_hw   *pc_hwpmcs[P6_NPMCS];
        struct pmc_hw   pc_p6pmcs[P6_NPMCS];
+       uint32_t        pc_state;
 };
 
 /*
Received on Wed Jul 27 2005 - 01:59:28 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:39 UTC