Hi,

I did a patch to fix this problem. It is attached.

I changed the makefile so that it looks for the file
"/proc/sys/kernel/perf_counter_paranoid", if the file exists then it
adds the flag OLD_KERNEL_PERF_PROC_FILE to CFLAGS.
Then, I changed the file pfmlib_perf_event.c so that it checks whether
OLD_KERNEL_PERF_PROC_FILE is define and sets PERF_PROC_FILE properly
according to the kernel version.

On Wed, Jul 6, 2011 at 5:28 PM, Vince Weaver <vweav...@eecs.utk.edu> wrote:
> On Wed, 6 Jul 2011, Leonardo Piga wrote:
>
>> I'm just curious to know why you handle the "old" kernel version
>> (2.6.31) in pfm_perf_detect function on pfmlib_perf_event_pmu.c file,
>> but doesn't on pfmlib_perf_event.c.
>
> Most people are using kernels newer than 2.6.31, so you are probably the
> first person to notice this problem. The change to make that file the
> "official" way to detect perf_event support was recent, so this is
> probably a recent breakage.
>
> I'm sure the libpfm4 maintainer will be glad to fix things properly, but I
> think currently he's on vacation so it might be a while before that
> happens.
>
> Vince
>



-- 
Leonardo
diff -crB libpfm4/lib/Makefile libpfm4_old_kernel_fix/lib/Makefile
*** libpfm4/lib/Makefile	2011-07-28 14:52:33.533522132 -0300
--- libpfm4_old_kernel_fix/lib/Makefile	2011-07-28 14:42:39.025522577 -0300
***************
*** 31,36 ****
--- 31,42 ----
  
  ifeq ($(SYS),Linux)
  SRCS += pfmlib_perf_event_pmu.c pfmlib_perf_event.c
+ PERF_PROC_FILE := $(shell if [ -e "/proc/sys/kernel/perf_counter_paranoid" ]; then echo "Old"; else "New"; fi)
+ 
+ ifeq ($(PERF_PROC_FILE),Old)
+ CFLAGS+=-DOLD_KERNEL_PERF_PROC_FILE
+ endif
+ 
  endif
  
  CFLAGS+=-D_REENTRANT -I.
diff -crB libpfm4/lib/pfmlib_perf_event.c libpfm4_old_kernel_fix/lib/pfmlib_perf_event.c
*** libpfm4/lib/pfmlib_perf_event.c	2011-07-28 14:52:33.561519406 -0300
--- libpfm4_old_kernel_fix/lib/pfmlib_perf_event.c	2011-07-28 14:25:33.098022294 -0300
***************
*** 30,37 ****
  #include "pfmlib_priv.h"
  #include "pfmlib_perf_event_priv.h"
  
  #define PERF_PROC_FILE "/proc/sys/kernel/perf_event_paranoid"
! 
  /*
   * contains ONLY attributes related to PMU features
   */
--- 30,40 ----
  #include "pfmlib_priv.h"
  #include "pfmlib_perf_event_priv.h"
  
+ #ifdef OLD_KERNEL_PERF_PROC_FILE
+ #define PERF_PROC_FILE "/proc/sys/kernel/perf_counter_paranoid"
+ #else
  #define PERF_PROC_FILE "/proc/sys/kernel/perf_event_paranoid"
! #endif
  /*
   * contains ONLY attributes related to PMU features
   */
------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to