Re: [perfmon2] [PATCH] libpfm patch to support building on newer distos + optimization for POWER5
Status: Beta
Brought to you by:
seranian
From: stephane e. <er...@go...> - 2007-12-21 21:18:44
|
Corey, On Dec 22, 2007 9:07 PM, Corey Ashford <cja...@us...> wrote: > Hello, > > In newer distros (e.g. RHEL 5.1), there is no longer a user-accessible > include file for the processor register definitions (specifically the > PMU registers). The include files used to be visible but many of the > definitions in these files where hidden by a "#ifdef __KERNEL__". In > the HEAD version of pfmlib_gen_powerpc.c, I had cheated and did a: > > #define __KENEL__ > #include <asm-powerpc/reg.h> > #undef __KERNEL__ > > I did not catch that but that is a no,no. YOU need to duplicate kernel headers if you need some of their definitions. Unless the registers are accessible from user space, I don't think we need the following macros in the user header file: > + > +/* Macros for setting and retrieving special purpose registers */ > +#define mfmsr() ({unsigned long rval; \ > + asm volatile("mfmsr %0" : "=r" (rval)); rval;}) > +#ifdef __powerpc64__ > +#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \ > + : : "r" (v)) > +#define mtmsrd(v) __mtmsrd((v), 0) > +#define mtmsr(v) mtmsrd(v) > +#else > +#define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v)) > +#endif > + > +#define mfspr(rn) ({unsigned long rval; \ > + asm volatile("mfspr %0," __stringify(rn) \ > + : "=r" (rval)); rval;}) > +#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)) > + > +#define mftb() ({unsigned long rval; \ > + asm volatile("mftb %0" : "=r" (rval)); rval;}) > +#define mftbl() ({unsigned long rval; \ > + asm volatile("mftbl %0" : "=r" (rval)); rval;}) > + > +#define mttbl(v) asm volatile("mttbl %0":: "r"(v)) > +#define mttbu(v) asm volatile("mttbu %0":: "r"(v)) > + > +#ifdef __powerpc64__ > +#define mfsrin(v) ({unsigned int rval; \ > + asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \ > + rval;}) > +#endif > + > +#define proc_trap() asm volatile("trap") > + > +#define __get_SP() ({unsigned long sp; \ > + asm volatile("mr %0,1": "=r" (sp)); sp;}) > + > +#endif /* _POWER_REG_H */ > > |