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.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 D0E3EC433DB for ; Thu, 4 Feb 2021 00:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8964364F67 for ; Thu, 4 Feb 2021 00:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233522AbhBDAPl (ORCPT ); Wed, 3 Feb 2021 19:15:41 -0500 Received: from www62.your-server.de ([213.133.104.62]:60410 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231817AbhBDAPk (ORCPT ); Wed, 3 Feb 2021 19:15:40 -0500 Received: from sslproxy01.your-server.de ([78.46.139.224]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1l7SIT-0008bJ-Bm; Thu, 04 Feb 2021 01:14:57 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7SIT-000EEW-3V; Thu, 04 Feb 2021 01:14:57 +0100 Subject: Re: [PATCH v3 bpf-next] net: veth: alloc skb in bulk for ndo_xdp_xmit To: Lorenzo Bianconi , bpf@vger.kernel.org Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, toshiaki.makita1@gmail.com, lorenzo.bianconi@redhat.com, brouer@redhat.com, toke@redhat.com References: From: Daniel Borkmann Message-ID: Date: Thu, 4 Feb 2021 01:14:56 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/26069/Wed Feb 3 13:23:20 2021) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/29/21 11:04 PM, Lorenzo Bianconi wrote: > Split ndo_xdp_xmit and ndo_start_xmit use cases in veth_xdp_rcv routine > in order to alloc skbs in bulk for XDP_PASS verdict. > Introduce xdp_alloc_skb_bulk utility routine to alloc skb bulk list. > The proposed approach has been tested in the following scenario: [...] > diff --git a/net/core/xdp.c b/net/core/xdp.c > index 0d2630a35c3e..05354976c1fc 100644 > --- a/net/core/xdp.c > +++ b/net/core/xdp.c > @@ -514,6 +514,17 @@ void xdp_warn(const char *msg, const char *func, const int line) > }; > EXPORT_SYMBOL_GPL(xdp_warn); > > +int xdp_alloc_skb_bulk(void **skbs, int n_skb, gfp_t gfp) > +{ > + n_skb = kmem_cache_alloc_bulk(skbuff_head_cache, gfp, > + n_skb, skbs); Applied, but one question I was wondering about when reading the kmem_cache_alloc_bulk() code was whether it would be safer to simply test for kmem_cache_alloc_bulk() != n_skb given it could potentially in future also alloc less objs than requested, but I presume if such extension would get implemented then call-sites might need to indicate 'best effort' somehow via flag instead (to handle < n_skb case). Either way all current callers assume for != 0 that everything went well, so lgtm. > + if (unlikely(!n_skb)) > + return -ENOMEM; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(xdp_alloc_skb_bulk); > + > struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf, > struct sk_buff *skb, > struct net_device *dev) >