All of lore.kernel.org
 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: [PATCH v3 3/8] eal: change several log levels matching a regexp
Date: Fri, 14 Apr 2017 13:40:31 +0800	[thread overview]
Message-ID: <9f3e0c9e-9e95-1c7e-7f68-d74c731e6313@intel.com> (raw)
In-Reply-To: <20170404164040.24132-4-olivier.matz@6wind.com>

Hi Olivier,


On 4/5/2017 12:40 AM, Olivier Matz wrote:
> Introduce a function to set the log level of several log types that
> match a regular expression.
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>   lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
>   lib/librte_eal/common/eal_common_log.c          | 21 +++++++++++++++++++++
>   lib/librte_eal/common/include/rte_log.h         | 12 ++++++++++++
>   lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
>   4 files changed, 35 insertions(+)
>
> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> index bd63ea66b..de74ff9ff 100644
> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> @@ -189,5 +189,6 @@ DPDK_17.05 {
>   	rte_log_dump;
>   	rte_log_register;
>   	rte_log_set_level;
> +	rte_log_set_level_regexp;
>   
>   } DPDK_17.02;
> diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
> index 90326215b..d02689390 100644
> --- a/lib/librte_eal/common/eal_common_log.c
> +++ b/lib/librte_eal/common/eal_common_log.c
> @@ -37,6 +37,7 @@
>   #include <stdlib.h>
>   #include <string.h>
>   #include <errno.h>
> +#include <regex.h>
>   
>   #include <rte_eal.h>
>   #include <rte_log.h>
> @@ -132,6 +133,26 @@ rte_log_set_level(uint32_t type, uint32_t level)
>   	return 0;
>   }
>   
> +/* set level */
> +int
> +rte_log_set_level_regexp(const char *pattern, uint32_t level)
> +{
> +	regex_t r;
> +	size_t i;
> +
> +	if (level > RTE_LOG_DEBUG)
> +		return -1;
> +
> +	for (i = 0; i < rte_logs.dynamic_types_len; i++) {
> +		if (rte_logs.dynamic_types[i].name == NULL)
> +			continue;
> +		if (regexec(&r, pattern, 0, NULL, 0) == 0)
> +			rte_logs.dynamic_types[i].loglevel = level;

When I try this option, it causes segment fault. The problem might lie 
in this function. As far as I know, when we use regexec(), we need to 
compile a regular expression firstly using regcomp(); and then call 
regexec() with the compiled pattern with the full string. In other words:

         regcomp(&r, pattern, 0);
         for (i = 0; i < rte_logs.dynamic_types_len; i++) {
                 ...
                if (regexec(&r, rte_logs.dynamic_types[i].name, 0, NULL, 
0) == 0)
                         rte_logs.dynamic_types[i].loglevel = level;
         }

Thanks,
Jianfeng

> +	}
> +
> +	return 0;
> +}
> +
>   /* get the current loglevel for the message beeing processed */
>   int rte_log_cur_msg_loglevel(void)
>   {
> diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
> index 97e0c5e52..ce48b0785 100644
> --- a/lib/librte_eal/common/include/rte_log.h
> +++ b/lib/librte_eal/common/include/rte_log.h
> @@ -157,6 +157,18 @@ uint32_t rte_get_log_type(void);
>   /**
>    * Set the log level for a given type.
>    *
> + * @param pattern
> + *   The regexp identifying the log type.
> + * @param level
> + *   The level to be set.
> + * @return
> + *   0 on success, a negative value if level is invalid.
> + */
> +int rte_log_set_level_regexp(const char *pattern, uint32_t level);
> +
> +/**
> + * Set the log level for a given type.
> + *
>    * @param logtype
>    *   The log type identifier.
>    * @param level
> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> index ef48500e9..f70b4b937 100644
> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> @@ -193,5 +193,6 @@ DPDK_17.05 {
>   	rte_log_dump;
>   	rte_log_register;
>   	rte_log_set_level;
> +	rte_log_set_level_regexp;
>   
>   } DPDK_17.02;

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

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-06 13:29 [RFC 0/8] eal: dynamic logs Olivier Matz
2017-02-06 13:29 ` [RFC 1/8] eal: support dynamic log types Olivier Matz
2017-02-06 13:29 ` [RFC 2/8] eal: dump registered " Olivier Matz
2017-02-06 13:29 ` [RFC 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-02-06 13:29 ` [RFC 4/8] eal: change specific log levels at startup Olivier Matz
2017-02-06 13:29 ` [RFC 5/8] eal: deprecate log functions Olivier Matz
2017-02-06 13:29 ` [RFC 6/8] app/test: new command to dump log types Olivier Matz
2017-02-06 13:29 ` [RFC 7/8] app/testpmd: " Olivier Matz
2017-02-06 13:29 ` [RFC 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-02-06 13:49 ` [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 ` [PATCH " Olivier Matz
2017-03-17 15:51   ` [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   ` [PATCH 2/8] eal: dump registered " Olivier Matz
2017-03-17 15:51   ` [PATCH 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-03-17 15:51   ` [PATCH 4/8] eal: change specific log levels at startup Olivier Matz
2017-03-17 15:51   ` [PATCH 5/8] eal: deprecate log functions Olivier Matz
2017-03-17 15:51   ` [PATCH 6/8] app/test: new command to dump log types Olivier Matz
2017-03-17 15:51   ` [PATCH 7/8] app/testpmd: " Olivier Matz
2017-03-17 15:51   ` [PATCH 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-03-29 15:53   ` [PATCH v2 0/8] eal: dynamic logs Olivier Matz
2017-03-29 15:53     ` [PATCH v2 1/8] eal: support dynamic log types Olivier Matz
2017-03-29 15:53     ` [PATCH v2 2/8] eal: dump registered " Olivier Matz
2017-04-04  9:01       ` Thomas Monjalon
2017-03-29 15:53     ` [PATCH v2 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-03-29 15:53     ` [PATCH v2 4/8] eal: change specific log levels at startup Olivier Matz
2017-03-29 15:53     ` [PATCH v2 5/8] eal: deprecate log functions Olivier Matz
2017-03-29 15:53     ` [PATCH v2 6/8] app/test: new command to dump log types Olivier Matz
2017-03-29 15:53     ` [PATCH v2 7/8] app/testpmd: " Olivier Matz
2017-03-29 15:53     ` [PATCH v2 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-04-04 16:40     ` [PATCH v3 0/8] eal: dynamic logs Olivier Matz
2017-04-04 16:40       ` [PATCH v3 1/8] eal: support dynamic log types Olivier Matz
2017-04-04 16:40       ` [PATCH v3 2/8] eal: dump registered " Olivier Matz
2017-04-04 16:40       ` [PATCH v3 3/8] eal: change several log levels matching a regexp Olivier Matz
2017-04-14  5:40         ` Tan, Jianfeng [this message]
2017-04-04 16:40       ` [PATCH v3 4/8] eal: change specific log levels at startup Olivier Matz
2017-04-14  5:33         ` Tan, Jianfeng
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       ` [PATCH v3 5/8] eal: deprecate log functions Olivier Matz
2017-04-04 16:40       ` [PATCH v3 6/8] app/test: new command to dump log types Olivier Matz
2017-04-04 16:40       ` [PATCH v3 7/8] app/testpmd: " Olivier Matz
2017-04-04 16:40       ` [PATCH v3 8/8] net/i40e: use dynamic log type for control logs Olivier Matz
2017-04-05 11:50       ` [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=9f3e0c9e-9e95-1c7e-7f68-d74c731e6313@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.