From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2476CC55179 for ; Fri, 23 Oct 2020 00:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6F6324650 for ; Fri, 23 Oct 2020 00:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603413896; bh=P801yupGfVJZpJBFR3gSGi8IVI4N2T8jCC9UpMeYlcU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=2JKzrkk+bHbS213wVWD49dNwR0Rb9heqyqAeUbRKN5MX1t2smQxdwBOnzGuLAvb2x LPv/Cga/1dO6AkTsIxUznE+TjlqCPmgI8z/SesTTuvWd7CByVq4YmNC/yuGBKIQzOZ zFR8bdWsVpztfho9neoj/9wEZlJ3RfqQwdhhVCYA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S374111AbgJWAoy (ORCPT ); Thu, 22 Oct 2020 20:44:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374101AbgJWAoy (ORCPT ); Thu, 22 Oct 2020 20:44:54 -0400 Received: from kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net (unknown [163.114.132.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0F7421531; Fri, 23 Oct 2020 00:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603413893; bh=P801yupGfVJZpJBFR3gSGi8IVI4N2T8jCC9UpMeYlcU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RCpc0n0ynyU9G0HiDO1pxAr1GSVz8bTo+B7+WpVhG9/rbaSTsDV/6GS+1s0PKqRTz TsaEQjrYU2rQRy1HEriSjWlzH2E6ZKUElVXmVnA0FBxk5nyBaN/1PPNziuBHN8UxGm rx1wYWPuMpNxbQwIRyvvHur2Aw8KNqNDRx7WApwI= Date: Thu, 22 Oct 2020 17:44:51 -0700 From: Jakub Kicinski To: Xie He Cc: "David S. Miller" , Linux Kernel Network Developers , LKML , Neil Horman , John Fastabend , Jesper Dangaard Brouer Subject: Re: [PATCH net RFC] net: Clear IFF_TX_SKB_SHARING for all Ethernet devices using skb_padto Message-ID: <20201022174451.1cd858ae@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> In-Reply-To: References: <20201022072814.91560-1-xie.he.0141@gmail.com> <20201022082239.2ae23264@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 22 Oct 2020 12:59:45 -0700 Xie He wrote: > On Thu, Oct 22, 2020 at 8:22 AM Jakub Kicinski 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?