public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "Gui,Jian" <guij@cn.ibm.com>
To: "Martin Hunt" <hunt@redhat.com>,
	        "SystemTAP" <systemtap@sources.redhat.com>
Subject: [patch] ppc64 patch for new benchmark framework
Date: Fri, 24 Mar 2006 10:38:00 -0000	[thread overview]
Message-ID: <001e01c64f2f$05dc51e0$9d85b509@IBM528414E28E4> (raw)
In-Reply-To: <1142416360.27792.8.camel@dragon>

[-- Attachment #1: Type: text/plain, Size: 3400 bytes --]

Hi, Martin

This patch is to fix three maybe bugs of the new benchmark framework
on ppc64.

This framework works fine on i686 but fails on my ppc64/2.6.9-34.EL
for the following reasons:
1) The function kallsyms_lookup_name("sys_getuid") always return 0
  on ppc64 and we have to use kallsysms_lookup_name(".sys_getuid")
  to get the function entry address instead;
2) The content of /proc/cpuinfo on ppc64 is different from on i686.
  It is like:
  processor       : 0
  cpu             : POWER5 (gr)
  clock           : 1502.496000MHz
  revision        : 2.2
  There is no "model name" or "physical id" information, thus current
  print_header always failed;
3) The assignment of (.addr = "sys_getuid") will trigger a compilation
  error like: "warning: initialization from incompatible pointer type"
  (I'm using gcc-3.4.5-2 + glibc-2.3.4-2.19)

This patch works on ppc64/2.6.9-34.EL and i686/2.6.15.6 and should
apply to snapshot-20060318.

Could you give some comments?  Thanks.

Gui,Jian

diff -Nur src-20060318/runtime/bench2/bench.rb 
src-modified/runtime/bench2/bench.rb
--- src-20060318/runtime/bench2/bench.rb        2006-03-24 
09:03:53.000000000 -0500
+++ src-modified/runtime/bench2/bench.rb        2006-03-24 
09:06:26.000000000 -0500
@@ -149,9 +149,14 @@
 MODULE_AUTHOR(\"automatically generated by bench2/run_bench\");\n\n"
        f << "static int inst_sys_getuid (struct kprobe *p, struct pt_regs 
*regs) {\n"
        f << @code
-       f << "\n  return 0;\n}
-static struct kprobe kp[] = {\n  {\n    .addr = \"sys_getuid\",
-    .pre_handler = inst_sys_getuid\n  }\n};\n
+       f << "\n  return 0;\n}\n"
+       f << " static struct kprobe kp[] = {\n  {\n"
+       f << "#if defined __powerpc64__ \n"
+       f << "  .addr = (void *)\".sys_getuid\",\n"
+       f << "#else \n"
+       f << "  .addr = \"sys_getuid\", \n"
+       f << "#endif\n"
+       f << ".pre_handler = inst_sys_getuid\n  }\n};\n
 #define NUM_KPROBES 1\n
 int probe_start(void)\n{\n  return _stp_register_kprobes (kp, 
NUM_KPROBES);\n}\n
 void probe_exit (void)\n{\n  _stp_unregister_kprobes (kp, NUM_KPROBES); 
\n}\n"
@@ -185,8 +190,17 @@
     else
       @@num_threads = [1]
     end
-    physical_cpus=`grep "physical id" 
/proc/cpuinfo`.split("\n").uniq.length
-    model=`grep "model name" /proc/cpuinfo`.match(/(model 
name\t: )([^\n]*)/)[2]
+    arch=`uname -m`.strip
+    if (arch.match(/ppc64/))
+       cpu=`grep "cpu" /proc/cpuinfo`.match(/(cpu\t\t: )([^\n]*)/)[2]
+       clock=`grep "clock" /proc/cpuinfo`.match(/(clock\t\t: )([^\n]*)/)[2]
+       revision=`grep "revision" 
/proc/cpuinfo`.match(/(revision\t: )([^\n]*)/)[2]
+       cpuinfo=cpu + " " + clock + " revision: " + revision
+    else
+               physical_cpus=`grep "physical id" 
/proc/cpuinfo`.split("\n").uniq.length
+               model=`grep "model name" /proc/cpuinfo`.match(/(model 
name\t: )([^\n]*)/)[2]
+       cpuinfo="(#{physical_cpus} physical) #{model}"
+    end
     puts "SystemTap BENCH2 \t" + `date`
     puts "kernel: " + `uname -r`.strip + " " + `uname -m`.strip
     begin
@@ -195,11 +209,7 @@
     end

     puts `uname -n`.strip + ": " + `uptime`
-    if nproc > 1
-      puts "processors: #{nproc} (#{physical_cpus} physical) #{model}"
-    else
-      puts "processors: #{nproc} #{model}"
-    end
+    puts "processors: #{nproc} #{cpuinfo}"

     begin
       mem=IO.read("/proc/meminfo").split("\n") 

[-- Attachment #2: bench2.ppc64.patch --]
[-- Type: application/octet-stream, Size: 2326 bytes --]

diff -Nur src-20060318/runtime/bench2/bench.rb src-modified/runtime/bench2/bench.rb
--- src-20060318/runtime/bench2/bench.rb	2006-03-24 09:03:53.000000000 -0500
+++ src-modified/runtime/bench2/bench.rb	2006-03-24 09:06:26.000000000 -0500
@@ -149,9 +149,14 @@
 MODULE_AUTHOR(\"automatically generated by bench2/run_bench\");\n\n"
 	f << "static int inst_sys_getuid (struct kprobe *p, struct pt_regs *regs) {\n"
 	f << @code
-	f << "\n  return 0;\n}
-static struct kprobe kp[] = {\n  {\n    .addr = \"sys_getuid\",
-    .pre_handler = inst_sys_getuid\n  }\n};\n
+	f << "\n  return 0;\n}\n"
+	f << " static struct kprobe kp[] = {\n  {\n"
+	f << "#if defined __powerpc64__ \n"
+	f << "  .addr = (void *)\".sys_getuid\",\n"
+	f << "#else \n"
+	f << "  .addr = \"sys_getuid\", \n"
+	f << "#endif\n"
+	f << ".pre_handler = inst_sys_getuid\n  }\n};\n
 #define NUM_KPROBES 1\n
 int probe_start(void)\n{\n  return _stp_register_kprobes (kp, NUM_KPROBES);\n}\n
 void probe_exit (void)\n{\n  _stp_unregister_kprobes (kp, NUM_KPROBES); \n}\n"
@@ -185,8 +190,17 @@
     else
       @@num_threads = [1]
     end
-    physical_cpus=`grep "physical id" /proc/cpuinfo`.split("\n").uniq.length
-    model=`grep "model name" /proc/cpuinfo`.match(/(model name\t: )([^\n]*)/)[2]
+    arch=`uname -m`.strip
+    if (arch.match(/ppc64/))
+	cpu=`grep "cpu" /proc/cpuinfo`.match(/(cpu\t\t: )([^\n]*)/)[2]
+	clock=`grep "clock" /proc/cpuinfo`.match(/(clock\t\t: )([^\n]*)/)[2]
+	revision=`grep "revision" /proc/cpuinfo`.match(/(revision\t: )([^\n]*)/)[2]
+	cpuinfo=cpu + " " + clock + " revision: " + revision
+    else
+       	physical_cpus=`grep "physical id" /proc/cpuinfo`.split("\n").uniq.length
+       	model=`grep "model name" /proc/cpuinfo`.match(/(model name\t: )([^\n]*)/)[2]
+	cpuinfo="(#{physical_cpus} physical) #{model}"
+    end	
     puts "SystemTap BENCH2 \t" + `date`
     puts "kernel: " + `uname -r`.strip + " " + `uname -m`.strip
     begin
@@ -195,11 +209,7 @@
     end
 
     puts `uname -n`.strip + ": " + `uptime`
-    if nproc > 1
-      puts "processors: #{nproc} (#{physical_cpus} physical) #{model}"
-    else
-      puts "processors: #{nproc} #{model}"
-    end
+    puts "processors: #{nproc} #{cpuinfo}"
 
     begin
       mem=IO.read("/proc/meminfo").split("\n")

  reply	other threads:[~2006-03-24 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-15  9:52 Martin Hunt
2006-03-24 10:38 ` Gui,Jian [this message]
2006-03-24 18:47   ` [patch] ppc64 patch for " Martin Hunt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001e01c64f2f$05dc51e0$9d85b509@IBM528414E28E4' \
    --to=guij@cn.ibm.com \
    --cc=hunt@redhat.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).