From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 161F568FC for ; Tue, 4 Oct 2016 10:26:58 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id k125so192476470wma.1 for ; Tue, 04 Oct 2016 01:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MQnTELIxx4g75AaqqHX0aamXoBq9GZXAe4DptIc7WtQ=; b=e1KcXYnybBj4eKmbz/n0FsSLGBvrs7enDQrlp/NkAH4BPciC2EdL2lFJ35pwF5AC6A KxBJlO/rLqosddKpUqamy43iOcJW23H/YP//T+RfpFMDVXHwGeapR76Q29Bjpd0+4zHX JeWJFlhIyBYFKWQ1LLG77NunqI7ul8vPCpht8V2oxEZURzkP7/HMAYLN9VIUgOclngha 6sllG9+FMYQYBuCS5AciKd6quSD092D5gSXOK9HhXtMolbIHaUtJ36SC++31sT9UPfqB 3wCnfSpOdCE25htzJMTLepqYyGNz4yDbM8d+Vs9Mvudjca/NqkjxIFpNjrNFmHsyeGpK AEIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MQnTELIxx4g75AaqqHX0aamXoBq9GZXAe4DptIc7WtQ=; b=B4TABOcanCbb/z3GcD+z+1q9ZMpvmtPRwvXl22BqVr0q0PoAR4xxEA4AapBNw/xAZh XKSmM5MD/du+CeAENdoNXIL3OPwxxmoeWQ0yzlYDMZTUhauY0QQt3FANchMAuRNB17T1 2x5f9GhMi75fuGTXMg9bsXbk44/trLrKdwWtPRtdK9HZAoSmFO7OvoZ3tpH63koGPMCy iBhezyLc7oriHzmNaaYHY2dxzbA6dveRVdmS5TQdfaVVTg0xWiLg00N2UBwDzuHqu3Xi 9KLeLac+rIGIRq+t/+m8mo0V1OI3f9uI23iPEZVu6pKW3B86xN1KwR+GJI45cNIMVKUE GJXA== X-Gm-Message-State: AA6/9Rk/V09nAK566s9OJ1MFs7ax47PCFEo+FmdyIVY69nKKqoxQ+NmweQTwHpTNjdsg5yracthZOjJNPd0jyEby X-Received: by 10.195.20.33 with SMTP id gz1mr1811326wjd.75.1475569617584; Tue, 04 Oct 2016 01:26:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.95.130 with HTTP; Tue, 4 Oct 2016 01:26:37 -0700 (PDT) In-Reply-To: <1474011832-29987-1-git-send-email-olivier.matz@6wind.com> References: <1474011832-29987-1-git-send-email-olivier.matz@6wind.com> From: David Marchand Date: Tue, 4 Oct 2016 10:26:37 +0200 Message-ID: To: Olivier Matz Cc: "dev@dpdk.org" Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH] log: do not drop debug logs at compile time 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: Tue, 04 Oct 2016 08:26:58 -0000 On Fri, Sep 16, 2016 at 9:43 AM, Olivier Matz wrote: > Today, all logs whose level is lower than INFO are dropped at > compile-time. This prevents from enabling debug logs at runtime using > --log-level=8. > > The rationale was to remove debug logs from the data path at > compile-time, avoiding a test at run-time. > > This patch changes the behavior of RTE_LOG() to avoid the compile-time > optimization, and introduces the RTE_LOG_DP() macro that has the same > behavior than the previous RTE_LOG(), for the rare cases where debug > logs are in the data path. > > So it is now possible to enable debug logs at run-time by just > specifying --log-level=8. Some drivers still have special compile-time > options to enable more debug log. Maintainers may consider to > remove/reduce them. > > Signed-off-by: Olivier Matz > --- > config/common_base | 1 + > doc/guides/faq/faq.rst | 2 +- > drivers/net/bnxt/bnxt_txr.c | 2 +- > drivers/net/nfp/nfp_net.c | 8 +++--- > examples/distributor/main.c | 4 +-- > examples/ipsec-secgw/esp.c | 2 +- > examples/ipsec-secgw/ipsec.c | 4 +-- > examples/packet_ordering/main.c | 6 ++-- > examples/quota_watermark/qw/main.c | 2 +- > examples/tep_termination/main.c | 4 +-- > examples/vhost/main.c | 14 +++++----- > examples/vhost_xen/main.c | 20 +++++++------- > lib/librte_eal/common/include/rte_log.h | 49 +++++++++++++++++++++------------ > 13 files changed, 67 insertions(+), 51 deletions(-) > > diff --git a/config/common_base b/config/common_base > index 7830535..04b71e9 100644 > --- a/config/common_base > +++ b/config/common_base > @@ -89,6 +89,7 @@ CONFIG_RTE_MAX_MEMSEG=256 > CONFIG_RTE_MAX_MEMZONE=2560 > CONFIG_RTE_MAX_TAILQ=32 > CONFIG_RTE_LOG_LEVEL=RTE_LOG_INFO > +CONFIG_RTE_LOG_DP_LEVEL=RTE_LOG_INFO > CONFIG_RTE_LOG_HISTORY=256 > CONFIG_RTE_LIBEAL_USE_HPET=n > CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n [snip] > diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h > index 919563c..76b198f 100644 > --- a/lib/librte_eal/common/include/rte_log.h > +++ b/lib/librte_eal/common/include/rte_log.h [snip] > @@ -266,6 +257,30 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) > * - Negative on error. > */ > #define RTE_LOG(l, t, ...) \ > + rte_log(RTE_LOG_ ## l, \ > + RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) > + > +/** > + * Generates a log message for data path. > + * > + * Similar to RTE_LOG(), except that it is removed at compilation time > + * if the RTE_LOG_DP_LEVEL configuration option is lower than the log > + * level argument. > + * > + * @param l > + * Log level. A value between EMERG (1) and DEBUG (8). The short name is > + * expanded by the macro, so it cannot be an integer value. > + * @param t > + * The log type, for example, EAL. The short name is expanded by the > + * macro, so it cannot be an integer value. > + * @param ... > + * The fmt string, as in printf(3), followed by the variable arguments > + * required by the format. > + * @return > + * - 0: Success. > + * - Negative on error. > + */ > +#define RTE_LOG_DP(l, t, ...) \ > (void)((RTE_LOG_ ## l <= RTE_LOG_LEVEL) ? \ > rte_log(RTE_LOG_ ## l, \ > RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ > -- > 2.8.1 Hum, I suppose RTE_LOG_DP should look at RTE_LOG_DP_LEVEL. -- David Marchand