netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Xie He <xie.he.0141@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Neil Horman <nhorman@tuxdriver.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Jesper Dangaard Brouer <hawk@kernel.org>
Subject: Re: [PATCH net RFC] net: Clear IFF_TX_SKB_SHARING for all Ethernet devices using skb_padto
Date: Thu, 22 Oct 2020 17:44:51 -0700	[thread overview]
Message-ID: <20201022174451.1cd858ae@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> (raw)
In-Reply-To: <CAJht_EM638CQDb5opnVxfQ81Z2U9hGZbnE581RFZrAQvenn+qQ@mail.gmail.com>

On Thu, 22 Oct 2020 12:59:45 -0700 Xie He wrote:
> On Thu, Oct 22, 2020 at 8:22 AM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > Are most of these drivers using skb_padto()? Is that the reason they
> > can't be sharing the SKB?  
> 
> Yes, I think if a driver calls skb_pad / skb_padto / skb_put_padto /
> eth_skb_pad, the driver can't accept shared skbs because it may modify
> the skbs.
> 
> > I think the IFF_TX_SKB_SHARING flag is only used by pktgen, so perhaps
> > we can make sure pktgen doesn't generate skbs < dev->min_mtu, and then
> > the drivers won't pad?  
> 
> Yes, I see a lot of drivers just want to pad the skb to ETH_ZLEN, or
> just call eth_skb_pad. In this case, requiring the shared skb to be at
> least dev->min_mtu long can solve the problem for these drivers.
> 
> But I also see some drivers that want to pad the skb to a strange
> length, and don't set their special min_mtu to match this length. For
> example:
> 
> drivers/net/ethernet/packetengines/yellowfin.c wants to pad the skb to
> a dynamically calculated value.
> 
> drivers/net/ethernet/ti/cpsw.c, cpsw_new.c and tlan.c want to pad the
> skb to macro defined values.
> 
> drivers/net/ethernet/intel/iavf/iavf_txrx.c wants to pad the skb to
> IAVF_MIN_TX_LEN (17).
> 
> drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c wants to pad the skb to 17.

Hm, I see, that would be a slight loss of functionality if we started
requiring 64B, for example, while the driver could in practice xmit
17B frames (would matter only to VFs, but nonetheless).

> Another solution I can think of is to add a "skb_shared" check to
> "__skb_pad", so that if __skb_pad encounters a shared skb, it just
> returns an error. The driver would think this is a memory allocation
> failure. This way we can ensure shared skbs are not modified.

I'm not sure if we want to be adding checks to __skb_pad() to handle
what's effectively a pktgen specific condition.

We could create a new field in struct netdevice for min_frame_len, but I
think your patch is the simplest solution. Let's see if anyone objects.

BTW it seems like there is more drivers which will need the flag
cleared, e.g. drivers/net/ethernet/broadcom/bnxt/bnxt.c?

  reply	other threads:[~2020-10-23  0:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22  7:28 [PATCH net RFC] net: Clear IFF_TX_SKB_SHARING for all Ethernet devices using skb_padto Xie He
2020-10-22  7:46 ` Xie He
2020-10-22 15:22   ` Jakub Kicinski
2020-10-22 19:59     ` Xie He
2020-10-23  0:44       ` Jakub Kicinski [this message]
2020-10-23  1:56         ` Xie He
2020-10-23  2:25           ` Xie He
2020-10-23 17:31             ` Jakub Kicinski

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=20201022174451.1cd858ae@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=xie.he.0141@gmail.com \
    /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).