From patchwork Wed Mar 1 16:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 62977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3715891wrd; Wed, 1 Mar 2023 08:06:12 -0800 (PST) X-Google-Smtp-Source: AK7set86rcynl+jehBuebtXkHJp8KBGXiu+xV6H142q4l7ir0qZi0I9HZEBCp0ulGXc88juQfiVp X-Received: by 2002:a17:907:7f1e:b0:8b1:76dd:f5ef with SMTP id qf30-20020a1709077f1e00b008b176ddf5efmr9428083ejc.5.1677686771977; Wed, 01 Mar 2023 08:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677686771; cv=none; d=google.com; s=arc-20160816; b=BMWqsrSvtQo8wUKtXnx8d/soF6A9oVed+wYub94W88uc28r/BfMlKOm5S9WzvOnADg aqZ4n3QBEZVKNHN1b+3PeAmUuTHz/8p4144N95YbF34Hv+fpLx6Ov+lDCOcOTrJCqvJF 0ZVv/c0FGMPgdoKHBu7kqJiZipgcgkU+KaV0CY39ognXcXDiIdWFWsJvX/C406e3lCrY u6e9sFYGT1P45Kl8IQ7zeY/QGkZQ/7mG5wf6ULmuVR9t5oZV2M/O1+9RiG4CYV4Ou0CG +1muB5BvgR65upe65D6nNJjv0JBqhuvfKCFqma6Ivc4KzDxUI59nLL28LZobBs00Zrbj 9Q+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sNYJNKG3NTTVTuj9+moiASnwPzyA0oRP5p905skLJp4=; b=qJkV4nowVd7r4ZwF5r88GXwvzywtMM6rB30kyPr6MxYMglC4OMxKlVoNUPWPLRqdBb 3ZPNUDp0AIcjnKRWdBhSjb+arrgk8RuhW1HppWBp+BIZbb1FrPqylGGNX6f9U+LW8sG9 enujVE3dkkkQxFt5BDVUU+kMc0oN19VxajP268ft8WNlsgOhRB/JLDtoWSlaNQogSiwC bBBmnxEfT0ZyZ1y2fGC4BxZBUuRas49glUdqpIz0aAu4N10RT2ITfcMacjrgp5uXA3+J k5R1c+cL0argIl+0M4p6Ik911ia2AVtl1dOLX0SzK7MQxmznIPgs9k8EXmLppO39Gxyk AL1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Pvdlb2x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a1709060e0800b008b31e35479csi14276533eji.639.2023.03.01.08.05.49; Wed, 01 Mar 2023 08:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Pvdlb2x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbjCAQEV (ORCPT + 99 others); Wed, 1 Mar 2023 11:04:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbjCAQES (ORCPT ); Wed, 1 Mar 2023 11:04:18 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9167392AD; Wed, 1 Mar 2023 08:04:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677686658; x=1709222658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7yX/2MWa8HFobhzC8fLR29+A0vGAbF/zFcR/r79lMZo=; b=Pvdlb2x9hASV9XkK5grxk7vJnZa2qqmsyeh9Rtpk09dQaPTwj+yrMuqj pdX/YY3ouFj3nCmsGkD3HKy8Q81gjVBfr83gFpmpw/Dfmu8CtJl/0dvhZ pCro3ne5OzCJowbbflEP86HEQkaqEdFs/EFb5X83oQlDiE8pGjon6+TrH /ymHZFP8nd8HBDJrxcsN+NyNSN7pdRORpGQVjJ/HwEpglneKvKIkXghmz Aw6SxDVX0QJLY0jNqTyfEWBbjdtYolRWJLv/V6EsqXoLU+nsX54iDcyEK pus2SpGyX1giEC+8mf6gdHWAdoF3SOsm7N3CSBaOMnlK/h5Tb0iQEkc+0 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="322709885" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="322709885" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 08:04:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="848686060" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="848686060" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga005.jf.intel.com with ESMTP; 01 Mar 2023 08:04:12 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 0844B36C08; Wed, 1 Mar 2023 16:04:11 +0000 (GMT) From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau Cc: Alexander Lobakin , Maciej Fijalkowski , Larysa Zaremba , =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= , Song Liu , Jesper Dangaard Brouer , Jakub Kicinski , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v1 1/2] xdp: recycle Page Pool backed skbs built from XDP frames Date: Wed, 1 Mar 2023 17:03:14 +0100 Message-Id: <20230301160315.1022488-2-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230301160315.1022488-1-aleksander.lobakin@intel.com> References: <20230301160315.1022488-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759182048609422746?= X-GMAIL-MSGID: =?utf-8?q?1759182084399229574?= __xdp_build_skb_from_frame() state(d): /* Until page_pool get SKB return path, release DMA here */ Page Pool got skb pages recycling in April 2021, but missed this function. xdp_release_frame() is relevant only for Page Pool backed frames and it detaches the page from the corresponding Pool in order to make it freeable via page_frag_free(). It can instead just mark the output skb as eligible for recycling if the frame is backed by a PP. No change for other memory model types (the same condition check as before). cpumap redirect and veth on Page Pool drivers now become zero-alloc (or almost). Signed-off-by: Alexander Lobakin --- net/core/xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/xdp.c b/net/core/xdp.c index 8c92fc553317..a2237cfca8e9 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -658,8 +658,8 @@ struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf, * - RX ring dev queue index (skb_record_rx_queue) */ - /* Until page_pool get SKB return path, release DMA here */ - xdp_release_frame(xdpf); + if (xdpf->mem.type == MEM_TYPE_PAGE_POOL) + skb_mark_for_recycle(skb); /* Allow SKB to reuse area used by xdp_frame */ xdp_scrub_frame(xdpf); From patchwork Wed Mar 1 16:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 62978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3716355wrd; Wed, 1 Mar 2023 08:06:42 -0800 (PST) X-Google-Smtp-Source: AK7set/YcslNMZ8A9tGUfGFBSL/pzDFxDZVUBjJwgTPkaaJmT4bj1aAsS3/RWhF3V38jee+b4+pO X-Received: by 2002:a17:906:101b:b0:8b2:7564:dfd7 with SMTP id 27-20020a170906101b00b008b27564dfd7mr8210922ejm.61.1677686802780; Wed, 01 Mar 2023 08:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677686802; cv=none; d=google.com; s=arc-20160816; b=dlJZE1jFSrk+fXlK5etmLgXQYLp4M0S92YPTmOSz+bB05qOomKYO0V6FAEjQgSEzMO 6HWKKzAjEQxYlxGSF0zfH2ok5+q+xOE5ckVE8f7NnkWtJ6INYSUooll7Qalq5dj6mjag btf627xCHbunrhT3yxFjLt8Zw6cdV3O/+ENK3oQvuzzbSmEEHS+diOIcQKB9NSj3MFJ4 rZruKBOKQbnokMqQansSx127wHIEfiK6SIdCz8nxK5+d5xSdJqoiwsq+/Se6ZtLAcmI+ OB9V2VzGWxe3b6+2Rq/tmzCl7s1lOJcVKPmy0R4ARbjWmQMOUxOCkAfzSlS9fvDSkkBz TOTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AdlRLCl39yZyLSvWF1g7etRTM6IKd70KhniSq0/vjqw=; b=SCeFWQMLaK08cKTVSXeaR8aJbgEA5A/u97RjJxhKd+k7WeiiVkz38Y/OYix1HFqDzm 6cmWo1fLNUrkRc88IgKqpcOr2tGnOSTWpUaL5lu/SCTO/ft4+Dq+INOISJEKYxPNg6IF qUqQh6nDaxIwkNZGSawVNTkWxkskpLnIRiMO0zP5TNm7nfMlH6UgPEyf2JA8gK0iIzT5 riBitE3nkd5M0cDbkLCeQPfiALPqArOQ/msXKsbHHLcy0XtbgBTLlsCwmv9vXPvgSB6s 5vduTdHmK0Iep+7O3dFhxFByx1yOkVn/BV7aeldrrAT7v7pmPvL45vXeYEPpGOc3uGKy QihQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MDkw6bfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a170906855300b008dd8c164de1si14767622ejy.541.2023.03.01.08.06.17; Wed, 01 Mar 2023 08:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MDkw6bfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjCAQEY (ORCPT + 99 others); Wed, 1 Mar 2023 11:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbjCAQET (ORCPT ); Wed, 1 Mar 2023 11:04:19 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0704738029; Wed, 1 Mar 2023 08:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677686659; x=1709222659; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h7oaQxLcaEUZNhhmO/EwniWo3ZoJc2fUHo/bmddoeLQ=; b=MDkw6bfhUTFwkZjicAgMbdD2hLJE9u/a98k85w8ZS272VSkqF/a/1WRF mLvP4yVj2LC88qbZCWY0w6dyV9Kkxmox25SU+UQp/ZGIWwP+tRhiYiyV0 WunZuBY6Vhxr8qErtxppZR+PcygagMXzQU9YPBufaZOXDoGKJ5Xl87/Xz ItCmBLifqlKxcY1m4OYwhJwvDF6ogQ7f2EuB1lD6FuL8UChznIIai5G/w lbzACjS445/7la6Caa8jYiJY/L9qrDyY01Q1SrZCfJ3b7su6q0QDQbAoz 4UZi/M+38sqwMzcxnVj5DJD8XKVDuhwDbiDI2bV5iQ2EZw07G6BYKMjSL Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="322709904" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="322709904" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 08:04:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10636"; a="848686068" X-IronPort-AV: E=Sophos;i="5.98,225,1673942400"; d="scan'208";a="848686068" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orsmga005.jf.intel.com with ESMTP; 01 Mar 2023 08:04:13 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail002.ir.intel.com (Postfix) with ESMTP id CD69F36C09; Wed, 1 Mar 2023 16:04:12 +0000 (GMT) From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau Cc: Alexander Lobakin , Maciej Fijalkowski , Larysa Zaremba , =?utf-8?q?Toke_H=C3=B8iland-J?= =?utf-8?q?=C3=B8rgensen?= , Song Liu , Jesper Dangaard Brouer , Jakub Kicinski , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v1 2/2] xdp: remove unused {__,}xdp_release_frame() Date: Wed, 1 Mar 2023 17:03:15 +0100 Message-Id: <20230301160315.1022488-3-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230301160315.1022488-1-aleksander.lobakin@intel.com> References: <20230301160315.1022488-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759182116666046191?= X-GMAIL-MSGID: =?utf-8?q?1759182116666046191?= __xdp_build_skb_from_frame() was the last user of {__,}xdp_release_frame(), which detaches pages from the Page Pool. All the consumers now recycle Page Pool skbs and page, except mlx5, stmmac and tsnep drivers, which use page_pool_release_page() directly (might change one day). It's safe to assume this functionality is not needed anymore and can be removed (in favor of recycling). Signed-off-by: Alexander Lobakin --- include/net/xdp.h | 29 ----------------------------- net/core/xdp.c | 15 --------------- 2 files changed, 44 deletions(-) diff --git a/include/net/xdp.h b/include/net/xdp.h index d517bfac937b..5393b3ebe56e 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -317,35 +317,6 @@ void xdp_flush_frame_bulk(struct xdp_frame_bulk *bq); void xdp_return_frame_bulk(struct xdp_frame *xdpf, struct xdp_frame_bulk *bq); -/* When sending xdp_frame into the network stack, then there is no - * return point callback, which is needed to release e.g. DMA-mapping - * resources with page_pool. Thus, have explicit function to release - * frame resources. - */ -void __xdp_release_frame(void *data, struct xdp_mem_info *mem); -static inline void xdp_release_frame(struct xdp_frame *xdpf) -{ - struct xdp_mem_info *mem = &xdpf->mem; - struct skb_shared_info *sinfo; - int i; - - /* Curr only page_pool needs this */ - if (mem->type != MEM_TYPE_PAGE_POOL) - return; - - if (likely(!xdp_frame_has_frags(xdpf))) - goto out; - - sinfo = xdp_get_shared_info_from_frame(xdpf); - for (i = 0; i < sinfo->nr_frags; i++) { - struct page *page = skb_frag_page(&sinfo->frags[i]); - - __xdp_release_frame(page_address(page), mem); - } -out: - __xdp_release_frame(xdpf->data, mem); -} - static __always_inline unsigned int xdp_get_frame_len(struct xdp_frame *xdpf) { struct skb_shared_info *sinfo; diff --git a/net/core/xdp.c b/net/core/xdp.c index a2237cfca8e9..8d3ad315f18d 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -531,21 +531,6 @@ void xdp_return_buff(struct xdp_buff *xdp) } EXPORT_SYMBOL_GPL(xdp_return_buff); -/* Only called for MEM_TYPE_PAGE_POOL see xdp.h */ -void __xdp_release_frame(void *data, struct xdp_mem_info *mem) -{ - struct xdp_mem_allocator *xa; - struct page *page; - - rcu_read_lock(); - xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params); - page = virt_to_head_page(data); - if (xa) - page_pool_release_page(xa->page_pool, page); - rcu_read_unlock(); -} -EXPORT_SYMBOL_GPL(__xdp_release_frame); - void xdp_attachment_setup(struct xdp_attachment_info *info, struct netdev_bpf *bpf) {