Message ID | 1433520077-11234-1-git-send-email-bruce.richardson@intel.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 573E05A50; Fri, 5 Jun 2015 18:01:23 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A9B7D37A8 for <dev@dpdk.org>; Fri, 5 Jun 2015 18:01:21 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 05 Jun 2015 09:01:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,559,1427785200"; d="scan'208";a="705983547" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 05 Jun 2015 09:01:18 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t55G1Hrm030086; Fri, 5 Jun 2015 17:01:17 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t55G1HqM011270; Fri, 5 Jun 2015 17:01:17 +0100 Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id t55G1HeL011266; Fri, 5 Jun 2015 17:01:17 +0100 From: Bruce Richardson <bruce.richardson@intel.com> To: dev@dpdk.org Date: Fri, 5 Jun 2015 17:01:17 +0100 Message-Id: <1433520077-11234-1-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] examples/distributor: fix missing "; " in debug macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Bruce Richardson
June 5, 2015, 4:01 p.m. UTC
The macro to turn on additional debug output when the app was compiled with "-DDEBUG" was missing a ";". Fixes: 07db4a975094 ("examples/distributor: new sample app") Signed-off-by: Anbarasan Murugesan <anbarasanx.murugesan@intel.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- examples/distributor/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
2015-06-05 17:01, Bruce Richardson: > The macro to turn on additional debug output when the app was compiled > with "-DDEBUG" was missing a ";". It shows that such dead code is almost never tested. It would be saner if this command would return no result: git grep 'ifdef.*DEBUG' examples examples/distributor/main.c:#ifdef DEBUG examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG examples/packet_ordering/main.c:#ifdef DEBUG examples/vhost/main.c:#ifdef DEBUG examples/vhost/main.h:#ifdef DEBUG examples/vhost_xen/main.c:#ifdef DEBUG examples/vhost_xen/main.h:#ifdef DEBUG There is no good reason to not use CONFIG_RTE_LOG_LEVEL to trigger debug build.
On Fri, Jun 05, 2015 at 10:45:04PM +0200, Thomas Monjalon wrote: > 2015-06-05 17:01, Bruce Richardson: > > The macro to turn on additional debug output when the app was compiled > > with "-DDEBUG" was missing a ";". > > It shows that such dead code is almost never tested. > It would be saner if this command would return no result: > git grep 'ifdef.*DEBUG' examples > examples/distributor/main.c:#ifdef DEBUG > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > examples/packet_ordering/main.c:#ifdef DEBUG > examples/vhost/main.c:#ifdef DEBUG > examples/vhost/main.h:#ifdef DEBUG > examples/vhost_xen/main.c:#ifdef DEBUG > examples/vhost_xen/main.h:#ifdef DEBUG > > There is no good reason to not use CONFIG_RTE_LOG_LEVEL to trigger debug build. > I agree and disagree. I agree it would be good if we had a standard way of setting up a DEBUG build that would make it easier to test and pick up on this sort of things. I disagree that the compile time log level is the way to do this. The log level at compile time specifies the default log level only, the actual log level is controllable at runtime. Having the default log level also affect what kind of build is done, e.g. with -O0 rather than -O3, introduces an unnecessary dependency. Setting the default log level to 5 and changing it to 9 at runtime should be the same as setting the default to 9. /Bruce
On Mon, 8 Jun 2015 11:58:10 +0100 Bruce Richardson <bruce.richardson@intel.com> wrote: > On Fri, Jun 05, 2015 at 10:45:04PM +0200, Thomas Monjalon wrote: > > 2015-06-05 17:01, Bruce Richardson: > > > The macro to turn on additional debug output when the app was compiled > > > with "-DDEBUG" was missing a ";". > > > > It shows that such dead code is almost never tested. > > It would be saner if this command would return no result: > > git grep 'ifdef.*DEBUG' examples > > examples/distributor/main.c:#ifdef DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/packet_ordering/main.c:#ifdef DEBUG > > examples/vhost/main.c:#ifdef DEBUG > > examples/vhost/main.h:#ifdef DEBUG > > examples/vhost_xen/main.c:#ifdef DEBUG > > examples/vhost_xen/main.h:#ifdef DEBUG > > > > There is no good reason to not use CONFIG_RTE_LOG_LEVEL to trigger debug build. > > > I agree and disagree. > > I agree it would be good if we had a standard way of setting up > a DEBUG build that would make it easier to test and pick up on this sort of things. > > I disagree that the compile time log level is the way to do this. The log level > at compile time specifies the default log level only, the actual log level is > controllable at runtime. Having the default log level also affect what kind of > build is done, e.g. with -O0 rather than -O3, introduces an unnecessary dependency. > Setting the default log level to 5 and changing it to 9 at runtime should be > the same as setting the default to 9. > > /Bruce One good way is to use something like: #ifdef DEBUG #define LOG_DEBUG(log_type, fmt, args...) do { \ - RTE_LOG(DEBUG, log_type, fmt, ##args) \ + RTE_LOG(DEBUG, log_type, fmt, ##args); \ } while (0) #else #define LOG_LEVEL RTE_LOG_INFO #define LOG_DEBUG(log_type, fmt, args...) if (0) { \ RTE_LOG(DEBUG, log_type, fmt, ##args); \ } else #endif
2015-06-05 17:01, Bruce Richardson: > The macro to turn on additional debug output when the app was compiled > with "-DDEBUG" was missing a ";". > > Fixes: 07db4a975094 ("examples/distributor: new sample app") > > Signed-off-by: Anbarasan Murugesan <anbarasanx.murugesan@intel.com> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Applied, thanks
2015-06-08 11:58, Bruce Richardson: > On Fri, Jun 05, 2015 at 10:45:04PM +0200, Thomas Monjalon wrote: > > It shows that such dead code is almost never tested. > > It would be saner if this command would return no result: > > git grep 'ifdef.*DEBUG' examples > > examples/distributor/main.c:#ifdef DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > examples/packet_ordering/main.c:#ifdef DEBUG > > examples/vhost/main.c:#ifdef DEBUG > > examples/vhost/main.h:#ifdef DEBUG > > examples/vhost_xen/main.c:#ifdef DEBUG > > examples/vhost_xen/main.h:#ifdef DEBUG > > > > There is no good reason to not use CONFIG_RTE_LOG_LEVEL to trigger debug build. > > > I agree and disagree. > > I agree it would be good if we had a standard way of setting up > a DEBUG build that would make it easier to test and pick up on this sort of things. > > I disagree that the compile time log level is the way to do this. The log level > at compile time specifies the default log level only, the actual log level is > controllable at runtime. Having the default log level also affect what kind of > build is done, e.g. with -O0 rather than -O3, introduces an unnecessary dependency. > Setting the default log level to 5 and changing it to 9 at runtime should be > the same as setting the default to 9. Setting CONFIG_RTE_LOG_LEVEL to 9 means we don't care about performance degradation due to debug log branches. So it is necessarily a debug build. Then the default log level must be set by the application. The EAL default set from CONFIG_RTE_LOG_LEVEL is a last chance default in case the application doesn't care about it. Maybe it won't convince you but anyway, it's not important here because the example applications don't use the DEBUG flag for anything else than the logs. That's why I think these flags must be removed. Please check "git grep 'ifdef.*DEBUG' examples".
On Mon, Jun 22, 2015 at 10:53:25PM +0200, Thomas Monjalon wrote: > 2015-06-08 11:58, Bruce Richardson: > > On Fri, Jun 05, 2015 at 10:45:04PM +0200, Thomas Monjalon wrote: > > > It shows that such dead code is almost never tested. > > > It would be saner if this command would return no result: > > > git grep 'ifdef.*DEBUG' examples > > > examples/distributor/main.c:#ifdef DEBUG > > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > > examples/l3fwd-acl/main.c:#ifdef L3FWDACL_DEBUG > > > examples/packet_ordering/main.c:#ifdef DEBUG > > > examples/vhost/main.c:#ifdef DEBUG > > > examples/vhost/main.h:#ifdef DEBUG > > > examples/vhost_xen/main.c:#ifdef DEBUG > > > examples/vhost_xen/main.h:#ifdef DEBUG > > > > > > There is no good reason to not use CONFIG_RTE_LOG_LEVEL to trigger debug build. > > > > > I agree and disagree. > > > > I agree it would be good if we had a standard way of setting up > > a DEBUG build that would make it easier to test and pick up on this sort of things. > > > > I disagree that the compile time log level is the way to do this. The log level > > at compile time specifies the default log level only, the actual log level is > > controllable at runtime. Having the default log level also affect what kind of > > build is done, e.g. with -O0 rather than -O3, introduces an unnecessary dependency. > > Setting the default log level to 5 and changing it to 9 at runtime should be > > the same as setting the default to 9. > > Setting CONFIG_RTE_LOG_LEVEL to 9 means we don't care about performance > degradation due to debug log branches. So it is necessarily a debug build. > Then the default log level must be set by the application. > The EAL default set from CONFIG_RTE_LOG_LEVEL is a last chance default in > case the application doesn't care about it. > > Maybe it won't convince you but anyway, it's not important here because the > example applications don't use the DEBUG flag for anything else than the logs. > That's why I think these flags must be removed. > Please check "git grep 'ifdef.*DEBUG' examples". > For checking if the app cares about performance, I would check the __optimize__ define rather than having a specific DEBUG macro, or using the DEFAULT_LOG_LEVEL setting. /Bruce
diff --git a/examples/distributor/main.c b/examples/distributor/main.c index ae3e7b3..972bddb 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -57,7 +57,7 @@ #ifdef DEBUG #define LOG_LEVEL RTE_LOG_DEBUG #define LOG_DEBUG(log_type, fmt, args...) do { \ - RTE_LOG(DEBUG, log_type, fmt, ##args) \ + RTE_LOG(DEBUG, log_type, fmt, ##args); \ } while (0) #else #define LOG_LEVEL RTE_LOG_INFO