From: Jesper Dangaard Brouer <brouer@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
bpf@vger.kernel.org, Eric Dumazet <eric.dumazet@gmail.com>,
Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
brouer@redhat.com
Subject: Re: [PATCH net-next V1] net: adjust net_device layout for cacheline usage
Date: Fri, 29 Jan 2021 08:58:08 +0100 [thread overview]
Message-ID: <20210129085808.4e023d3f@carbon> (raw)
In-Reply-To: <2836dccc-faa9-3bb6-c4d5-dd60c75b275a@gmail.com>
On Thu, 28 Jan 2021 20:51:23 -0700
David Ahern <dsahern@gmail.com> wrote:
> On 1/26/21 10:39 AM, Jesper Dangaard Brouer wrote:
> > The current layout of net_device is not optimal for cacheline usage.
> >
> > The member adj_list.lower linked list is split between cacheline 2 and 3.
> > The ifindex is placed together with stats (struct net_device_stats),
> > although most modern drivers don't update this stats member.
> >
> > The members netdev_ops, mtu and hard_header_len are placed on three
> > different cachelines. These members are accessed for XDP redirect into
> > devmap, which were noticeably with perf tool. When not using the map
> > redirect variant (like TC-BPF does), then ifindex is also used, which is
> > placed on a separate fourth cacheline. These members are also accessed
> > during forwarding with regular network stack. The members priv_flags and
> > flags are on fast-path for network stack transmit path in __dev_queue_xmit
> > (currently located together with mtu cacheline).
> >
> > This patch creates a read mostly cacheline, with the purpose of keeping the
> > above mentioned members on the same cacheline.
> >
> > Some netdev_features_t members also becomes part of this cacheline, which is
> > on purpose, as function netif_skb_features() is on fast-path via
> > validate_xmit_skb().
>
> A long over due look at the organization of this struct. Do you have
> performance numbers for the XDP case?
Yes, my measurements are documented here:
https://github.com/xdp-project/xdp-project/blob/master/areas/core/xdp_redir01_net_device.org
Calc improvements of xdp_redirect_map on driver i40e:
* (1/12115061-1/12906785)*10^9 = 5.06 ns
* ((12906785/12115061)-1)*100 = 6.54%
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2021-01-29 8:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 17:39 [PATCH net-next V1] net: adjust net_device layout for cacheline usage Jesper Dangaard Brouer
2021-01-29 3:51 ` David Ahern
2021-01-29 7:58 ` Jesper Dangaard Brouer [this message]
[not found] ` <20210129114642.139cb7dc@carbon>
2021-01-29 19:35 ` Jakub Kicinski
2021-01-29 19:47 ` Eric Dumazet
2021-01-29 20:07 ` Jakub Kicinski
2021-02-12 15:57 ` Jesper Dangaard Brouer
2021-01-29 4:50 ` patchwork-bot+netdevbpf
[not found] ` <52835f1f-96e1-b36e-2631-1182649ac3a8@gmail.com>
[not found] ` <20210129150058.34e3a855@carbon>
2021-02-12 15:49 ` Jesper Dangaard Brouer
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=20210129085808.4e023d3f@carbon \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=borkmann@iogearbox.net \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--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).