From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>, netdev@vger.kernel.org
Subject: Re: [net-next.git 3/7] stmmac: review private structure fields
Date: Thu, 04 Apr 2013 08:11:34 +0200 [thread overview]
Message-ID: <515D1996.8030501@st.com> (raw)
In-Reply-To: <1365005352.2897.12.camel@bwh-desktop.uk.solarflarecom.com>
On 4/3/2013 6:09 PM, Ben Hutchings wrote:
> On Wed, 2013-04-03 at 09:33 +0200, Giuseppe CAVALLARO wrote:
>> On 4/3/2013 9:21 AM, Eric Dumazet wrote:
>>> On Wed, 2013-04-03 at 07:41 +0200, Giuseppe CAVALLARO wrote:
>>>> recently many new supports have been added in the stmmac driver w/o taking care
>>>> about where each new field had to be placed inside the private structure for
>>>> guaranteeing the best cache usage.
>>>> This is what I wanted in the beginning, so this patch reorganizes all the fields
>>>> in order to keep adjacent fields for cache effect.
>>>> I have also tried to optimize them by using pahole.
>>>>
>>>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>>>> ---
>>>> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 70 +++++++++++++-------------
>>>> 1 files changed, 35 insertions(+), 35 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
>>>> index 75f997b..8aa28c5 100644
>>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
>>>> @@ -35,36 +35,45 @@
>>>>
>>>> struct stmmac_priv {
>>>> /* Frequently used values are kept adjacent for cache effect */
>>>> - struct dma_desc *dma_tx ____cacheline_aligned; /* Basic TX desc */
>>>> - struct dma_extended_desc *dma_etx; /* Extended TX descriptor */
>>>> - dma_addr_t dma_tx_phy;
>>>> - struct sk_buff **tx_skbuff;
>>>> - dma_addr_t *tx_skbuff_dma;
>>>> + struct dma_extended_desc *dma_etx;
>>>> + struct dma_desc *dma_tx ____cacheline_aligned_in_smp;
>>>> + struct sk_buff **tx_skbuff ____cacheline_aligned_in_smp;
>>>
>>> dma_tx & tx_skbuff are readonly, why put them in separate cache lines ?
>>
>> I put tx_skbuff in a separate cache line because, when we use extended
>> descriptors, the driver works with dma_etx instead of dma_tx.
>> So my idea was to have both dma_etx, dma_tx and tx_skbuff aligned in
>> any case.
> [...]
>
> It's generally not that important to put fields at the beginning of a
> cache line. (If you've measured with typical systems using stmmac and
> found an advantage, then I accept that you have a good reason to do
> this. But that advantage is unlikely to be specific to SMP systems.)
That is the point. I had seen an improvement when testing on SH4
platforms if these pointers were at the beginning of a cache line.
> I would use ____cacheline_aligned_in_smp to separate fields that are
> likely to be changed on different CPUs, so that the cache line doesn't
> bounce between their caches. Fields that are rarely modified (such as
> these pointers), or are used together on the same CPU should be packed
> together into a small number of cache lines.
Thx Ben for this explanation. Let me do some other tests on SMP ARM.
I'll rework this patch trying to balance the "abuse" of
____cacheline_aligned_in_smp and the best performances (I can re-test
on ARM and SH4).
peppe
>
> Ben.
>
next prev parent reply other threads:[~2013-04-04 6:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 5:41 [net-next.git 1/7] stmmac: review napi gro support Giuseppe CAVALLARO
2013-04-03 5:41 ` [net-next.git 2/7] stmmac: review barriers Giuseppe CAVALLARO
2013-04-03 7:18 ` Eric Dumazet
2013-04-03 7:28 ` Giuseppe CAVALLARO
2013-04-03 8:51 ` Shiraz Hashim
2013-04-04 6:06 ` Giuseppe CAVALLARO
2013-04-04 15:08 ` Eric Dumazet
2013-04-03 14:02 ` Sergei Shtylyov
2013-04-03 5:41 ` [net-next.git 3/7] stmmac: review private structure fields Giuseppe CAVALLARO
2013-04-03 7:21 ` Eric Dumazet
2013-04-03 7:33 ` Giuseppe CAVALLARO
2013-04-03 16:09 ` Ben Hutchings
2013-04-04 6:11 ` Giuseppe CAVALLARO [this message]
2013-04-03 5:41 ` [net-next.git 4/7] stmmac: review driver documentation Giuseppe CAVALLARO
2013-04-03 5:41 ` [net-next.git 5/7] stmmac: improve/review and fix kernel-doc Giuseppe CAVALLARO
2013-04-03 5:41 ` [net-next.git 6/7] stmmac: code tidy-up Giuseppe CAVALLARO
2013-04-03 5:41 ` [net-next.git 7/7] stmmac: prefetch all dma_erx when use extend_desc Giuseppe CAVALLARO
2013-04-03 7:05 ` [net-next.git 1/7] stmmac: review napi gro support Eric Dumazet
2013-04-03 7:41 ` Giuseppe CAVALLARO
2013-04-03 13:39 ` Eric Dumazet
2013-04-04 6:16 ` Giuseppe CAVALLARO
2013-04-03 16:01 ` Ben Hutchings
2013-04-04 6:20 ` Giuseppe CAVALLARO
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515D1996.8030501@st.com \
--to=peppe.cavallaro@st.com \
--cc=bhutchings@solarflare.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).