[PATCH] adds support for loongson2

View: New views
9 Messages — Rating Filter:   Alert me  

[PATCH] adds support for loongson2

by 陈杰 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
This patch adds oprofile userland support for loongson 2 processor.
The kernel part of oprofile support has already entered mainline (see
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=67b35e5d01aba7a83f2161b0c90acb08afa01e3e)

To try this, you may additionally need a 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),
since most linux system running on loongson platform will have a
64-bit kernel with a o32 userland,

== summary of the patch ==
 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

[loongson_support.patch]

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 =


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH] adds support for loongson2

by Maynard Johnson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chenjie wrote:

> Hi all,
> This patch adds oprofile userland support for loongson 2 processor.
> The kernel part of oprofile support has already entered mainline (see
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=67b35e5d01aba7a83f2161b0c90acb08afa01e3e)
>
> To try this, you may additionally need a 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),
> since most linux system running on loongson platform will have a
> 64-bit kernel with a o32 userland,
Thanks for your patch submission.  I have a few requests regarding your submission.

First, please add a Signed-off-by line to your patch submission, as described at
http://oprofile.sourceforge.net/contribute/.  Also, include a ChangeLog entry as
described in the <oprofile-src>/HACKING file.

Could you explain why you have loongson2 events and unit masks including godson2
events and unit masks instead of just putting the event/unit mask info directly
into the loongson2 files.

Lastly, 'make distcheck' fails with:
"could not open unit mask description file ../../../events/mips/godson2/unit_masks"
Please fix that error.

Thanks.
-Maynard

>
> == summary of the patch ==
>  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
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> oprofile-list mailing list
> oprofile-list@...
> https://lists.sourceforge.net/lists/listinfo/oprofile-list


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

[PATCH-V2] adds support for loongson2

by 陈杰 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The second version of patch adds oprofile userland support for ICT
loongson2 processor.
Signed-off-by Chen Jie <chenj@...>

== changes since patch v1 ==
* Fix 'make distcheck' fails
* Add new entry to ChangeLog

About godson2 and loongson2:
godson is the codename, and loongson is the trademark, using
"loongson" is perferred.
The relationship may like Nehalem and core i7.

Currently, the kernel identifies loongson2 as "mips/godson2"
(arch/mips/oprofile/op_model_loongson2.c), so I put the substantial
content in godson2 events, and let loongson2 events include it.

Thanks,
-Chen

[loongson_support_v2.patch]

diff -prauN oprofile.cvs/ChangeLog oprofile.commit/ChangeLog
--- oprofile.cvs/ChangeLog 2009-10-21 19:38:10.000000000 +0800
+++ oprofile.commit/ChangeLog 2009-10-21 20:40:29.000000000 +0800
@@ -349,5 +349,18 @@
 
  * m4/binutils.m4: Fix error in AC_CHECK_LIB action
 
+2009-10-21 Chen Jie <chenj@...>
+
+ * events/Makefile.am
+ * events/mips/godson2/events: New File
+ * events/mips/godson2/unit_masks: New File
+ * events/mips/loongson2/events: New File
+ * events/mips/loongson2/unit_masks: New File
+ * libop/op_cpu_type.c:
+ * libop/op_cpu_type.h:
+ * libop/op_events.c: Add default event for loongson2
+ * libutil/op_cpufreq.c: Add freq estimation for high performance mips processors
+ * utils/ophelp.c: Add support for ICT loongson2
+
 
 See ChangeLog-2008 for earlier changelogs.
diff -prauN oprofile.cvs/events/Makefile.am oprofile.commit/events/Makefile.am
--- oprofile.cvs/events/Makefile.am 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/events/Makefile.am 2009-10-21 20:24:41.000000000 +0800
@@ -53,6 +53,8 @@ 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 \
+ mips/godson2/events mips/godson2/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.commit/events/mips/godson2/events
--- oprofile.cvs/events/mips/godson2/events 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/godson2/events 2009-10-21 20:23:10.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.commit/events/mips/godson2/unit_masks
--- oprofile.cvs/events/mips/godson2/unit_masks 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/godson2/unit_masks 2009-10-21 20:23:10.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.commit/events/mips/loongson2/events
--- oprofile.cvs/events/mips/loongson2/events 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/loongson2/events 2009-10-21 20:23:10.000000000 +0800
@@ -0,0 +1 @@
+include:mips/godson2
diff -prauN oprofile.cvs/events/mips/loongson2/unit_masks oprofile.commit/events/mips/loongson2/unit_masks
--- oprofile.cvs/events/mips/loongson2/unit_masks 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/loongson2/unit_masks 2009-10-21 20:23:10.000000000 +0800
@@ -0,0 +1 @@
+include:mips/godson2
diff -prauN oprofile.cvs/libop/op_cpu_type.c oprofile.commit/libop/op_cpu_type.c
--- oprofile.cvs/libop/op_cpu_type.c 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/libop/op_cpu_type.c 2009-10-21 20:23:10.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.commit/libop/op_cpu_type.h
--- oprofile.cvs/libop/op_cpu_type.h 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/libop/op_cpu_type.h 2009-10-21 20:23:10.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.commit/libop/op_events.c
--- oprofile.cvs/libop/op_events.c 2009-06-05 23:26:39.000000000 +0800
+++ oprofile.commit/libop/op_events.c 2009-10-21 20:23:10.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.commit/libutil/op_cpufreq.c
--- oprofile.cvs/libutil/op_cpufreq.c 2003-11-04 12:26:45.000000000 +0800
+++ oprofile.commit/libutil/op_cpufreq.c 2009-10-21 20:23:10.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.commit/utils/ophelp.c
--- oprofile.cvs/utils/ophelp.c 2009-08-20 21:09:16.000000000 +0800
+++ oprofile.commit/utils/ophelp.c 2009-10-21 20:23:10.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 =


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH-V2] adds support for loongson2

by Maynard Johnson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chen Jie wrote:

> The second version of patch adds oprofile userland support for ICT
> loongson2 processor.
> Signed-off-by Chen Jie <chenj@...>
>
> == changes since patch v1 ==
> * Fix 'make distcheck' fails
> * Add new entry to ChangeLog
>
> About godson2 and loongson2:
> godson is the codename, and loongson is the trademark, using
> "loongson" is perferred.
> The relationship may like Nehalem and core i7.
>
> Currently, the kernel identifies loongson2 as "mips/godson2"
> (arch/mips/oprofile/op_model_loongson2.c), so I put the substantial
> content in godson2 events, and let loongson2 events include it.
This seems wrong.  The way you explain it, this is *not* analogous to Nehalem.  For the Nehalem-based processors, the oprofile kernel driver reports their cpu_type as the specific type; e.g. "i386/core_i7".  The event info is put into the events/i386/nehalem/events file, and then events/i386/core_i7/events file simply includes the nehalem events file.  If the kernel reports the processor as "mips/godson2", then all you need is the godson2 events file.  I don't see where the loongson2 events file would ever come into play.  Did you run 'make distcheck'?  This must pass before your patch can be accepted.

Regards,
-Maynard

>
> Thanks,
> -Chen
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH-V2] adds support for loongson2

by 陈杰 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/21 Maynard Johnson <maynardj@...>:

> Chen Jie wrote:
>> The second version of patch adds oprofile userland support for ICT
>> loongson2 processor.
>> Signed-off-by Chen Jie <chenj@...>
>>
>> == changes since patch v1 ==
>> * Fix 'make distcheck' fails
>> * Add new entry to ChangeLog
>>
>> About godson2 and loongson2:
>> godson is the codename, and loongson is the trademark, using
>> "loongson" is perferred.
>> The relationship may like Nehalem and core i7.
>>
>> Currently, the kernel identifies loongson2 as "mips/godson2"
>> (arch/mips/oprofile/op_model_loongson2.c), so I put the substantial
>> content in godson2 events, and let loongson2 events include it.
> This seems wrong.  The way you explain it, this is *not* analogous to Nehalem.  For the Nehalem-based processors, the oprofile kernel driver reports their cpu_type as the specific type; e.g. "i386/core_i7".  The event info is put into the events/i386/nehalem/events file, and then events/i386/core_i7/events file simply includes the nehalem events file.  If the kernel reports the processor as "mips/godson2", then all you need is the godson2 events file.  I don't see where the loongson2 events file would ever come into play.  Did you run 'make distcheck'?  This must pass before your patch can be accepted.

I've ran 'make distcheck', no error reports.
Currently only a few parts in kernel source reference "loongson" as
"godson", these will be changed to "loongson" in the future.

>
> Regards,
> -Maynard
>
>>
>> Thanks,
>> -Chen
>>
>
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH-V2] adds support for loongson2

by John Levon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 21, 2009 at 10:23:14PM +0800, Chen Jie wrote:

> I've ran 'make distcheck', no error reports.
> Currently only a few parts in kernel source reference "loongson" as
> "godson", these will be changed to "loongson" in the future.

Then you need to finish fixing the kernel before trying to work around
it in userspace, unless you can convince us otherwise...

regards
john

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH-V2] adds support for loongson2

by 陈杰 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John, Maynard:
Thanks for your reviews and suggestions, a patch fixing the kernel
(rename cpu_type from godson2 to loongson2) is submitted (see
http://www.linux-mips.org/archives/linux-mips/2009-10/msg00293.html)

I'll submit another version of this patch removing the godson2/events
once the kernel patch is applied.

Regards,
- Chen

2009/10/21 John Levon <levon@...>:

> On Wed, Oct 21, 2009 at 10:23:14PM +0800, Chen Jie wrote:
>
>> I've ran 'make distcheck', no error reports.
>> Currently only a few parts in kernel source reference "loongson" as
>> "godson", these will be changed to "loongson" in the future.
>
> Then you need to finish fixing the kernel before trying to work around
> it in userspace, unless you can convince us otherwise...
>
> regards
> john
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

[PATCH-V3] adds support for loongson2

by 陈杰 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adds oprofile userland support for ICT loongson2 processor. 
Signed-off-by Chen Jie <chenj@...>

This is the third version, changes since last version: 
 * unify the cpu's identifier, rename from "godson2" to "loongson2" (This needs kernel support: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=55f4e1d4fe88f16f773ba5bb31ce8c1ae63724af)

The 'make distcheck' test is ok.


Regards,
- Chenj

[loongson_support_v3.patch]

diff -prauN oprofile.cvs/ChangeLog oprofile.commit/ChangeLog
--- oprofile.cvs/ChangeLog 2009-11-03 09:35:26.000000000 +0800
+++ oprofile.commit/ChangeLog 2009-11-03 09:53:12.000000000 +0800
@@ -393,5 +393,16 @@
 
  * m4/binutils.m4: Fix error in AC_CHECK_LIB action
 
+2009-10-21 Chen Jie <chenj@...>
+
+ * events/Makefile.am
+ * events/mips/loongson2/events: New File
+ * events/mips/loongson2/unit_masks: New File
+ * libop/op_cpu_type.c:
+ * libop/op_cpu_type.h:
+ * libop/op_events.c: Add default event for loongson2
+ * libutil/op_cpufreq.c: Add freq estimation for high performance mips processors
+ * utils/ophelp.c: Add support for ICT loongson2
+
 
 See ChangeLog-2008 for earlier changelogs.
diff -prauN oprofile.cvs/events/Makefile.am oprofile.commit/events/Makefile.am
--- oprofile.cvs/events/Makefile.am 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/events/Makefile.am 2009-11-03 09:53:27.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/loongson2/events oprofile.commit/events/mips/loongson2/events
--- oprofile.cvs/events/mips/loongson2/events 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/loongson2/events 2009-11-03 09:52:26.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/loongson2/unit_masks oprofile.commit/events/mips/loongson2/unit_masks
--- oprofile.cvs/events/mips/loongson2/unit_masks 1970-01-01 08:00:00.000000000 +0800
+++ oprofile.commit/events/mips/loongson2/unit_masks 2009-11-03 09:52:26.000000000 +0800
@@ -0,0 +1,4 @@
+# loongson2 possible unit masks
+#
+name:zero type:mandatory default:0x0
+ 0x0 No unit mask
diff -prauN oprofile.cvs/libop/op_cpu_type.c oprofile.commit/libop/op_cpu_type.c
--- oprofile.cvs/libop/op_cpu_type.c 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/libop/op_cpu_type.c 2009-11-03 09:53:00.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/loongson2", 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.commit/libop/op_cpu_type.h
--- oprofile.cvs/libop/op_cpu_type.h 2009-05-07 22:20:16.000000000 +0800
+++ oprofile.commit/libop/op_cpu_type.h 2009-11-03 09:52:26.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.commit/libop/op_events.c
--- oprofile.cvs/libop/op_events.c 2009-06-05 23:26:39.000000000 +0800
+++ oprofile.commit/libop/op_events.c 2009-11-03 09:52:26.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.commit/libutil/op_cpufreq.c
--- oprofile.cvs/libutil/op_cpufreq.c 2003-11-04 12:26:45.000000000 +0800
+++ oprofile.commit/libutil/op_cpufreq.c 2009-11-03 09:52:26.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.commit/utils/ophelp.c
--- oprofile.cvs/utils/ophelp.c 2009-08-20 21:09:16.000000000 +0800
+++ oprofile.commit/utils/ophelp.c 2009-11-03 09:52:26.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 =


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list

Re: [PATCH-V3] adds support for loongson2

by Maynard Johnson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chen Jie wrote:

> Adds oprofile userland support for ICT loongson2 processor.
> Signed-off-by Chen Jie <chenj@...>
>
> This is the third version, changes since last version:
>  * unify the cpu's identifier, rename from "godson2" to "loongson2" (This
> needs kernel support:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=55f4e1d4fe88f16f773ba5bb31ce8c1ae63724af
> )
>
> The 'make distcheck' test is ok.
Patch committed.  Thanks.

-Maynard
>
>
> Regards,
> - Chenj
>
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
oprofile-list mailing list
oprofile-list@...
https://lists.sourceforge.net/lists/listinfo/oprofile-list