From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: lib: include rte_memory.h for __rte_cache_aligned Date: Thu, 11 Dec 2014 01:51:01 +0100 Message-ID: <1519285.2rmHEkrl95@xps13> References: <1415381289-43291-1-git-send-email-jyu@vmware.com> <5486B87E.5010404@6wind.com> <20141209152204.GD28871@hmsreliant.think-freely.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Jia Yu Return-path: In-Reply-To: <20141209152204.GD28871-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 2014-12-09 10:22, Neil Horman: > On Tue, Dec 09, 2014 at 09:53:18AM +0100, Olivier MATZ wrote: > > On 12/08/2014 04:04 PM, Neil Horman wrote: > > >On Fri, Nov 07, 2014 at 09:28:09AM -0800, Jia Yu wrote: > > >>Include rte_memory.h for lib files that use __rte_cache_aligned > > >>attribute. > > >> > > >>Signed-off-by: Jia Yu > > >> > > >Why? I presume there was a build break or something. Please repost with a > > >changelog that details what this patch is for. > > >Neil > > > > I don't know if Yu's issue was the same, but I had a very "fun" issue > > with __rte_cache_aligned in my application. Consider the following code: > > > > struct per_core_foo { > > ... > > } __rte_cache_aligned; > > > > struct global_foo { > > struct per_core_foo foo[RTE_MAX_CORE]; > > }; > > > > If __rte_cache_aligned is not defined (rte_memory.h is not included), > > the code compiles but the structure is not aligned... it defines the > > structure and creates a global variable called __rte_cache_aligned. > > And this can lead to really bad things if this code is in a .h that > > is included by files that may or may not include rte_memory.h > > > > I have no idea about how we could prevent this issue, except using > > __attribute__((aligned(CACHE_LINE))) instead of __rte_cache_aligned. > > > > Anyway this could probably explain the willing to include rte_memory.h > > everywhere. > > > > Regards, > > Olivier > > So, that is a great explination, and would be good to have in the changelog. Acked-by: Thomas Monjalon Applied with Olivier's explanation. Thanks -- Thomas