DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jia Yu <jyu@vmware.com>
To: Neil Horman <nhorman@tuxdriver.com>,
	Olivier MATZ <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] lib: include rte_memory.h for __rte_cache_aligned
Date: Wed, 10 Dec 2014 19:09:03 +0000
Message-ID: <D0ADD64A.2E3F8%jyu@vmware.com> (raw)
In-Reply-To: <20141209152204.GD28871@hmsreliant.think-freely.org>

Hi Neil,

Moving __rte_cache_aligned right after struct keyword will help. On the
other hand, enforcing this rule for existing (100+) and future definitions
will be difficult. It¹s clearer and a good practice to include header file


On 12/9/14, 7:22 AM, "Neil Horman" <nhorman@tuxdriver.com> wrote:

>On Tue, Dec 09, 2014 at 09:53:18AM +0100, Olivier MATZ 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@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
>So, that is a great explination, and would be good to have in the
>Also, to avoid the problem that you describe, while its preferred to have
>it at
>the end of a struct, you can also put the alignment attribute right after
>struct keyword in gcc:
>That seems like it would solve the problem going forward.

  reply	other threads:[~2014-12-10 19:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 17:28 [dpdk-dev] [PATCH] " Jia Yu
2014-11-10  9:46 ` Thomas Monjalon
2014-11-17 19:07   ` Jia Yu
2014-12-08 15:04 ` [dpdk-dev] " Neil Horman
2014-12-09  8:53   ` Olivier MATZ
2014-12-09  9:11     ` Jia Yu
2014-12-09 15:22     ` Neil Horman
2014-12-10 19:09       ` Jia Yu [this message]
2014-12-11  0:28         ` Neil Horman
2014-12-11  0:36           ` Thomas Monjalon
2014-12-11 14:17             ` Neil Horman
2014-12-11 21:14               ` Thomas Monjalon
2014-12-11  0:51       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D0ADD64A.2E3F8%jyu@vmware.com \
    --to=jyu@vmware.com \
    --cc=dev@dpdk.org \
    --cc=nhorman@tuxdriver.com \
    --cc=olivier.matz@6wind.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git