diff mbox

[V2] tools:misc:xenpm: set max freq to all cpu with default cpuid

Message ID 1492080268-18123-1-git-send-email-luwei.kang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Luwei Kang April 13, 2017, 10:44 a.m. UTC
User can set max freq to specific cpu by
"xenpm set-scaling-maxfreq [cpuid] <HZ>"
or set max freq to all cpu with default cpuid by
"xenpm set-scaling-maxfreq <HZ>".

Set max freq with default cpuid will cause
segmentation fault after commit id d4906b5d05.
This patch will fix this issue and add ability
to set max freq with default cpuid.

Signed-off-by: Luwei Kang <luwei.kang@intel.com>
---
 tools/misc/xenpm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Roger Pau Monné April 13, 2017, 11:41 a.m. UTC | #1
On Thu, Apr 13, 2017 at 06:44:28PM +0800, Luwei Kang wrote:
> User can set max freq to specific cpu by
> "xenpm set-scaling-maxfreq [cpuid] <HZ>"
> or set max freq to all cpu with default cpuid by
> "xenpm set-scaling-maxfreq <HZ>".
> 
> Set max freq with default cpuid will cause
> segmentation fault after commit id d4906b5d05.
> This patch will fix this issue and add ability
> to set max freq with default cpuid.
> 
> Signed-off-by: Luwei Kang <luwei.kang@intel.com>

Sorry for that.

Compile-tested-by: Roger Pau Monné <roger.pau@citrix.com>
(using clang 4.0)

Thanks, Roger.
Wei Liu April 13, 2017, 3:19 p.m. UTC | #2
On Thu, Apr 13, 2017 at 06:44:28PM +0800, Luwei Kang wrote:
> User can set max freq to specific cpu by
> "xenpm set-scaling-maxfreq [cpuid] <HZ>"
> or set max freq to all cpu with default cpuid by
> "xenpm set-scaling-maxfreq <HZ>".
> 
> Set max freq with default cpuid will cause
> segmentation fault after commit id d4906b5d05.
> This patch will fix this issue and add ability
> to set max freq with default cpuid.
> 
> Signed-off-by: Luwei Kang <luwei.kang@intel.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>
Julien Grall April 13, 2017, 3:20 p.m. UTC | #3
Hi,

On 13/04/17 16:19, Wei Liu wrote:
> On Thu, Apr 13, 2017 at 06:44:28PM +0800, Luwei Kang wrote:
>> User can set max freq to specific cpu by
>> "xenpm set-scaling-maxfreq [cpuid] <HZ>"
>> or set max freq to all cpu with default cpuid by
>> "xenpm set-scaling-maxfreq <HZ>".
>>
>> Set max freq with default cpuid will cause
>> segmentation fault after commit id d4906b5d05.
>> This patch will fix this issue and add ability
>> to set max freq with default cpuid.
>>
>> Signed-off-by: Luwei Kang <luwei.kang@intel.com>
>
> Acked-by: Wei Liu <wei.liu2@citrix.com>

Release-acked-by: Julien Grall <julien.grall@arm.com>

Cheers,
diff mbox

Patch

diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
index ded40b9..762311e 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -99,10 +99,12 @@  static void parse_cpuid_and_int(int argc, char *argv[],
          exit(EINVAL);
     }
 
-    parse_cpuid(argv[0], cpuid);
-    if ( sscanf(argv[1], "%d", val) != 1 )
+    if ( argc > 1 )
+        parse_cpuid(argv[0], cpuid);
+
+    if ( sscanf(argv[argc > 1], "%d", val) != 1 )
     {
-        fprintf(stderr, "Invalid %s '%s'\n", what, argv[1]);
+        fprintf(stderr, "Invalid %s '%s'\n", what, argv[argc > 1]);
         exit(EINVAL);
     }
 }