Hi Dan,
Glad to hear from you! I added Solaris support to x86info, built successfully,
and the patch is attached(against the lasted x86 git repo) for your information.
But the lack of MSR access make it almost useless. Say:
[js226...@git x86info]$ ./x86info
x86info v1.24. Dave Jones 2001-2009
Feedback to <[email protected]>.
Found 4 CPUs
--------------------------------------------------------------------------
CPU #1
EFamily: 0 EModel: 0 Family: 6 Model: 15 Stepping: 6
CPU Model: Core 2 Duo
Processor name string: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz
Type: 0 (Original OEM) Brand: 0 (Unsupported)
Number of cores per physical package=2
Number of logical processors per socket=2
Number of logical processors per core=1
APIC ID: 0x0 Package: 0 Core: 0 SMT ID 0
--------------------------------------------------------------------------
CPU #2
EFamily: 0 EModel: 0 Family: 6 Model: 15 Stepping: 6
CPU Model: Core 2 Duo
Processor name string: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz
Type: 0 (Original OEM) Brand: 0 (Unsupported)
Number of cores per physical package=2
Number of logical processors per socket=2
Number of logical processors per core=1
APIC ID: 0x6 Package: 0 Core: 1 SMT ID 0
--------------------------------------------------------------------------
CPU #3
EFamily: 0 EModel: 0 Family: 6 Model: 15 Stepping: 6
CPU Model: Core 2 Duo
Processor name string: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz
Type: 0 (Original OEM) Brand: 0 (Unsupported)
Number of cores per physical package=2
Number of logical processors per socket=2
Number of logical processors per core=1
APIC ID: 0x1 Package: 0 Core: 0 SMT ID 1
--------------------------------------------------------------------------
CPU #4
EFamily: 0 EModel: 0 Family: 6 Model: 15 Stepping: 6
CPU Model: Core 2 Duo
Processor name string: Intel(R) Xeon(R) CPU 5150 @ 2.66GHz
Type: 0 (Original OEM) Brand: 0 (Unsupported)
Number of cores per physical package=2
Number of logical processors per socket=2
Number of logical processors per core=1
APIC ID: 0x7 Package: 0 Core: 1 SMT ID 1
--------------------------------------------------------------------------
[js226...@git x86info]$ sudo ./x86info
x86info v1.24. Dave Jones 2001-2009
Feedback to <[email protected]>.
readEntry: Bad address
It seems that /dev/mem doesn't support lseek + read accessing model. And
furthermore, I don't know how to access MSR registers from userspace. If
we have no such facilities in kernel, there are 2 choices:
a) Disable all MSR accessing codes in x86info, which unfortunately will
remove some features;
b) implement a msr driver, say /dev/cpu/self/msr, to serve MSR read/write
from userspace.
Choice b sounds better, but I have read the linux msr driver before I join
SMI. So I'm not able to write this driver due to license issue;-(
Is your working directory accessible in SWAN?
--
Thanks,
Jike Song, SW Engineer
Sun Microsystems China(ERI)
Tel: (86-10)62673147
Dan Mick wrote:
Jike Song wrote:
Hi,
I'm porting x86info to opensolaris. Among many options, x86info try to
access MSR registers(MTRR, TSC, etc.), but x86 CPU allows MSR access
only in RING 0 privilege. In order to allow access from userspace,
there have to be a msr driver in kernel to handle it.
Does opensolaris has such a driver? It should be easy to implement from
technical perspective.
It's not included, but I did exactly the same thing not long ago. You're
welcome to the code if you want it, but it would take some work to actually
include with Solaris (and I'm not sure it would be a great idea to have it there
anyway).
>From 42ea8c4cc3e20e9f823a948bf18b63c8ef766bd3 Mon Sep 17 00:00:00 2001
From: Jike Song <[email protected]>
Date: Tue, 7 Apr 2009 14:58:56 +0800
Subject: [PATCH] Add Solaris support.
Signed-off-by: Jike Song <[email protected]>
---
cpuid.c | 6 ++++++
lsmsr.c | 1 +
x86info.h | 14 ++++++++++++++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/cpuid.c b/cpuid.c
index a17699c..8ab68ac 100644
--- a/cpuid.c
+++ b/cpuid.c
@@ -44,7 +44,9 @@ static void native_cpuid(unsigned int cpunr, unsigned long
long idx,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
+#if !defined(__sun__)
cpu_set_t set;
+#endif /* __sun__ */
unsigned int a = 0, b = 0, c = 0, d = 0;
if (eax != NULL)
@@ -56,11 +58,15 @@ static void native_cpuid(unsigned int cpunr, unsigned long
long idx,
if (edx != NULL)
d = *edx;
+#if defined(__sun__)
+ processor_bind(P_PID, getpid(), (processorid_t)cpunr, NULL);
+#else /* !__sun__ */
if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
CPU_ZERO(&set);
CPU_SET(cpunr, &set);
sched_setaffinity(getpid(), sizeof(set), &set);
}
+#endif /* __sun__ */
asm("cpuid"
: "=a" (a),
diff --git a/lsmsr.c b/lsmsr.c
index 98ffeef..595c434 100644
--- a/lsmsr.c
+++ b/lsmsr.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/x86info.h b/x86info.h
index c286b47..d5a6c31 100644
--- a/x86info.h
+++ b/x86info.h
@@ -179,6 +179,19 @@ extern int user_is_root;
#include <sched.h>
#include <sys/types.h>
#include <unistd.h>
+
+#if defined(__sun__)
+#include <sys/pset.h>
+#include <sys/processor.h>
+#include <sys/procset.h>
+static inline void bind_cpu(struct cpudata *cpu)
+{
+ if (processor_bind(P_PID, getpid(), (processorid_t)cpu->number, NULL)
== -1)
+ fprintf(stderr, "processor_find() failed\n");
+}
+
+#else /* !__sun__ */
+
static inline void bind_cpu(struct cpudata *cpu)
{
cpu_set_t set;
@@ -189,5 +202,6 @@ static inline void bind_cpu(struct cpudata *cpu)
sched_setaffinity(getpid(), sizeof(set), &set);
}
}
+#endif /* __sun__*/
#endif /* _X86INFO_H */
--
1.6.2
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code