Yes, Olivier?s observation is consistent with ours. Compilation didn?t complain if rte_memory.h is not included.
Currently, the lib files indirectly included rte_mbuf.h or rte_mempool.h. These two header files already included rte_memory.h. Therefore without this patch, things still work (as validated by parole). For good practice, it?s better to explicitly include rte_memory.h to avoid the problem. Thanks, Jia On 12/9/14, 12:53 AM, "Olivier MATZ" <olivier.matz at 6wind.com> wrote: >Hi Neil, > >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 <jyu at vmware.com> >>> >> 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 >