From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id EE759DE0 for ; Tue, 18 Apr 2017 10:50:20 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id o81so50307638wmb.1 for ; Tue, 18 Apr 2017 01:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rd769c77C7hxDMt5gt/c8E4HCdTIeG/LdBeeo3wSaWM=; b=yP4X8s/iExbVM+C+cZGZeA3tCAOt7TkH4/V2wfg6Zv90eIZN/ndZCmQO0blVOCRgzs vyctKSDg0ZS9NBVIlc2xB9leCWNBmwLfZVjhGcJ4fJrUsi/NEkYWGXfDa58YUrKi5Mma YQXXtWeW9MboLs0zcaE0DvG+c09h7O3RfEr+Yi9mQ8Kp2+jkHA2hNV//4GcgQATUrmez 7ptDo9MG9psCDZxlIgWyGhV/sBEnr2RPLiqfqmN6+vf0kDv6Jc6lc5sI3NcJYPE/h1PP 3ThJ8ZgB4/6tyvZZ7I2d6bUqKCv3S6pE5q7BTP84+oE4YPnRspKNIVd/pQjFJsqRjL9I 4Acw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rd769c77C7hxDMt5gt/c8E4HCdTIeG/LdBeeo3wSaWM=; b=Ulxhv1hjweOQa5BqhPIbUTL9ja5RWqfNXR/ExLhWrAarYzMGZXaeXd1R9uixlArfiI OaDsvmEuRe02Xy3PkgLrRxW8GB2JMzmBFwqubg+ShNBYz7MJgt4qh1nQPtJmhZqMMpoe enRAmrFxPMmNnUKx9x1OzU582M8oVDwDOzR3K1xF+nTajk3VDR8T+R1e7lPVLaH1rDy+ F9wV/dxYhzfq1ukk5IagSu1T5HjpXaXHaXpolDIlMZQHcolv9p5J3NbSrmkyO/u32J43 cM+XTPEuY4buYKbUC676S9JxRvzxLc/dSGgwl14o0baZxd+tB1kH48RuiDFEN2uKQ8Bx yD1Q== X-Gm-Message-State: AN3rC/6jt36QZmsBiXj/pS5uqhvNvoe574pKQddfdZQnwMQNTNWFkWOG 9iuhp/a74WJNgH3a X-Received: by 10.28.236.135 with SMTP id h7mr12243334wmi.74.1492505420629; Tue, 18 Apr 2017 01:50:20 -0700 (PDT) Received: from glumotte.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 19sm13016092wmr.30.2017.04.18.01.50.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2017 01:50:20 -0700 (PDT) Date: Tue, 18 Apr 2017 10:50:47 +0200 From: Olivier MATZ To: "Tan, Jianfeng" Cc: dev@dpdk.org, david.marchand@6wind.com, bruce.richardson@intel.com, thomas.monjalon@6wind.com, keith.wiles@intel.com, stephen@networkplumber.org, "De Lara Guarch, Pablo" Message-ID: <20170418105047.266cd8a0@glumotte.dev.6wind.com> In-Reply-To: <88ff6283-4b3f-f3a7-0d44-9be8fe5441c1@intel.com> References: <20170329155323.4760-1-olivier.matz@6wind.com> <20170404164040.24132-1-olivier.matz@6wind.com> <20170404164040.24132-5-olivier.matz@6wind.com> <88ff6283-4b3f-f3a7-0d44-9be8fe5441c1@intel.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 4/8] eal: change specific log levels at startup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2017 08:50:21 -0000 Hi Jianfeng, On Fri, 14 Apr 2017 13:33:49 +0800, "Tan, Jianfeng" wrote: > Hi Olivier, > > If I understand it correctly, this patch is to shift log level setting > earlier. But we did not remove the one in eal_parse_common_option(). So > we can see this parameter will be analyzed twice. Does it make sense to > remove analysis of log level in eal_parse_common_option()? > The patch does not change the way the log level is parsed: it was already parsed twice, because we want to know the log level as soon as possible. But the patch introduces a bug, as seen by Ferruh: the default log level is not set properly when no --log-level parameter is passed. Regards, Olivier > Thanks, > Jianfeng > > On 4/5/2017 12:40 AM, Olivier Matz wrote: > > Example of use: > > ./app/test-pmd --log-level='pmd\.i40e.*,8' > > > > This enables debug logs for all dynamic logs whose type starts with > > 'pmd.i40e'. > > > > Signed-off-by: Olivier Matz > > --- > > lib/librte_eal/bsdapp/eal/eal.c | 4 +-- > > lib/librte_eal/common/eal_common_options.c | 49 +++++++++++++++++++++++------- > > lib/librte_eal/linuxapp/eal/eal.c | 4 +-- > > 3 files changed, 40 insertions(+), 17 deletions(-) > > > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c > > index 4ee9c66fe..fae6c7e0a 100644 > > --- a/lib/librte_eal/bsdapp/eal/eal.c > > +++ b/lib/librte_eal/bsdapp/eal/eal.c > > @@ -519,10 +519,8 @@ rte_eal_init(int argc, char **argv) > > > > thread_id = pthread_self(); > > > > - eal_log_level_parse(argc, argv); > > - > > /* set log level as early as possible */ > > - rte_set_log_level(internal_config.log_level); > > + eal_log_level_parse(argc, argv); > > > > if (rte_eal_cpu_init() < 0) { > > rte_eal_init_alert("Cannot detect lcores."); > > diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c > > index f36bc5568..606695a7f 100644 > > --- a/lib/librte_eal/common/eal_common_options.c > > +++ b/lib/librte_eal/common/eal_common_options.c > > @@ -739,25 +739,53 @@ eal_parse_syslog(const char *facility, struct internal_config *conf) > > } > > > > static int > > -eal_parse_log_level(const char *level, uint32_t *log_level) > > +eal_parse_log_level(const char *arg, struct internal_config *conf) > > { > > - char *end; > > + char *end, *str, *type, *level; > > unsigned long tmp; > > > > + str = strdup(arg); > > + if (str == NULL) > > + return -1; > > + > > + if (strchr(str, ',') == NULL) { > > + type = NULL; > > + level = str; > > + } else { > > + type = strsep(&str, ","); > > + level = strsep(&str, ","); > > + } > > + > > errno = 0; > > tmp = strtoul(level, &end, 0); > > > > /* check for errors */ > > if ((errno != 0) || (level[0] == '\0') || > > - end == NULL || (*end != '\0')) > > - return -1; > > + end == NULL || (*end != '\0')) > > + goto fail; > > > > /* log_level is a uint32_t */ > > if (tmp >= UINT32_MAX) > > - return -1; > > + goto fail; > > + > > + printf("set log level %s,%lu\n", > > + type, tmp); > > + > > + if (type == NULL) { > > + conf->log_level = tmp; > > + rte_set_log_level(tmp); > > + } else if (rte_log_set_level_regexp(type, tmp) < 0) { > > + printf("cannot set log level %s,%lu\n", > > + type, tmp); > > + goto fail; > > + } > > > > - *log_level = tmp; > > + free(str); > > return 0; > > + > > +fail: > > + free(str); > > + return -1; > > } > > > > static enum rte_proc_type_t > > @@ -898,15 +926,12 @@ eal_parse_common_option(int opt, const char *optarg, > > break; > > > > case OPT_LOG_LEVEL_NUM: { > > - uint32_t log; > > - > > - if (eal_parse_log_level(optarg, &log) < 0) { > > + if (eal_parse_log_level(optarg, conf) < 0) { > > RTE_LOG(ERR, EAL, > > "invalid parameters for --" > > OPT_LOG_LEVEL "\n"); > > return -1; > > } > > - conf->log_level = log; > > break; > > } > > case OPT_LCORES_NUM: > > @@ -1057,7 +1082,9 @@ eal_common_usage(void) > > " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n" > > " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n" > > " --"OPT_SYSLOG" Set syslog facility\n" > > - " --"OPT_LOG_LEVEL" Set default log level\n" > > + " --"OPT_LOG_LEVEL"= Set global log level\n" > > + " --"OPT_LOG_LEVEL"=,\n" > > + " Set specific log level\n" > > " -v Display version information on startup\n" > > " -h, --help This help\n" > > "\nEAL options for DEBUG use only:\n" > > diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c > > index f0ded185b..d98d56d2f 100644 > > --- a/lib/librte_eal/linuxapp/eal/eal.c > > +++ b/lib/librte_eal/linuxapp/eal/eal.c > > @@ -776,10 +776,8 @@ rte_eal_init(int argc, char **argv) > > > > thread_id = pthread_self(); > > > > - eal_log_level_parse(argc, argv); > > - > > /* set log level as early as possible */ > > - rte_set_log_level(internal_config.log_level); > > + eal_log_level_parse(argc, argv); > > > > if (rte_eal_cpu_init() < 0) { > > rte_eal_init_alert("Cannot detect lcores."); >