From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by dpdk.org (Postfix) with ESMTP id 43996590F for ; Fri, 26 Jul 2013 13:55:31 +0200 (CEST) Received: by mail-wi0-f178.google.com with SMTP id j17so144677wiw.11 for ; Fri, 26 Jul 2013 04:55:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:x-gm-message-state; bh=Ni+m6uqVhiJSCFOvz4Bg3dlQt7lPvqUnLJbXMNfPSYU=; b=oXxBJHxHaIx3MAHdt8PscwOMBJs+BFtdhcmndFH9ncV4nmJUHhES9ufbkvtk1gLe0G /Lqh+NWPZ1ZUoylPQ6uVhDlQv732tjA8Re/E+3UbytYqu3CPNr8YzVRBxm9B++JWdmPF n9N1aXQCHu1N0Nrt0fdJBqewEbUApXePs3bI3yxvecp4/ZA1HnfFuUrf3ytKWtGjaLtE 7BCw+ha2SoLHL7hBxpZNnaiND/MH8E8snWMj79Tpyvj8b6fSce1o8xd7Pp6/eSscGttS ReSK/7uORsgLalMC6dyjgM4fE3FOLBOrTU7z0copGP7dbdTtgut3dVp1Ne68jeEwRGsV eMoA== X-Received: by 10.180.185.101 with SMTP id fb5mr5463149wic.44.1374839753994; Fri, 26 Jul 2013 04:55:53 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id a6sm4172191wib.10.2013.07.26.04.55.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 04:55:52 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Fri, 26 Jul 2013 13:55:49 +0200 From: Thomas Monjalon To: dev@dpdk.org Date: Fri, 26 Jul 2013 13:55:49 +0200 Message-Id: <1374839749-28143-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQk/82K2DirEJI+mITLsxFhrla4sVoIiWVkmC5sxqwkQ3wk1ZdTh8zWlAJs6Ar4C8+5eVsap Subject: [dpdk-dev] [PATCH] eal: fix recording of detected/enabled logical cores X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jul 2013 11:55:31 -0000 From: Ivan Boule 1) In the EAL initialization phase, invoke the function rte_eal_cpu_init to detect the set of running cores (and enable them by default) before processing the [enabled] core mask option that is performed during the parsing of EAL arguments. 2) In the function rte_eal_cpu_init(): - to parse the set of all running logical cores on the machine, do not use the RTE_LCORE_FOREACH macro that considers the set of already detected cores... Instead, use a standard loop based on the RTE_MAX_LCORE constant. - explicitely set to ROLE_RTE the role of each detected logical core that is recorded in the EAL configuration, as all running cores are enabled by default. 3) In the function eal_parse_coremask(), update the "lcore_count" field of the EAL configuration with the effective number of logical cores that are set in the mask of enabled logical cores. Signed-off-by: Ivan Boule --- lib/librte_eal/linuxapp/eal/eal.c | 8 +++++--- lib/librte_eal/linuxapp/eal/eal_lcore.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index d94c6bb..ed0e9b1 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -389,6 +389,8 @@ eal_parse_coremask(const char *coremask) cfg->lcore_role[i] = ROLE_OFF; } } + /* Update the count of enabled logical cores of the EAL configuration */ + cfg->lcore_count = count; return 0; } @@ -817,6 +819,9 @@ rte_eal_init(int argc, char **argv) if (rte_eal_log_early_init() < 0) rte_panic("Cannot init early logs\n"); + if (rte_eal_cpu_init() < 0) + rte_panic("Cannot detect lcores\n"); + fctret = eal_parse_args(argc, argv); if (fctret < 0) exit(1); @@ -849,9 +854,6 @@ rte_eal_init(int argc, char **argv) rte_config_init(); - if (rte_eal_cpu_init() < 0) - rte_panic("Cannot detect lcores\n"); - if (rte_eal_memory_init() < 0) rte_panic("Cannot init memory\n"); diff --git a/lib/librte_eal/linuxapp/eal/eal_lcore.c b/lib/librte_eal/linuxapp/eal/eal_lcore.c index 7487f34..768e333 100644 --- a/lib/librte_eal/linuxapp/eal/eal_lcore.c +++ b/lib/librte_eal/linuxapp/eal/eal_lcore.c @@ -152,15 +152,19 @@ rte_eal_cpu_init(void) unsigned lcore_id; unsigned count = 0; - /* disable lcores that were not detected */ - RTE_LCORE_FOREACH(lcore_id) { - + /* + * Parse the maximum set of logical cores, detect the subset of running + * ones and enable them by default. + */ + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { lcore_config[lcore_id].detected = cpu_detected(lcore_id); if (lcore_config[lcore_id].detected == 0) { RTE_LOG(DEBUG, EAL, "Skip lcore %u (not detected)\n", lcore_id); config->lcore_role[lcore_id] = ROLE_OFF; continue; } + /* By default, each detected core is enabled */ + config->lcore_role[lcore_id] = ROLE_RTE; lcore_config[lcore_id].core_id = cpu_core_id(lcore_id); lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id); if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES) @@ -177,7 +181,7 @@ rte_eal_cpu_init(void) lcore_config[lcore_id].socket_id); count ++; } - + /* Set the count of enabled logical cores of the EAL configuration */ config->lcore_count = count; return 0; -- 1.7.10.4