From: Chenjie <ch...@le...> - 2009-10-11 10:00:36
|
Hi all, loongson2 is a MIPSIII compatible high performance CPU. The kernel part of Oprofile has entered mainline, and is supposed to delivered with linux-2.6.32 (see http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=67b35e5d01aba7a83f2161b0c90acb08afa01e3e). I also mention a related kernel part patch, which fix broken o32 lookup_dcookie syscall with a 64-bit kernel. (see http://www.linux-mips.org/archives/linux-mips/2009-10/msg00089.html Here is the userland part patch: == change summary == events/Makefile.am | 1 + events/mips/godson2/events | 34 ++++++++++++++++++++++++++++++++++ events/mips/godson2/unit_masks | 4 ++++ events/mips/loongson2/events | 1 + events/mips/loongson2/unit_masks | 1 + libop/op_cpu_type.c | 1 + libop/op_cpu_type.h | 1 + libop/op_events.c | 1 + libutil/op_cpufreq.c | 5 +++++ utils/ophelp.c | 5 +++++ 10 files changed, 54 insertions(+), 0 deletions(-) create mode 100644 events/mips/godson2/events create mode 100644 events/mips/godson2/unit_masks create mode 100644 events/mips/loongson2/events create mode 100644 events/mips/loongson2/unit_masks Signed-off-by: Chen Jie <ch...@le...> --- diff -prauN oprofile.cvs/events/Makefile.am oprofile/events/Makefile.am --- oprofile.cvs/events/Makefile.am 2009-05-07 22:20:16.000000000 +0800 +++ oprofile/events/Makefile.am 2009-10-11 17:35:44.000000000 +0800 @@ -53,6 +53,7 @@ event_files = \ mips/r12000/events mips/r12000/unit_masks \ mips/vr5432/events mips/vr5432/unit_masks \ mips/vr5500/events mips/vr5500/unit_masks \ + mips/loongson2/events mips/loongson2/unit_masks \ ppc/7450/events ppc/7450/unit_masks \ ppc/e500/events ppc/e500/unit_masks \ ppc/e500v2/events ppc/e500v2/unit_masks \ diff -prauN oprofile.cvs/events/mips/godson2/events oprofile/events/mips/godson2/events --- oprofile.cvs/events/mips/godson2/events 1970-01-01 08:00:00.000000000 +0800 +++ oprofile/events/mips/godson2/events 2009-10-11 17:35:44.000000000 +0800 @@ -0,0 +1,34 @@ +# loongson2 Events +# +event:0x00 counters:0 um:zero minimum:10000 name:CPU_CLK_UNHALTED : Cycles outside of haltstate +event:0x01 counters:0 um:zero minimum:5000 name:BRANCH_INSTRUCTIONS : Branch instructions +event:0x02 counters:0 um:zero minimum:400 name:JUMP_INSTRUCTIONS : JR instructions +event:0x03 counters:0 um:zero minimum:500 name:JR31_INSTRUCTIONS : JR(rs=31) instructions +event:0x04 counters:0 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:0x05 counters:0 um:zero minimum:500 name:ALU1_ISSUED : ALU1 operation issued +event:0x06 counters:0 um:zero minimum:8000 name:MEM_ISSUED : Memory read/write issued +event:0x07 counters:0 um:zero minimum:300 name:FALU1_ISSUED : Float ALU1 operation issued +event:0x08 counters:0 um:zero minimum:200 name:BHT_BRANCH_INSTRUCTIONS : BHT prediction instructions +event:0x09 counters:0 um:zero minimum:200 name:MEM_READ : Read from primary memory +event:0x0a counters:0 um:zero minimum:300 name:FQUEUE_FULL : Fix queue full +event:0x0b counters:0 um:zero minimum:300 name:ROQ_FULL : Reorder queue full +event:0x0c counters:0 um:zero minimum:300 name:CP0_QUEUE_FULL : CP0 queue full +event:0x0d counters:0 um:zero minimum:300 name:TLB_REFILL : TLB refill exception +event:0x0e counters:0 um:zero minimum:5 name:EXCEPTION : Exceptions +event:0x0f counters:0 um:zero minimum:300 name:INTERNAL_EXCEPTION : Internal exceptions +event:0x10 counters:1 um:zero minimum:5000 name:INSTRUCTION_COMMITTED : Instruction committed +event:0x11 counters:1 um:zero minimum:500 name:BRANCHES_MISPREDICTED : Branch mispredicted +event:0x12 counters:1 um:zero minimum:200 name:JR_MISPREDICTED : JR mispredicted +event:0x13 counters:1 um:zero minimum:200 name:JR31_MISPREDICTED : JR31 mispredicted +event:0x14 counters:1 um:zero minimum:500 name:DCACHE_MISSES : Data cache misses +event:0x15 counters:1 um:zero minimum:500 name:ALU2_ISSUED : ALU2 operation issued +event:0x16 counters:1 um:zero minimum:500 name:FALU2_ISSUED : FALU2 operation issued +event:0x17 counters:1 um:zero minimum:500 name:UNCACHED_ACCESS : Uncached accesses +event:0x18 counters:1 um:zero minimum:500 name:BHT_MISPREDICTED : Branch history table mispredicted +event:0x19 counters:1 um:zero minimum:5000 name:MEM_WRITE : Write to memory +event:0x1a counters:1 um:zero minimum:500 name:FTQ_FULL : Float queue full +event:0x1b counters:1 um:zero minimum:500 name:BRANCH_QUEUE_FULL : Branch queue full +event:0x1c counters:1 um:zero minimum:500 name:ITLB_MISSES : Instruction TLB misses +event:0x1d counters:1 um:zero minimum:500 name:TOTAL_EXCEPTIONS : Total exceptions +event:0x1e counters:1 um:zero minimum:500 name:LOAD_SPECULATION_MISSES : Load speculation misses +event:0x1f counters:1 um:zero minimum:500 name:CP0Q_FORWARD_VALID : CP0 queue forward valid diff -prauN oprofile.cvs/events/mips/godson2/unit_masks oprofile/events/mips/godson2/unit_masks --- oprofile.cvs/events/mips/godson2/unit_masks 1970-01-01 08:00:00.000000000 +0800 +++ oprofile/events/mips/godson2/unit_masks 2009-10-11 17:35:44.000000000 +0800 @@ -0,0 +1,4 @@ +# loongson2 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff -prauN oprofile.cvs/events/mips/loongson2/events oprofile/events/mips/loongson2/events --- oprofile.cvs/events/mips/loongson2/events 1970-01-01 08:00:00.000000000 +0800 +++ oprofile/events/mips/loongson2/events 2009-10-11 17:35:44.000000000 +0800 @@ -0,0 +1 @@ +include:mips/godson2 diff -prauN oprofile.cvs/events/mips/loongson2/unit_masks oprofile/events/mips/loongson2/unit_masks --- oprofile.cvs/events/mips/loongson2/unit_masks 1970-01-01 08:00:00.000000000 +0800 +++ oprofile/events/mips/loongson2/unit_masks 2009-10-11 17:35:44.000000000 +0800 @@ -0,0 +1 @@ +include:mips/godson2 diff -prauN oprofile.cvs/libop/op_cpu_type.c oprofile/libop/op_cpu_type.c --- oprofile.cvs/libop/op_cpu_type.c 2009-05-07 22:20:16.000000000 +0800 +++ oprofile/libop/op_cpu_type.c 2009-10-11 17:35:44.000000000 +0800 @@ -82,6 +82,7 @@ static struct cpu_descr const cpu_descrs { "ppc64 compat version 1", "ppc64/ibm-compat-v1", CPU_PPC64_IBM_COMPAT_V1, 4 }, { "Intel Core/i7", "i386/core_i7", CPU_CORE_I7, 4 }, { "Intel Atom", "i386/atom", CPU_ATOM, 2 }, + { "Loongson2", "mips/godson2", CPU_MIPS_LOONGSON2, 2 }, }; static size_t const nr_cpu_descrs = sizeof(cpu_descrs) / sizeof(struct cpu_descr); diff -prauN oprofile.cvs/libop/op_cpu_type.h oprofile/libop/op_cpu_type.h --- oprofile.cvs/libop/op_cpu_type.h 2009-05-07 22:20:16.000000000 +0800 +++ oprofile/libop/op_cpu_type.h 2009-10-11 17:35:44.000000000 +0800 @@ -79,6 +79,7 @@ typedef enum { CPU_PPC64_IBM_COMPAT_V1, /**< IBM PPC64 processor compat mode version 1 */ CPU_CORE_I7, /* Intel Core i7, Nehalem */ CPU_ATOM, /* First generation Intel Atom */ + CPU_MIPS_LOONGSON2, /* < loongson2 family */ MAX_CPU_TYPE } op_cpu; diff -prauN oprofile.cvs/libop/op_events.c oprofile/libop/op_events.c --- oprofile.cvs/libop/op_events.c 2009-06-05 23:26:39.000000000 +0800 +++ oprofile/libop/op_events.c 2009-10-11 17:36:35.000000000 +0800 @@ -970,6 +970,7 @@ void op_default_event(op_cpu cpu_type, s case CPU_FAMILY11H: case CPU_ATOM: case CPU_CORE_I7: + case CPU_MIPS_LOONGSON2: descr->name = "CPU_CLK_UNHALTED"; break; diff -prauN oprofile.cvs/libutil/op_cpufreq.c oprofile/libutil/op_cpufreq.c --- oprofile.cvs/libutil/op_cpufreq.c 2003-11-04 12:26:45.000000000 +0800 +++ oprofile/libutil/op_cpufreq.c 2009-10-11 17:35:44.000000000 +0800 @@ -51,6 +51,11 @@ double op_cpu_frequency(void) fval = uval / 1E6; break; } + /* mips including loongson2 */ + if (sscanf(line, "BogoMIPS : %lu", &uval) == 1) { + fval = uval * 3 / 2; + break; + } /* s390 doesn't provide cpu freq, checked up to 2.6-test4 */ free(line); diff -prauN oprofile.cvs/utils/ophelp.c oprofile/utils/ophelp.c --- oprofile.cvs/utils/ophelp.c 2009-08-20 21:09:16.000000000 +0800 +++ oprofile/utils/ophelp.c 2009-10-11 17:35:44.000000000 +0800 @@ -617,6 +617,11 @@ int main(int argc, char const * argv[]) "http://www.necel.com/nesdis/image/U16677EJ3V0UM00.pdf\n"; break; + case CPU_MIPS_LOONGSON2: + event_doc = + "See loongson2 RISC Microprocessor Family Reference Manual\n"; + break; + case CPU_PPC_E500: case CPU_PPC_E500_2: event_doc = |