Skip to content

Commit

Permalink
tools/power/x86/intel-speed-select: Error on CPU count exceed in request
Browse files Browse the repository at this point in the history
There is a limit on number of CPUs in one request. This is set to 256.
Currently tool silently ignores request for count over 256. Give an
error message to indicate this.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
  • Loading branch information
spandruvada committed Aug 8, 2023
1 parent 06bbebd commit e67b6ed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tools/power/x86/intel-speed-select/isst-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2622,10 +2622,11 @@ static struct process_cmd_struct isst_cmds[] = {
*/
void parse_cpu_command(char *optarg)
{
unsigned int start, end;
unsigned int start, end, invalid_count;
char *next;

next = optarg;
invalid_count = 0;

while (next && *next) {
if (*next == '-') /* no negative cpu numbers */
Expand All @@ -2635,6 +2636,8 @@ void parse_cpu_command(char *optarg)

if (max_target_cpus < MAX_CPUS_IN_ONE_REQ)
target_cpus[max_target_cpus++] = start;
else
invalid_count = 1;

if (*next == '\0')
break;
Expand All @@ -2661,6 +2664,8 @@ void parse_cpu_command(char *optarg)
while (++start <= end) {
if (max_target_cpus < MAX_CPUS_IN_ONE_REQ)
target_cpus[max_target_cpus++] = start;
else
invalid_count = 1;
}

if (*next == ',')
Expand All @@ -2669,6 +2674,13 @@ void parse_cpu_command(char *optarg)
goto error;
}

if (invalid_count) {
isst_ctdp_display_information_start(outf);
isst_display_error_info_message(1, "Too many CPUs in one request: max is", 1, MAX_CPUS_IN_ONE_REQ - 1);
isst_ctdp_display_information_end(outf);
exit(-1);
}

#ifdef DEBUG
{
int i;
Expand Down

0 comments on commit e67b6ed

Please sign in to comment.