DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Tan, Jianfeng" <jianfeng.tan@intel.com>
To: Olivier Matz <olivier.matz@6wind.com>, dev@dpdk.org
Cc: david.marchand@6wind.com, bruce.richardson@intel.com,
	thomas.monjalon@6wind.com, keith.wiles@intel.com,
	stephen@networkplumber.org, "De Lara Guarch,
	Pablo" <pablo.de.lara.guarch@intel.com>
Subject: Re: [dpdk-dev] [PATCH v3 4/8] eal: change specific log levels at startup
Date: Fri, 14 Apr 2017 13:33:49 +0800	[thread overview]
Message-ID: <88ff6283-4b3f-f3a7-0d44-9be8fe5441c1@intel.com> (raw)
In-Reply-To: <20170404164040.24132-5-olivier.matz@6wind.com>

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()?

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 <olivier.matz@6wind.com>
> ---
>   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"=<int>   Set global log level\n"
> +	       "  --"OPT_LOG_LEVEL"=<type-regexp>,<int>\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.");

  reply	other threads:[~2017-04-14  5:33 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-06 13:29 [dpdk-dev] [RFC 0/8] eal: dynamic logs Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 1/8] eal: support dynamic log types Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 2/8] eal: dump registered " Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 4/8] eal: change specific log levels at startup Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 5/8] eal: deprecate log functions Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 6/8] app/test: new command to dump log types Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 7/8] app/testpmd: " Olivier Matz
2017-02-06 13:29 ` [dpdk-dev] [RFC 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-02-06 13:49 ` [dpdk-dev] [RFC 0/8] eal: dynamic logs Bruce Richardson
2017-02-06 14:10   ` Olivier Matz
2017-02-06 15:01     ` Wiles, Keith
2017-02-06 15:27       ` Olivier Matz
2017-02-06 15:55         ` Wiles, Keith
2017-02-06 16:18           ` Olivier Matz
2017-02-06 17:57             ` Wiles, Keith
2017-03-15 16:35 ` Thomas Monjalon
2017-03-17 15:32   ` Olivier Matz
2017-03-17 15:51 ` [dpdk-dev] [PATCH " Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 1/8] eal: support dynamic log types Olivier Matz
2017-03-17 16:13     ` Stephen Hemminger
2017-03-17 16:14     ` Stephen Hemminger
2017-03-17 16:15     ` Stephen Hemminger
2017-03-17 16:40       ` Olivier Matz
2017-03-17 16:17     ` Stephen Hemminger
2017-03-17 15:51   ` [dpdk-dev] [PATCH 2/8] eal: dump registered " Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 4/8] eal: change specific log levels at startup Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 5/8] eal: deprecate log functions Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 6/8] app/test: new command to dump log types Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 7/8] app/testpmd: " Olivier Matz
2017-03-17 15:51   ` [dpdk-dev] [PATCH 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-03-29 15:53   ` [dpdk-dev] [PATCH v2 0/8] eal: dynamic logs Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 1/8] eal: support dynamic log types Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 2/8] eal: dump registered " Olivier Matz
2017-04-04  9:01       ` Thomas Monjalon
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 4/8] eal: change specific log levels at startup Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 5/8] eal: deprecate log functions Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 6/8] app/test: new command to dump log types Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 7/8] app/testpmd: " Olivier Matz
2017-03-29 15:53     ` [dpdk-dev] [PATCH v2 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-04-04 16:40     ` [dpdk-dev] [PATCH v3 0/8] eal: dynamic logs Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 1/8] eal: support dynamic log types Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 2/8] eal: dump registered " Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-04-14  5:40         ` Tan, Jianfeng
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 4/8] eal: change specific log levels at startup Olivier Matz
2017-04-14  5:33         ` Tan, Jianfeng [this message]
2017-04-18  8:50           ` Olivier MATZ
2017-04-18 11:15             ` Tan, Jianfeng
2017-04-18 11:56               ` Olivier MATZ
2017-04-14 15:32         ` Ferruh Yigit
2017-04-18  8:02           ` Olivier MATZ
2017-04-14 15:40         ` Ferruh Yigit
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 5/8] eal: deprecate log functions Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 6/8] app/test: new command to dump log types Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 7/8] app/testpmd: " Olivier Matz
2017-04-04 16:40       ` [dpdk-dev] [PATCH v3 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-04-05 11:50       ` [dpdk-dev] [PATCH v3 0/8] eal: dynamic logs Thomas Monjalon
2017-04-12  9:26       ` De Lara Guarch, Pablo
2017-04-12 10:37         ` Thomas Monjalon
2017-04-12 13:11           ` De Lara Guarch, Pablo
2017-04-12 13:29             ` Thomas Monjalon
2017-04-12 13:47               ` De Lara Guarch, Pablo
2017-04-12 14:06                 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88ff6283-4b3f-f3a7-0d44-9be8fe5441c1@intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas.monjalon@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).