examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2010-2014 Intel Corporation.
|
|
|
|
* Copyright(c) 2014 6WIND S.A.
|
|
|
|
*/
|
|
|
|
|
2022-08-27 11:32:22 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
#include <string.h>
|
2022-08-27 11:32:22 +00:00
|
|
|
|
examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
#include <rte_log.h>
|
2022-08-27 11:32:22 +00:00
|
|
|
|
examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse elem, the elem could be single number/range or group
|
|
|
|
* 1) A single number elem, it's just a simple digit. e.g. 9
|
|
|
|
* 2) A single range elem, two digits with a '-' between. e.g. 2-6
|
|
|
|
* 3) A group elem, combines multiple 1) or 2) e.g 0,2-4,6
|
|
|
|
* Within group, '-' used for a range separator;
|
|
|
|
* ',' used for a single number.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
parse_set(const char *input, uint16_t set[], unsigned int num)
|
|
|
|
{
|
|
|
|
unsigned int idx;
|
|
|
|
const char *str = input;
|
|
|
|
char *end = NULL;
|
|
|
|
unsigned int min, max;
|
|
|
|
|
|
|
|
memset(set, 0, num * sizeof(uint16_t));
|
|
|
|
|
|
|
|
while (isblank(*str))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
/* only digit or left bracket is qualify for start point */
|
|
|
|
if (!isdigit(*str) || *str == '\0')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
while (isblank(*str))
|
|
|
|
str++;
|
|
|
|
if (*str == '\0')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
min = num;
|
|
|
|
do {
|
|
|
|
|
|
|
|
/* go ahead to the first digit */
|
|
|
|
while (isblank(*str))
|
|
|
|
str++;
|
|
|
|
if (!isdigit(*str))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* get the digit value */
|
|
|
|
errno = 0;
|
|
|
|
idx = strtoul(str, &end, 10);
|
|
|
|
if (errno || end == NULL || idx >= num)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* go ahead to separator '-' and ',' */
|
|
|
|
while (isblank(*end))
|
|
|
|
end++;
|
|
|
|
if (*end == '-') {
|
|
|
|
if (min == num)
|
|
|
|
min = idx;
|
|
|
|
else /* avoid continuous '-' */
|
|
|
|
return -1;
|
2020-07-14 16:01:58 +00:00
|
|
|
} else if ((*end == ',') || (*end == ':') || (*end == '\0')) {
|
examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
max = idx;
|
|
|
|
|
|
|
|
if (min == num)
|
|
|
|
min = idx;
|
|
|
|
|
|
|
|
for (idx = RTE_MIN(min, max);
|
|
|
|
idx <= RTE_MAX(min, max); idx++) {
|
|
|
|
set[idx] = 1;
|
|
|
|
}
|
|
|
|
min = num;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
str = end + 1;
|
2020-07-14 16:01:58 +00:00
|
|
|
} while ((*end != '\0') && (*end != ':'));
|
|
|
|
|
|
|
|
return str - input;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
parse_branch_ratio(const char *input, float *branch_ratio)
|
|
|
|
{
|
|
|
|
const char *str = input;
|
|
|
|
char *end = NULL;
|
|
|
|
|
|
|
|
while (isblank(*str))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
if (*str == '\0')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Go straight to the ':' separator if present */
|
|
|
|
while ((*str != '\0') && (*str != ':'))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
/* Branch ratio not specified in args so leave it at default setting */
|
|
|
|
if (*str == '\0')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Confirm ':' separator present */
|
|
|
|
if (*str != ':')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
str++;
|
|
|
|
errno = 0;
|
|
|
|
*branch_ratio = strtof(str, &end);
|
|
|
|
if (errno || end == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (*end != '\0')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
str = end + 1;
|
examples/vm_power: add core list parameter
Add in the '-l' command line parameter (also --core-list)
So the user can now pass --corelist=4,6,8-10 and it will
expand out to 4,6,8,9,10 using the parse function provided
in parse.c (parse_set).
This list of cores is then used to enable out-of-band monitoring
to scale up and down these cores based on the ratio of branch
hits versus branch misses. The ratio will be low when a poll
loop is spinning with no packets being received, so the frequency
will be scaled down.
Also , as part of this change, we introduce a core_info struct
which keeps information on each core in the system, and whether
we're doing out of band monitoring on them.
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
2018-07-13 14:22:55 +00:00
|
|
|
|
|
|
|
return str - input;
|
|
|
|
}
|