From patchwork Wed Nov 29 11:23:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Chen X-Patchwork-Id: 13472667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CA10C4167B for ; Wed, 29 Nov 2023 11:24:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4D196B031C; Wed, 29 Nov 2023 06:24:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FD136B0374; Wed, 29 Nov 2023 06:24:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4CE6B03B3; Wed, 29 Nov 2023 06:24:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7A43B6B031C for ; Wed, 29 Nov 2023 06:24:30 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 535541C0317 for ; Wed, 29 Nov 2023 11:24:30 +0000 (UTC) X-FDA: 81510758700.24.868F2DE Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf11.hostedemail.com (Postfix) with ESMTP id 72BDF40011 for ; Wed, 29 Nov 2023 11:24:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XZn0Oanu; spf=pass (imf11.hostedemail.com: domain of liangchen.linux@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=liangchen.linux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701257068; a=rsa-sha256; cv=none; b=OwOx/q+drfvzC0Y2T0FAwCc5AQ523MqJnEVEiUf3BHJOmSqqK6Bw5fY2d21s+hEuACVp0o ne+tkZrvFNjj0WiJHaOdwUAZ7UqGlzofML6DeXUW7Fg9Xl3IVUOEcoLk2JNakq8OM2Dt3n qIGhdmvtQmyi24nwGPW9i9Lr0YIiBZw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XZn0Oanu; spf=pass (imf11.hostedemail.com: domain of liangchen.linux@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=liangchen.linux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701257068; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EJmCJbg2unIrLNyB6mMQhrpmPKGl/tPs30r44BnRYC8=; b=PpTb1Uk5h2zNbJBq3f+aOLGv94ulp6XvbiFGzbwVkNYdQBFhcshHeI5twf6MOiR0F83tmz IWH0YfB9ScAMebeUxTKXFKa9DB+cXTQO8Rh/nlfBQEM+Qokg8BqXGfYKIxb4LDkG4eogp1 vgJZUz5edwEZsXn6nxZ05Z7u3NxtuZQ= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1cfc34b6890so6142245ad.1 for ; Wed, 29 Nov 2023 03:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701257067; x=1701861867; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EJmCJbg2unIrLNyB6mMQhrpmPKGl/tPs30r44BnRYC8=; b=XZn0Oanu3xwrll2uxe4+jF2Tf882KNoxogzOpPnZU3QN962V0930gPSVTcgtf26+9+ tJ5ohg/fycxw44kAz+3+KhjgUrIDxn5NG4LtI/PspgwQwg53OJcnc7gSuYpu6vfXzWjR 6YtQ+icCjgu8Vnhkczx5fEyUA24GuJSHP9U4P1Q0X+0qSxby0cFSkdD157eF4f1J7N5p 28SK+tVXwUaJNSTVmk8pzXfx4Ge+Io7aKmkWvPpBEAfxn2pf7POBcpnYmP/okSJQRG/s 6/VVY/spNr1UpxhwKYcJtmTRTa6zIHVWMExtELeUp8CFLEsirMvCFLyg+WxpPB6Cm0r6 OFnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701257067; x=1701861867; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EJmCJbg2unIrLNyB6mMQhrpmPKGl/tPs30r44BnRYC8=; b=Ns0ov/X8b0kPNIM3bvi1wWvr5E6jx3jxrSoKV5hJz8GYOM3VLu6QPotztjjf/YUWXP jaSicjwusTUHg3xT0GZk9lpQC/LjrKKrAJR/qVvA7VIY1RF6FmvqihE/jY21/sk8X+7g Uh+P32cjJMhLoN22GuIPbeDNwLGN7mtvG3+FZG46k8OrINY6cH0jbJlHcrP59qUTBc+P 6qd2KTkLWSvwU8cccZcEIv6lqPbhrGMNY9fDnBEfLj+pQ+B6jfVcZgPMhXo4V0xU1M27 VFXZmTYz7Jv5RpePXTieoXgru9VEfbiHHWxX+aox5U5QyMCu/oqqj72O29ljm97MRcBF iJrA== X-Gm-Message-State: AOJu0YyWQnQRE2akbf56KwJf2kH3qiiU3huTEW4oQCXBqeGX/mwrdzzU LAJHse4b34ap/MssJLwcj8o= X-Google-Smtp-Source: AGHT+IHPtrhNJElGFoSlRRa9htkiJw1G/4qkpCx/tap9I0jADSqFFRW2wIC64qNCuihA28nOdgoLXg== X-Received: by 2002:a17:902:f68e:b0:1cf:a0b7:c68b with SMTP id l14-20020a170902f68e00b001cfa0b7c68bmr26693689plg.8.1701257067202; Wed, 29 Nov 2023 03:24:27 -0800 (PST) Received: from localhost.localdomain ([89.187.161.180]) by smtp.gmail.com with ESMTPSA id c6-20020a170902c1c600b001cfd0ed1604sm5460710plc.87.2023.11.29.03.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:24:26 -0800 (PST) From: Liang Chen To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, hawk@kernel.org, ilias.apalodimas@linaro.org, linyunsheng@huawei.com Cc: netdev@vger.kernel.org, linux-mm@kvack.org, liangchen.linux@gmail.com Subject: [PATCH net-next v5 0/4] skbuff: Optimize SKB coalescing for page pool Date: Wed, 29 Nov 2023 19:23:00 +0800 Message-Id: <20231129112304.67836-1-liangchen.linux@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 72BDF40011 X-Stat-Signature: f3feobbom1mik53ythgm8wk8h9719e1d X-Rspam-User: X-HE-Tag: 1701257068-954365 X-HE-Meta: U2FsdGVkX18z2leaiFfOdYACKK70wHiFDgD6zoovE6Ql1B1ocpXrN8VeeYo9nSx4KRIkLkCJR69CY0Y1eUiYufWOFBQPxHO69eUoe55l+RFmW2Q/X30S6mRBUtsEOfLk2CEw8u5XAq8TbjmnFx9kqN0sQSR1sCLKjJ3nKOyqs/fCv4rMQGiI2akOmtsAg7VmsBGqpPNV6O3b6Z3LQVRowpNO6BorCX557ODgsrKKkdP2UD6UACUR+Nl7wqVfpGSVw2Hj3EelV7HA7YjZGrRBNOhrbjlFib98tiddtqdwgx/nWcjATnKUIniTzwU4qVoa6AUDOzs8x0ioylFjLKxSLm/BrbJFj/nQEsohCp+WdLvp7E/bd8AjhzbaqxrbkY2XViQU9UQXPX8zu+xiEJ1wD+OliDEZdXL7on96H/dIRCQU7J2lydCIAUlI5J0bzwRiBEzN9qCE7cSKXvGt5U00DhEWpD/wacCavg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.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The combination of the following condition was excluded from skb coalescing: from->pp_recycle = 1 from->cloned = 1 to->pp_recycle = 1 With page pool in use, this combination can be quite common(ex. NetworkMananger may lead to the additional packet_type being registered, thus the cloning). In scenarios with a higher number of small packets, it can significantly affect the success rate of coalescing. This patchset aims to optimize this scenario and enable coalescing of this particular combination. That also involves supporting multiple users referencing the same fragment of a pp page to accomondate the need to increment the "from" SKB page's pp page reference count. Changes from v4: - remove 'inline' - rename skb_pp_get_frag_ref to skb_pp_frag_ref - use page_ref_inc instead of get_page - add helper to increase pp_ref_count in page_pool/helpers.h Liang Chen (4): page_pool: Rename pp_frag_count to pp_ref_count page_pool: halve BIAS_MAX for multiple user references of a fragment skbuff: Add a function to check if a page belongs to page_pool skbuff: Optimization of SKB coalescing for page pool .../net/ethernet/mellanox/mlx5/core/en_rx.c | 4 +- include/linux/mm_types.h | 2 +- include/net/page_pool/helpers.h | 50 +++++++++++-------- include/net/page_pool/types.h | 2 +- net/core/page_pool.c | 14 +++--- net/core/skbuff.c | 48 +++++++++++++----- 6 files changed, 76 insertions(+), 44 deletions(-)