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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 2E6BCC2D0E4 for ; Tue, 24 Nov 2020 21:50:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D200F20866 for ; Tue, 24 Nov 2020 21:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731568AbgKXVu0 (ORCPT ); Tue, 24 Nov 2020 16:50:26 -0500 Received: from www62.your-server.de ([213.133.104.62]:36268 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731557AbgKXVu0 (ORCPT ); Tue, 24 Nov 2020 16:50:26 -0500 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1khgCd-0006kk-6H; Tue, 24 Nov 2020 22:50:23 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khgCc-000V64-Ub; Tue, 24 Nov 2020 22:50:22 +0100 Subject: Re: [PATCH bpf v2] net, xsk: Avoid taking multiple skbuff references To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , ast@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , jonathan.lemon@gmail.com, yhs@fb.com, weqaar.janjua@gmail.com, magnus.karlsson@intel.com, weqaar.a.janjua@intel.com References: <20201123175600.146255-1-bjorn.topel@gmail.com> From: Daniel Borkmann Message-ID: Date: Tue, 24 Nov 2020 22:50:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20201123175600.146255-1-bjorn.topel@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/25998/Tue Nov 24 14:16:50 2020) Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 11/23/20 6:56 PM, Björn Töpel wrote: > From: Björn Töpel > > Commit 642e450b6b59 ("xsk: Do not discard packet when NETDEV_TX_BUSY") > addressed the problem that packets were discarded from the Tx AF_XDP > ring, when the driver returned NETDEV_TX_BUSY. Part of the fix was > bumping the skbuff reference count, so that the buffer would not be > freed by dev_direct_xmit(). A reference count larger than one means > that the skbuff is "shared", which is not the case. > > If the "shared" skbuff is sent to the generic XDP receive path, > netif_receive_generic_xdp(), and pskb_expand_head() is entered the > BUG_ON(skb_shared(skb)) will trigger. > > This patch adds a variant to dev_direct_xmit(), __dev_direct_xmit(), > where a user can select the skbuff free policy. This allows AF_XDP to > avoid bumping the reference count, but still keep the NETDEV_TX_BUSY > behavior. > > Reported-by: Yonghong Song > Fixes: 642e450b6b59 ("xsk: Do not discard packet when NETDEV_TX_BUSY") > Signed-off-by: Björn Töpel Yeah looks better! Applied, thanks!