From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9D836A046B for ; Wed, 26 Jun 2019 07:36:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 970CB1B951; Wed, 26 Jun 2019 07:36:24 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 96D721B951 for ; Wed, 26 Jun 2019 07:36:23 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id i2so773481plt.1 for ; Tue, 25 Jun 2019 22:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=WjsG2dCngP9wxyMSqjDMfBtuLOSk1ClxnTffZ+KZm0s=; b=nbFJhVf6b84wQf0VE613XSF5fcsS5t4TKN+wdCgwmYVOm1Yr3kT7KWkBW/12PwnlAK E+gKqKS/RPliN+YURodpyWwAc1vCqDXT5/c9XvlTvR7SxQOjJJ4VRQ3zg+3hz9qW6a6E RCB8E4P4Uz4O1/O9VMoh3gpZRdeZuTOAQdqDVPWULmYaKzDNNLoj2TBPfl+azNmkgnZL kyWLewWjKhJVU9oRJ+3/1i4d9w38DToTxc+AJmA6p4KDRaligEpQCvCEhxu6ib9g8iTa 9aYY8t8EqOLkB1k09VgjaLizbWLu5X4IZbfuJvgtb48PThJeldvaPxq2vM4Bm9z5cu7I dGIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=WjsG2dCngP9wxyMSqjDMfBtuLOSk1ClxnTffZ+KZm0s=; b=RVELRcLqTx4nms0r4mxMFw8pcugjewjhzcTX8xoxMlg5t6eMaMc3S/Q7PXvVV0njm/ V8vf+5Ud7JGX/GHjGefcjQuk4sh3iEKt+B2XpJ4ImqmE6eXw1TgpoxMhxU05w/lFNhkO 0rGpPKWiTJZ+p+DYJMUthlnWZWqOyE12AQH+YXaAj7H6z0/JmX14WU6u7t6ar0b0sQwi mIVfR0jgpkERJ4GEmj0Qinbo4zwU3h1dm//U0CXZFHwyGFMAPzZ8PLA3LiTPNgas04+m B9BK0i7bQ4iasUgUPHr4+ClctqVmxJfZcc18CjBnGgBcIA7BlDXnw1Ye/Oitqscbkesn eWOg== X-Gm-Message-State: APjAAAWIwzjGUa6b+XL463Z792kTn692ZTHyBiJFZ3/a/epgJY0rC7p3 1hzhQ9EhLzDicoK0iddfF+AhnHqj X-Google-Smtp-Source: APXvYqwXU85yIK+GChBJIakk6hOEh/FfEs4y8NZo/KqvIAMwsAWFaxnjFJb0+odRVZr3/xV1QQC9TA== X-Received: by 2002:a17:902:404:: with SMTP id 4mr3201638ple.200.1561527382663; Tue, 25 Jun 2019 22:36:22 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id 201sm22719973pfz.24.2019.06.25.22.36.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jun 2019 22:36:22 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Wed, 26 Jun 2019 14:36:16 +0900 Message-Id: <20190626053617.39907-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626053617.39907-1-yasufum.o@gmail.com> References: <20190626053617.39907-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 1/2] shared/sec: remove global master lcore ID X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa In SPP worker processes, master lcore ID is managed as a member of global variable, but no need to this because it can be retrieved with rte_get_master_lcore(). This update is to change to use this function. Signed-off-by: Yasufumi Ogawa --- src/mirror/spp_mirror.c | 44 ++++++--------- .../secondary/spp_worker_th/cmd_utils.c | 13 ++--- .../secondary/spp_worker_th/cmd_utils.h | 4 +- src/vf/spp_vf.c | 55 ++++++++----------- 4 files changed, 49 insertions(+), 67 deletions(-) diff --git a/src/mirror/spp_mirror.c b/src/mirror/spp_mirror.c index f040010..898755d 100644 --- a/src/mirror/spp_mirror.c +++ b/src/mirror/spp_mirror.c @@ -56,9 +56,6 @@ struct mirror_info { static uint16_t nb_rxd = MIR_RX_DESC_DEFAULT; static uint16_t nb_txd = MIR_TX_DESC_DEFAULT; -/* Logical core ID for main process */ -static unsigned int g_main_lcore_id = 0xffffffff; - /* Interface management information */ static struct iface_info g_iface_info; @@ -421,7 +418,7 @@ slave_main(void *arg __attribute__ ((unused))) struct core_mng_info *info = &g_core_info[lcore_id]; struct core_info *core = get_core_info(lcore_id); - RTE_LOG(INFO, MIRROR, "Core[%d] Start.\n", lcore_id); + RTE_LOG(INFO, MIRROR, "Slave started on lcore %d.\n", lcore_id); set_core_status(lcore_id, SPP_CORE_IDLE); while ((status = spp_get_core_status(lcore_id)) != @@ -446,14 +443,14 @@ slave_main(void *arg __attribute__ ((unused))) } if (unlikely(ret != 0)) { RTE_LOG(ERR, MIRROR, - "Core[%d] Component Error. (id = %d)\n", + "Failed to forward on lcore %d (id = %d)\n", lcore_id, core->id[cnt]); break; } } set_core_status(lcore_id, SPP_CORE_STOP); - RTE_LOG(INFO, MIRROR, "Core[%d] End.\n", lcore_id); + RTE_LOG(INFO, MIRROR, "Terminated slave on lcore %d.\n", lcore_id); return ret; } @@ -469,6 +466,7 @@ main(int argc, char *argv[]) char ctl_ip[IPADDR_LEN] = { 0 }; int ctl_port; int ret_cmd_init; + unsigned int master_lcore; unsigned int lcore_id; #ifdef SPP_DEMONIZE @@ -498,13 +496,12 @@ main(int argc, char *argv[]) if (unlikely(ret_parse != 0)) break; - /* Get lcore id of main thread to set its status after */ - g_main_lcore_id = rte_lcore_id(); + master_lcore = rte_get_master_lcore(); if (sppwk_set_mng_data(&g_iface_info, g_component_info, g_core_info, g_change_core, - g_change_component, &g_backup_info, - g_main_lcore_id) < 0) { + g_change_component, + &g_backup_info) < 0) { RTE_LOG(ERR, MIRROR, "Failed to set management data.\n"); break; @@ -514,7 +511,7 @@ main(int argc, char *argv[]) ret = mirror_pool_create(get_client_id()); if (ret == SPP_RET_NG) { RTE_LOG(ERR, MIRROR, - "mirror mnuf pool create failed.\n"); + "Failed to create mbuf pool.\n"); return SPP_RET_NG; } @@ -547,7 +544,7 @@ main(int argc, char *argv[]) } /* Set the status of main thread to idle */ - g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE; + g_core_info[master_lcore].status = SPP_CORE_IDLE; int ret_wait = check_core_status_wait(SPP_CORE_IDLE); if (unlikely(ret_wait != 0)) break; @@ -569,7 +566,7 @@ main(int argc, char *argv[]) /* Enter loop for accepting commands */ int ret_do = 0; #ifndef USE_UT_SPP_VF - while (likely(g_core_info[g_main_lcore_id].status != + while (likely(g_core_info[master_lcore].status != SPP_CORE_STOP_REQUEST)) { #else { @@ -599,24 +596,19 @@ main(int argc, char *argv[]) } /* Finalize to exit */ - if (g_main_lcore_id == rte_lcore_id()) { - g_core_info[g_main_lcore_id].status = SPP_CORE_STOP; - int ret_core_end = check_core_status_wait(SPP_CORE_STOP); - if (unlikely(ret_core_end != 0)) - RTE_LOG(ERR, MIRROR, "Core did not stop.\n"); - - /* - * Remove vhost sock file if it is not running - * in vhost-client mode - */ - del_vhost_sockfile(g_iface_info.vhost); - } + g_core_info[master_lcore].status = SPP_CORE_STOP; + int ret_core_end = check_core_status_wait(SPP_CORE_STOP); + if (unlikely(ret_core_end != 0)) + RTE_LOG(ERR, MIRROR, "Failed to terminate master thread.\n"); + + /* Remove vhost sock file if not running in vhost-client mode. */ + del_vhost_sockfile(g_iface_info.vhost); #ifdef SPP_RINGLATENCYSTATS_ENABLE spp_ringlatencystats_uninit(); #endif /* SPP_RINGLATENCYSTATS_ENABLE */ - RTE_LOG(INFO, MIRROR, "spp_mirror exit.\n"); + RTE_LOG(INFO, MIRROR, "Exit spp_mirror.\n"); return ret; } diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.c b/src/shared/secondary/spp_worker_th/cmd_utils.c index 4f84365..32929ec 100644 --- a/src/shared/secondary/spp_worker_th/cmd_utils.c +++ b/src/shared/secondary/spp_worker_th/cmd_utils.c @@ -40,7 +40,6 @@ struct mng_data_info { int *p_change_core; int *p_change_component; /* Set of flags for udpated components */ struct cancel_backup_info *p_backup_info; - unsigned int main_lcore_id; }; /* Logical core ID for main process */ @@ -137,13 +136,15 @@ set_all_core_status(enum sppwk_lcore_status status) void stop_process(int signal) { + unsigned int master_lcore; if (unlikely(signal != SIGTERM) && unlikely(signal != SIGINT)) { return; } - (g_mng_data.p_core_info + g_mng_data.main_lcore_id)->status = - SPP_CORE_STOP_REQUEST; + master_lcore = rte_get_master_lcore(); + (g_mng_data.p_core_info + master_lcore)->status = + SPP_CORE_STOP_REQUEST; set_all_core_status(SPP_CORE_STOP_REQUEST); } @@ -843,8 +844,7 @@ int sppwk_set_mng_data( struct core_mng_info *core_mng_p, int *change_core_p, int *change_component_p, - struct cancel_backup_info *backup_info_p, - unsigned int main_lcore_id) + struct cancel_backup_info *backup_info_p) { /** * TODO(yasufum) confirm why the last `0xffffffff` is same as NULL, @@ -852,7 +852,7 @@ int sppwk_set_mng_data( */ if (iface_p == NULL || component_p == NULL || core_mng_p == NULL || change_core_p == NULL || change_component_p == NULL || - backup_info_p == NULL || main_lcore_id == 0xffffffff) + backup_info_p == NULL) return SPP_RET_NG; g_mng_data.p_iface_info = iface_p; @@ -861,7 +861,6 @@ int sppwk_set_mng_data( g_mng_data.p_change_core = change_core_p; g_mng_data.p_change_component = change_component_p; g_mng_data.p_backup_info = backup_info_p; - g_mng_data.main_lcore_id = main_lcore_id; return SPP_RET_OK; } diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h index e2b987f..f33bc62 100644 --- a/src/shared/secondary/spp_worker_th/cmd_utils.h +++ b/src/shared/secondary/spp_worker_th/cmd_utils.h @@ -532,7 +532,6 @@ int64_t sppwk_convert_mac_str_to_int64(const char *macaddr); * @param change_core_p Pointer to g_change_core address. * @param change_component_p Pointer to g_change_component address. * @param backup_info_p Pointer to g_backup_info address. - * @param main_lcore_id Lcore ID of main thread. * @retval SPP_RET_OK If succeeded. * @retval SPP_RET_NG If failed. */ @@ -541,8 +540,7 @@ int sppwk_set_mng_data(struct iface_info *iface_p, struct core_mng_info *core_mng_p, int *change_core_p, int *change_component_p, - struct cancel_backup_info *backup_info_p, - unsigned int main_lcore_id); + struct cancel_backup_info *backup_info_p); /** * Get mange data address. diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c index 44e39fc..0068329 100644 --- a/src/vf/spp_vf.c +++ b/src/vf/spp_vf.c @@ -18,9 +18,6 @@ #include "shared/secondary/spp_worker_th/spp_port.h" /* Declare global variables */ -/* Logical core ID for main process */ -static unsigned int g_main_lcore_id = 0xffffffff; - /* Interface management information */ static struct iface_info g_iface_info; @@ -147,7 +144,7 @@ slave_main(void *arg __attribute__ ((unused))) struct core_mng_info *info = &g_core_info[lcore_id]; struct core_info *core = get_core_info(lcore_id); - RTE_LOG(INFO, APP, "Core[%d] Start.\n", lcore_id); + RTE_LOG(INFO, APP, "Slave started on lcore %d.\n", lcore_id); set_core_status(lcore_id, SPP_CORE_IDLE); while ((status = spp_get_core_status(lcore_id)) != @@ -178,15 +175,15 @@ slave_main(void *arg __attribute__ ((unused))) } } if (unlikely(ret != 0)) { - RTE_LOG(ERR, APP, "Core[%d] Component Error. " - "(id = %d)\n", + RTE_LOG(ERR, APP, "Failed to forward on lcore %d. " + "(id = %d).\n", lcore_id, core->id[cnt]); break; } } set_core_status(lcore_id, SPP_CORE_STOP); - RTE_LOG(INFO, APP, "Core[%d] End.\n", lcore_id); + RTE_LOG(INFO, APP, "Terminated slave on lcore %d.\n", lcore_id); return ret; } @@ -202,7 +199,8 @@ main(int argc, char *argv[]) char ctl_ip[IPADDR_LEN] = { 0 }; int ctl_port; int ret_cmd_init; - unsigned int lcore_id = 0; + unsigned int master_lcore; + unsigned int lcore_id; #ifdef SPP_DEMONIZE /* Daemonize process */ @@ -231,14 +229,10 @@ main(int argc, char *argv[]) if (unlikely(ret_parse != SPP_RET_OK)) break; - /* Get lcore id of main thread to set its status after */ - g_main_lcore_id = rte_lcore_id(); - - if (sppwk_set_mng_data(&g_iface_info, - g_component_info, g_core_info, - g_change_core, g_change_component, - &g_backup_info, - g_main_lcore_id) < SPP_RET_OK) { + if (sppwk_set_mng_data(&g_iface_info, g_component_info, + g_core_info, g_change_core, + g_change_component, + &g_backup_info) < SPP_RET_OK) { RTE_LOG(ERR, APP, "Failed to set management data.\n"); break; @@ -276,7 +270,8 @@ main(int argc, char *argv[]) } /* Set the status of main thread to idle */ - g_core_info[g_main_lcore_id].status = SPP_CORE_IDLE; + master_lcore = rte_get_master_lcore(); + g_core_info[master_lcore].status = SPP_CORE_IDLE; int ret_wait = check_core_status_wait(SPP_CORE_IDLE); if (unlikely(ret_wait != SPP_RET_OK)) break; @@ -292,7 +287,7 @@ main(int argc, char *argv[]) /* Enter loop for accepting commands */ int ret_do = SPP_RET_OK; #ifndef USE_UT_SPP_VF - while (likely(g_core_info[g_main_lcore_id].status != + while (likely(g_core_info[master_lcore].status != SPP_CORE_STOP_REQUEST)) { #else { @@ -322,23 +317,21 @@ main(int argc, char *argv[]) } /* Finalize to exit */ - if (g_main_lcore_id == rte_lcore_id()) { - g_core_info[g_main_lcore_id].status = SPP_CORE_STOP; - int ret_core_end = check_core_status_wait(SPP_CORE_STOP); - if (unlikely(ret_core_end != SPP_RET_OK)) - RTE_LOG(ERR, APP, "Core did not stop.\n"); - - /* - * Remove vhost sock file if it is not running - * in vhost-client mode - */ - del_vhost_sockfile(g_iface_info.vhost); - } + g_core_info[master_lcore].status = SPP_CORE_STOP; + int ret_core_end = check_core_status_wait(SPP_CORE_STOP); + if (unlikely(ret_core_end != SPP_RET_OK)) + RTE_LOG(ERR, APP, "Failed to terminate master thread.\n"); + + /* + * Remove vhost sock file if it is not running + * in vhost-client mode + */ + del_vhost_sockfile(g_iface_info.vhost); #ifdef SPP_RINGLATENCYSTATS_ENABLE spp_ringlatencystats_uninit(); #endif /* SPP_RINGLATENCYSTATS_ENABLE */ - RTE_LOG(INFO, APP, "spp_vf exit.\n"); + RTE_LOG(INFO, APP, "Exit spp_vf.\n"); return ret; } -- 2.17.1