* Re: [Powertop] [PATCH 2/8] Use MSR Lib MSR functions
@ 2013-04-13 10:43 Sergey Senozhatsky
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2013-04-13 10:43 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 2149 bytes --]
On (04/12/13 08:47), Srinivas Pandruvada wrote:
> Date: Fri, 12 Apr 2013 08:47:02 -0700
> From: Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
> To: powertop(a)lists.01.org
> Subject: [Powertop] [PATCH 2/8] Use MSR Lib MSR functions
> X-Mailer: git-send-email 1.7.11.7
>
> MSR read is implemented in lib.c. Use this API instead.
>
oh, not again... I missed Cc list. sorry!
resending.
please merge with the master. this function is a bit ahead since
commit 4d636301f641855a0bf059928c7a395cecc272b1
Author: Jani Nikula <jani.nikula intel.com>
Date: Thu Feb 21 11:27:34 2013 +0200
-ss
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
> ---
> src/cpu/intel_cpus.cpp | 23 ++++-------------------
> 1 file changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
> index 2b78d31..8d5f51a 100644
> --- a/src/cpu/intel_cpus.cpp
> +++ b/src/cpu/intel_cpus.cpp
> @@ -49,30 +49,15 @@ static uint64_t get_msr(int cpu, uint64_t offset)
> {
> ssize_t retval;
> uint64_t msr;
> - int fd;
> - char msr_path[256];
>
> - fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
> -
> - if (access(msr_path, R_OK) != 0){
> - fd = sprintf(msr_path, "/dev/msr%d", cpu);
> -
> - if (access(msr_path, R_OK) != 0){
> - fprintf(stderr, _("msr reg not found"));
> - exit(-2);
> - }
> - }
> -
> - fd = open(msr_path, O_RDONLY);
> -
> - retval = pread(fd, &msr, sizeof msr, offset);
> - if (retval != sizeof msr) {
> + retval = read_msr(cpu, offset, &msr);
> + if (retval < 0) {
> reset_display();
> - fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
> + fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
> fprintf(stderr, "%s\n", strerror(errno));
> exit(-2);
> }
> - close(fd);
> +
> return msr;
> }
>
> --
> 1.7.11.7
>
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
>
^ permalink raw reply [flat|nested] 4+ messages in thread* [Powertop] [PATCH 2/8] Use MSR Lib MSR functions
@ 2013-04-15 16:09 Srinivas Pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2013-04-15 16:09 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]
MSR read is implemented in lib.c. Use this API instead.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
src/cpu/intel_cpus.cpp | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index d17a605..d1205b2 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -50,30 +50,15 @@ static uint64_t get_msr(int cpu, uint64_t offset)
{
ssize_t retval;
uint64_t msr;
- int fd;
- char msr_path[256];
- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fd = sprintf(msr_path, "/dev/msr%d", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fprintf(stderr, _("Model-specific registers (MSR) not found (try enabling CONFIG_X86_MSR).\n"));
- exit(-2);
- }
- }
-
- fd = open(msr_path, O_RDONLY);
-
- retval = pread(fd, &msr, sizeof msr, offset);
- if (retval != sizeof msr) {
+ retval = read_msr(cpu, offset, &msr);
+ if (retval < 0) {
reset_display();
- fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
+ fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
fprintf(stderr, "%s\n", strerror(errno));
exit(-2);
}
- close(fd);
+
return msr;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Powertop] [PATCH 2/8] Use MSR Lib MSR functions
@ 2013-04-12 15:47 Srinivas Pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2013-04-12 15:47 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]
MSR read is implemented in lib.c. Use this API instead.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
src/cpu/intel_cpus.cpp | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 2b78d31..8d5f51a 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -49,30 +49,15 @@ static uint64_t get_msr(int cpu, uint64_t offset)
{
ssize_t retval;
uint64_t msr;
- int fd;
- char msr_path[256];
- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fd = sprintf(msr_path, "/dev/msr%d", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fprintf(stderr, _("msr reg not found"));
- exit(-2);
- }
- }
-
- fd = open(msr_path, O_RDONLY);
-
- retval = pread(fd, &msr, sizeof msr, offset);
- if (retval != sizeof msr) {
+ retval = read_msr(cpu, offset, &msr);
+ if (retval < 0) {
reset_display();
- fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
+ fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
fprintf(stderr, "%s\n", strerror(errno));
exit(-2);
}
- close(fd);
+
return msr;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Powertop] [PATCH 2/8] Use MSR Lib MSR functions
@ 2013-04-11 23:58 Srinivas Pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2013-04-11 23:58 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]
MSR read is implemented in lib.c. Use this API instead.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
src/cpu/intel_cpus.cpp | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 2b78d31..8d5f51a 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -49,30 +49,15 @@ static uint64_t get_msr(int cpu, uint64_t offset)
{
ssize_t retval;
uint64_t msr;
- int fd;
- char msr_path[256];
- fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fd = sprintf(msr_path, "/dev/msr%d", cpu);
-
- if (access(msr_path, R_OK) != 0){
- fprintf(stderr, _("msr reg not found"));
- exit(-2);
- }
- }
-
- fd = open(msr_path, O_RDONLY);
-
- retval = pread(fd, &msr, sizeof msr, offset);
- if (retval != sizeof msr) {
+ retval = read_msr(cpu, offset, &msr);
+ if (retval < 0) {
reset_display();
- fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
+ fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
fprintf(stderr, "%s\n", strerror(errno));
exit(-2);
}
- close(fd);
+
return msr;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-15 16:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-13 10:43 [Powertop] [PATCH 2/8] Use MSR Lib MSR functions Sergey Senozhatsky
-- strict thread matches above, loose matches on Subject: below --
2013-04-15 16:09 Srinivas Pandruvada
2013-04-12 15:47 Srinivas Pandruvada
2013-04-11 23:58 Srinivas Pandruvada
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.