examples/ip_pipeline: fix coremask limitation

Issue:
coremask used in IP Pipeline is limited to 64 cores.

Solution:
Modified coremask as an array of uint64_t to support RTE_MAX_LCORE

Fixes: 7f64b9c004aa ("examples/ip_pipeline: rework config file syntax")
Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters")
Fixes: b4aee0fb9c6d ("examples/ip_pipeline: reconfigure thread binding dynamically")
Fixes: 4e14069328fc ("examples/ip_pipeline: measure CPU utilization")

Signed-off-by: Sankar Chokkalingam <sankarx.chokkalingam@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Sankar Chokkalingam 2016-12-28 05:01:54 -07:00 committed by Thomas Monjalon
parent 50c644fc1f
commit ac6bad59f1
3 changed files with 47 additions and 12 deletions

View File

@ -491,6 +491,9 @@ struct app_eal_params {
#define APP_THREAD_HEADROOM_STATS_COLLECT 1
#endif
#define APP_CORE_MASK_SIZE \
(RTE_MAX_LCORE / 64 + ((RTE_MAX_LCORE % 64) ? 1 : 0))
struct app_params {
/* Config */
char app_name[APP_APPNAME_SIZE];
@ -533,7 +536,7 @@ struct app_params {
/* Init */
char *eal_argv[1 + APP_EAL_ARGC];
struct cpu_core_map *core_map;
uint64_t core_mask;
uint64_t core_mask[APP_CORE_MASK_SIZE];
struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
struct app_link_data link_data[APP_MAX_LINKS];
struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
@ -1359,6 +1362,36 @@ app_get_link_for_kni(struct app_params *app, struct app_pktq_kni_params *p_kni)
return &app->link_params[link_param_idx];
}
static inline uint32_t
app_core_is_enabled(struct app_params *app, uint32_t lcore_id)
{
return(app->core_mask[lcore_id / 64] &
(1LLU << (lcore_id % 64)));
}
static inline void
app_core_enable_in_core_mask(struct app_params *app, int lcore_id)
{
app->core_mask[lcore_id / 64] |= 1LLU << (lcore_id % 64);
}
static inline void
app_core_build_core_mask_string(struct app_params *app, char *mask_buffer)
{
int i;
mask_buffer[0] = '\0';
for (i = (int)RTE_DIM(app->core_mask); i > 0; i--) {
/* For Hex representation of bits in uint64_t */
char buffer[(64 / 8) * 2 + 1];
memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer), "%016" PRIx64,
app->core_mask[i-1]);
strcat(mask_buffer, buffer);
}
}
void app_pipeline_params_get(struct app_params *app,
struct app_pipeline_params *p_in,
struct pipeline_params *p_out);

View File

@ -78,11 +78,14 @@ app_init_core_map(struct app_params *app)
cpu_core_map_print(app->core_map);
}
/* Core Mask String in Hex Representation */
#define APP_CORE_MASK_STRING_SIZE ((64 * APP_CORE_MASK_SIZE) / 8 * 2 + 1)
static void
app_init_core_mask(struct app_params *app)
{
uint64_t mask = 0;
uint32_t i;
char core_mask_str[APP_CORE_MASK_STRING_SIZE];
for (i = 0; i < app->n_pipelines; i++) {
struct app_pipeline_params *p = &app->pipeline_params[i];
@ -96,17 +99,18 @@ app_init_core_mask(struct app_params *app)
if (lcore_id < 0)
rte_panic("Cannot create CPU core mask\n");
mask |= 1LLU << lcore_id;
app_core_enable_in_core_mask(app, lcore_id);
}
app->core_mask = mask;
APP_LOG(app, HIGH, "CPU core mask = 0x%016" PRIx64, app->core_mask);
app_core_build_core_mask_string(app, core_mask_str);
APP_LOG(app, HIGH, "CPU core mask = 0x%s", core_mask_str);
}
static void
app_init_eal(struct app_params *app)
{
char buffer[256];
char core_mask_str[APP_CORE_MASK_STRING_SIZE];
struct app_eal_params *p = &app->eal_params;
uint32_t n_args = 0;
uint32_t i;
@ -114,7 +118,8 @@ app_init_eal(struct app_params *app)
app->eal_argv[n_args++] = strdup(app->app_name);
snprintf(buffer, sizeof(buffer), "-c%" PRIx64, app->core_mask);
app_core_build_core_mask_string(app, core_mask_str);
snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str);
app->eal_argv[n_args++] = strdup(buffer);
if (p->coremap) {

View File

@ -70,8 +70,7 @@ app_pipeline_enable(struct app_params *app,
core_id,
hyper_th_id);
if ((thread_id < 0) ||
((app->core_mask & (1LLU << thread_id)) == 0))
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
if (app_pipeline_data(app, pipeline_id) == NULL)
@ -134,8 +133,7 @@ app_pipeline_disable(struct app_params *app,
core_id,
hyper_th_id);
if ((thread_id < 0) ||
((app->core_mask & (1LLU << thread_id)) == 0))
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
if (app_pipeline_data(app, pipeline_id) == NULL)
@ -188,8 +186,7 @@ app_thread_headroom(struct app_params *app,
core_id,
hyper_th_id);
if ((thread_id < 0) ||
((app->core_mask & (1LLU << thread_id)) == 0))
if ((thread_id < 0) || !app_core_is_enabled(app, thread_id))
return -1;
req = app_msg_alloc(app);