From: Claudiu Manoil <claudiu.manoil@freescale•com>
To: Paul Gortmaker <paul.gortmaker@windriver•com>
Cc: <netdev@vger•kernel.org>, "David S. Miller" <davem@davemloft•net>
Subject: Re: [PATCH net-next 2/5] gianfar: Cleanup and optimize struct gfar_private
Date: Tue, 12 Feb 2013 17:58:27 +0200 [thread overview]
Message-ID: <511A66A3.7040704@freescale.com> (raw)
In-Reply-To: <511A5BA3.4020306@windriver.com>
On 2/12/2013 5:11 PM, Paul Gortmaker wrote:
> On 13-02-12 07:47 AM, Claudiu Manoil wrote:
>> * group run-time critical fields within the 1st cacheline
>> followed by the tx|rx_queue reference arrays and the interrupt
>> group instances (gfargrp) (all cacheline aligned)
>> * change 'padding' from unsigned short to u16
>> * clear 20+ byte memory hole
>
> Per prev. mail, it gets harder to see which change is where,
> when they are all lumped together like this. For example, it
> wasn't obvious to me where the 20 byte hole was. Also, it
> doesn't look like you changed the padding, but rather instead
> totally re-purposed it, leaving no alignment padding after the
> uchar bitfields (where it was originally).
>
> P.
The 20 byte hole was here:
struct gfar_private {
unsigned int num_tx_queues;
unsigned int num_rx_queues;
unsigned int num_grps;
unsigned int mode;
unsigned int total_tx_ring_size;
unsigned int total_rx_ring_size;
struct device_node * node;
struct net_device * ndev;
/* --- cacheline 1 boundary (32 bytes) --- */
struct platform_device * ofdev;
enum gfar_errata errata;
/* XXX 24 bytes hole, try to pack */
/* --- cacheline 2 boundary (64 bytes) --- */
struct gfar_priv_grp gfargrp[2];
At the end of the patch series the first cacheline is without holes.
Please note that the re-grouping of members and their order is most
important. For instance why keep in the first cacheline something
as unimportant as total_rx_ring_size? Members like rx_buffer_size,
or padding, or even errata, are critical however for the fast path.
Rx processing (gfar_poll + clean_rx_ring) is the bottleneck here,
keeping the CPU to 100%. So the main goal is to optimize this path,
including memory access/cache optimizations. For instance, better
results were obtained by inverting rx|tx_queue[] with gfargrp[], originally:
/* --- cacheline 1 boundary (32 bytes) --- */
struct gfar_priv_tx_q * tx_queue[8]; /* 32 32 */
/* --- cacheline 2 boundary (64 bytes) --- */
struct gfar_priv_rx_q * rx_queue[8]; /* 64 32 */
/* --- cacheline 3 boundary (96 bytes) --- */
struct gfar_priv_grp gfargrp[2]; /* 96 192 */
The uchar bitfields are unimportant here (used at "init time"), and
they take 4 bytes including padding anyway. So whether it's uchar or
uint, it's the same, maybe better left uchar to discourage the abuse
of these bitfields. (A 2-3byte hole here doesn't change anything
to the whole structure size, which is padded to be at least a 32B
multiple.)
Thanks,
Claudiu
next prev parent reply other threads:[~2013-02-12 15:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-12 12:47 [PATCH net-next 1/5] gianfar: Cleanup device refs in gfar_private Claudiu Manoil
2013-02-12 12:47 ` [PATCH net-next 2/5] gianfar: Cleanup and optimize struct gfar_private Claudiu Manoil
2013-02-12 12:47 ` [PATCH net-next 3/5] gianfar: GRO_DROP is unlikely Claudiu Manoil
2013-02-12 12:47 ` [PATCH net-next 4/5] gianfar: Remove wrong buffer size conditioning to VLAN h/w offload Claudiu Manoil
2013-02-12 12:47 ` [PATCH net-next 5/5] gianfar: Fix and cleanup Rx FCB handling Claudiu Manoil
2013-02-12 17:19 ` Paul Gortmaker
2013-02-13 11:34 ` Claudiu Manoil
2013-02-13 14:32 ` Paul Gortmaker
2013-02-12 16:30 ` [PATCH net-next 3/5] gianfar: GRO_DROP is unlikely Paul Gortmaker
2013-02-12 16:47 ` Eric Dumazet
2013-02-12 17:05 ` Claudiu Manoil
2013-02-12 15:11 ` [PATCH net-next 2/5] gianfar: Cleanup and optimize struct gfar_private Paul Gortmaker
2013-02-12 15:58 ` Claudiu Manoil [this message]
2013-02-12 16:49 ` Paul Gortmaker
2013-02-12 14:54 ` [PATCH net-next 1/5] gianfar: Cleanup device refs in gfar_private Paul Gortmaker
2013-02-12 17:14 ` Claudiu Manoil
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=511A66A3.7040704@freescale.com \
--to=claudiu.manoil@freescale$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=paul.gortmaker@windriver$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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