cpufreq Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit
@ 2010-12-08 16:39 Frank Arnold
  2010-12-08 20:53 ` Thomas Renninger
  2010-12-12  9:07 ` Dominik Brodowski
  0 siblings, 2 replies; 3+ messages in thread
From: Frank Arnold @ 2010-12-08 16:39 UTC (permalink / raw)
  To: Dominik Brodowski, Thomas Renninger; +Cc: Borislav Petkov, cpufreq

The cpufreq-aperf command does not work on 32-bit systems. The reason
for that is a wrong count argument passed to the read() call. Instead
of the buffer size, the size of the pointer to the buffer is used. On
64-bit systems this just happened to work, because we need to read an
8 byte value and a pointer has a size of 8 bytes on 64-bit. On 32-bit
systems only 4 bytes are read, which then triggers the error path.

Signed-off-by: Frank Arnold <frank.arnold@amd.com>
---
 utils/aperf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utils/aperf.c b/utils/aperf.c
index 1c64501..6302f5a 100644
--- a/utils/aperf.c
+++ b/utils/aperf.c
@@ -100,7 +100,7 @@ static int read_msr(int cpu, unsigned int idx, unsigned long long *val)
 		return -1;
 	if (lseek(fd, idx, SEEK_CUR) == -1)
 		goto err;
-	if (read(fd, val, sizeof val) != sizeof *val)
+	if (read(fd, val, sizeof *val) != sizeof *val)
 		goto err;
 	close(fd);
 	return 0;
-- 
1.7.2.3




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit
  2010-12-08 16:39 [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit Frank Arnold
@ 2010-12-08 20:53 ` Thomas Renninger
  2010-12-12  9:07 ` Dominik Brodowski
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Renninger @ 2010-12-08 20:53 UTC (permalink / raw)
  To: Frank Arnold; +Cc: Dominik Brodowski, Borislav Petkov, cpufreq

On Wednesday 08 December 2010 17:39:14 Frank Arnold wrote:
> The cpufreq-aperf command does not work on 32-bit systems. The reason
> for that is a wrong count argument passed to the read() call. Instead
> of the buffer size, the size of the pointer to the buffer is used. On
> 64-bit systems this just happened to work, because we need to read an
> 8 byte value and a pointer has a size of 8 bytes on 64-bit. On 32-bit
> systems only 4 bytes are read, which then triggers the error path.
> 
> Signed-off-by: Frank Arnold <frank.arnold@amd.com>
> ---
>  utils/aperf.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/utils/aperf.c b/utils/aperf.c
> index 1c64501..6302f5a 100644
> --- a/utils/aperf.c
> +++ b/utils/aperf.c
> @@ -100,7 +100,7 @@ static int read_msr(int cpu, unsigned int idx, 
unsigned long long *val)
>  		return -1;
>  	if (lseek(fd, idx, SEEK_CUR) == -1)
>  		goto err;
> -	if (read(fd, val, sizeof val) != sizeof *val)
> +	if (read(fd, val, sizeof *val) != sizeof *val)

Reviewed-by: trenn@suse.de

Thanks,

       Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit
  2010-12-08 16:39 [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit Frank Arnold
  2010-12-08 20:53 ` Thomas Renninger
@ 2010-12-12  9:07 ` Dominik Brodowski
  1 sibling, 0 replies; 3+ messages in thread
From: Dominik Brodowski @ 2010-12-12  9:07 UTC (permalink / raw)
  To: Frank Arnold; +Cc: Thomas Renninger, Borislav Petkov, cpufreq

Applied, thanks.

Best,
	Dominik

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-12  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 16:39 [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit Frank Arnold
2010-12-08 20:53 ` Thomas Renninger
2010-12-12  9:07 ` Dominik Brodowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox