From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15A9FA00C2; Thu, 3 Feb 2022 13:23:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 664F640143; Thu, 3 Feb 2022 13:23:00 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id EC85640140 for ; Thu, 3 Feb 2022 13:22:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643890979; x=1675426979; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=4Ol6yZN5+Y2GRc6Oe7RvuHf3DsD58LHY+e4e8tygruA=; b=Qho5+QxxzqKHm1OK7D8zILHfApPeCZ7AUov8C6KKuNOAQnWJ1Kxzig8m h5Tz6xqFz4ESh0/ucSQTCM6s02191dMDIUscsdUdxCGuxoSDmdNlWZRxJ lgbYwwaOG2sQlV9RGAkMysf63I4HTSuWLDHRVD10bWbbrOlwElniR8oLY RZ4ubojiugZnShjxYs3E0Q5a2m2BfuXd6cz1ZnrZbK0dDr/AlfhzxNWya X+8c3DmJ+BKSkJLX4mYj3LdXu5vvRr0vS07KVJeBJEst/5OjJsvrlsR+c pwjQyFbGRZ5FzMTkeqYp/4nUjxGpB8Wuqylt+0fTsNg6+ie2bMjPfvGou w==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="245726894" X-IronPort-AV: E=Sophos;i="5.88,339,1635231600"; d="scan'208";a="245726894" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 04:22:48 -0800 X-IronPort-AV: E=Sophos;i="5.88,339,1635231600"; d="scan'208";a="538724446" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.19.95]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 03 Feb 2022 04:22:46 -0800 Date: Thu, 3 Feb 2022 12:22:43 +0000 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , Sean Morrissey , Reshma Pattan , dev@dpdk.org Subject: Re: [PATCH v6 20/50] pdump: remove unneeded header includes Message-ID: References: <20220202094802.3618978-1-sean.morrissey@intel.com> <20220202094802.3618978-21-sean.morrissey@intel.com> <20220202075458.3f8cd2c1@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35D86E6B@smartserver.smartshare.dk> <20220202092836.5e1aadbb@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35D86E6C@smartserver.smartshare.dk> <98CBD80474FA8B44BF855DF32C47DC35D86E6E@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D86E6E@smartserver.smartshare.dk> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Feb 03, 2022 at 01:11:42PM +0100, Morten Brørup wrote: > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Thursday, 3 February 2022 11.43 > > > > On Wed, Feb 02, 2022 at 07:21:33PM +0100, Morten Brørup wrote: > > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > > > Sent: Wednesday, 2 February 2022 18.29 > > > > > > > > On Wed, 2 Feb 2022 17:03:44 +0000 > > > > Bruce Richardson wrote: > > > > > > > > > On Wed, Feb 02, 2022 at 05:45:47PM +0100, Morten Brørup wrote: > > > > > > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > > > > > > Sent: Wednesday, 2 February 2022 17.01 > > > > > > > > > > > > > > On Wed, Feb 02, 2022 at 07:54:58AM -0800, Stephen Hemminger > > > > wrote: > > > > > > > > On Wed, 2 Feb 2022 09:47:32 +0000 > > > > > > > > Sean Morrissey wrote: > > > > > > > > > > > > > > > > > These header includes have been flagged by the iwyu_tool > > > > > > > > > and removed. > > > > > > > > > > > > > > > > > > Signed-off-by: Sean Morrissey > > > > > > > > > --- > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > diff --git a/lib/pdump/rte_pdump.h > > b/lib/pdump/rte_pdump.h > > > > > > > > > index 6efa0274f2..41c4b7800b 100644 > > > > > > > > > --- a/lib/pdump/rte_pdump.h > > > > > > > > > +++ b/lib/pdump/rte_pdump.h > > > > > > > > > @@ -13,8 +13,6 @@ > > > > > > > > > */ > > > > > > > > > > > > > > > > > > #include > > > > > > > > > -#include > > > > > > > > > -#include > > > > > > > > > #include > > > > > > > > > > > > > > > > > > #ifdef __cplusplus > > > > > > > > > > > > > > > > This header does use rte_mempool and rte_ring in > > > > rte_pdump_enable(). > > > > > > > > Not sure why IWYU thinks they should be removed. > > > > > > > > > > > > > > Because they are only used as pointer types, not as > > structures > > > > > > > themselves. > > > > > > > Normally in cases like this, I would put in just "struct > > > > rte_mempool;" > > > > > > > at > > > > > > > the top of the file rather than including a whole header just > > for > > > > one > > > > > > > structure. > > > > > > > > > > > > I don't think we should introduce such a hack! > > > > > > If a module uses something from a library, it makes sense to > > > > include the header file for the library. > > > > > > > > > > > > Putting in "struct rte_mempool;" is essentially copy-pasting > > from > > > > the library, although only a structure. What happens if the type > > > > changes or disappears, or depends on some #ifdef? It could have one > > > > type in some cases and another type in other cases - e.g. the > > atomic > > > > counters in the mbuf once had different types, depending on compile > > > > time flags. The copy-pasted code would not get fixed if the type > > > > evolved over time. > > > > > > > > > > By "struct rte_mempool;" I mean literally just that. All it does > > is > > > > > indicate that there is a structure defined somewhere else that > > will > > > > be used > > > > > via pointer in the file later on. > > > > > > Yes, I did understand that. Like a forward declaration, often used in > > structures referencing each other. > > > > > > > > There is no copy-pasting involved and the > > > > > reference does not need to change as the structure changes. > > > > > > I meant that the rte_mempool itself could change type, so it is no > > longer a structure. Then the "copy-pasted" forward declaration will > > allow the code to compile, not catching that the type has changed. > > > > > > The refcnt member of the mbuf structure changed over time from being > > a structure (specifically rte_atomic_t, which was a typedef) to being a > > simple uint16_t. So types changing over time does happen in the real > > world, also in DPDK. > > > > > > > If the type does change, then it will still be caught via compilation > > error, since the corresponding .c file will have to include the full > > mempool header to access the internals of the data structures. That > > will > > trigger a compilation failure on the function in the .c file, requiring > > the > > parameter type to change from e.g. struct to union. > > Overall, though, if a type does change, one would expect that a global > > search replace would be used throughout the whole codebase, so I > > consider > > the possibilities of problems here to be very, very remote. > > Thank you for elaborating, Bruce. > > Although I agree that the risk of problems is extremely low, I still prefer eliminating risks over reducing compile time. > > It boils down to different opinions about the cost/benefit analysis, and it seems that Stephen and you outnumber me, so I'll stop complaining about it. ;-) > In this case it probably doesn't matter that much, either way, and thanks for flagging issues with this! Hopefully my final word on this is that it can sometimes be more problematic than just compilation time. I've hit issues in the past when working on DPDK, where adding in a needed header include to another header, created an include loop that broke compilation, because one of the headers in the chain/loop had included another header just to get a reference to a structure half-way down the file. Ever since, I've had a strong dislike for including unnecessary headers, especially if it is just for a pointer to a struct. Regards, /Bruce