From patchwork Wed Dec 6 10:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Chen X-Patchwork-Id: 13481484 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 BE543C4167B for ; Wed, 6 Dec 2023 10:54:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36BFA6B00A7; Wed, 6 Dec 2023 05:54:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F4A06B00A9; Wed, 6 Dec 2023 05:54:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16E636B00AA; Wed, 6 Dec 2023 05:54:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 042A96B00A7 for ; Wed, 6 Dec 2023 05:54:35 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CE690A0187 for ; Wed, 6 Dec 2023 10:54:34 +0000 (UTC) X-FDA: 81536084868.07.11EEE6D Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) by imf20.hostedemail.com (Postfix) with ESMTP id 231E51C0021 for ; Wed, 6 Dec 2023 10:54:32 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SD04l5Ih; spf=pass (imf20.hostedemail.com: domain of liangchen.linux@gmail.com designates 209.85.160.42 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=1701860073; 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=2qSQoXhaZIkSox5U4y8/LH5pk6N5f+xtot1Ew+ZDWQM=; b=dmub48iEukHfo0RIHzWBisl5FgxYQ/nOLL84pwZi2RO0oDU3NCd9AZOpMwHOcKlYa1gHjV 3kDRjFW2kI/BK22LP/XGNU/SZrzEUYOXTvAPm9hvUpgZKNJMheXJgpmYmryiXFdnrTTbCB mUtUy6BDNZfkavCyW1r4qgclAAmxpG4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701860073; a=rsa-sha256; cv=none; b=63COIW2dDyYOZ94Qb5AlK1TIZ11oa2dRZfGWlZwObWcIh5/teBo3jY73L/9W1fVyBY7qLI l/leWknHOMGEl0Cn1PRnT2lZv5eiMNcmq2neg7feQJV/wrEh0bdyxzovY+L4gS+cHiySbh qwrsVA2c/u7q5NJ99slvT2XNKIgUhMA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SD04l5Ih; spf=pass (imf20.hostedemail.com: domain of liangchen.linux@gmail.com designates 209.85.160.42 as permitted sender) smtp.mailfrom=liangchen.linux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-1fa37df6da8so3732000fac.2 for ; Wed, 06 Dec 2023 02:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701860072; x=1702464872; 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=2qSQoXhaZIkSox5U4y8/LH5pk6N5f+xtot1Ew+ZDWQM=; b=SD04l5Ih7BqWja/P3a3Lymj4w1npTP6cpYxiMZOZ6EhM6xR45n+DjCQjPaUkXQ5CiB vZVEZO0PRZi+nPdbndzrRey3Y93iwk9p70sqHvnanx1fhcuPxXwEFa5FPEUS/17OK8xY /Cv7HPvhYrU1/dN1/3DQ9QH8g48ZJjdXNY1V4OLOuxGU/5rkKRCu2mn3wocRV0xFIQ91 DP88Ingvmr4l/2XV+OPmeLVhFFH4iNw8WPUU/N46H4eImOJzvKE62SdMN5zaGVnRN3sL gkre2rpuxRMXliChWL9+TNvcXu15TnxJ5w30dSggUo/Q0Yqf4aPgMJXHxxnVpVkqwVYv FgqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701860072; x=1702464872; 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=2qSQoXhaZIkSox5U4y8/LH5pk6N5f+xtot1Ew+ZDWQM=; b=c4MmHHaUOFsq1c1oGi9zd8Rb71rI/EJ0RgMJk4L32UdoXXbwDG7TlaY6NQz6OLTFrr JSLJFD3NVf+zTNGFLSwDPmT7pK9wH2/w/y/kQZ6ItEwNhHFzlngRKf0aGsObY7UHztfv B5YIX4nDS2fYztAjh6U6Lb515mRE+CcpqBdsEp37uiLSmKd3hPQYdBUxnhU0x+MFcFBv HSthdKdQKQPKkbSLyeJ3xcSqtOqVAbY+w9DhsAzU59YNrw4ZLR1eJVhYQp05gseRd4yd 7RZLo0efmy9Tq3huaYERrsYUWGTdidr0yc5ln3gW4nHfNWESNSOJ8jrMyzjH4owufh1p c6QQ== X-Gm-Message-State: AOJu0YykHqG57w86FgjjwYJ7BWUAd87t8R2m0KKr9pD/bhBwTK5WS1DM K/aFq/Whn6xWcwQJvLvKXkU= X-Google-Smtp-Source: AGHT+IG6Q6CwXDOVK1QrybKOfwa9jQm+Yy2c7KW0m9JQ9gPTTFusxHRJxArUpmVKE2k1Pzd7pOTruA== X-Received: by 2002:a05:6871:330a:b0:1fb:205d:756b with SMTP id nf10-20020a056871330a00b001fb205d756bmr800031oac.19.1701860072268; Wed, 06 Dec 2023 02:54:32 -0800 (PST) Received: from localhost.localdomain ([89.187.161.180]) by smtp.gmail.com with ESMTPSA id n15-20020a638f0f000000b005c6801efa0fsm5388796pgd.28.2023.12.06.02.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:54:31 -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, jasowang@redhat.com, liangchen.linux@gmail.com Subject: [PATCH net-next v7 0/4] skbuff: Optimize SKB coalescing for page pool Date: Wed, 6 Dec 2023 18:54:15 +0800 Message-Id: <20231206105419.27952-1-liangchen.linux@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 231E51C0021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ngrjz3rjt9acsws9tizwo953xedoc4m1 X-HE-Tag: 1701860072-109455 X-HE-Meta: U2FsdGVkX1/uJDNtJKOuENCRtJrMulGBdb7OTOc+j839i0HYL4qRvz060uHdrZ2FHJQrL1gCk4iXn5F5ATvR5LiNcimzstKVRNACfKMQDUaD7p3OhCD/ibMXyKfO/hTfLBhy4emqnfR2F8/iC1+Bbd7zaParRRZ5dbMecq67PYCNlimwQ3pVy/4aZFq40PLKFGwMP0EQhjaK53fS5M1SvPsTWec23FO4GHneDGHXBVul8VEo23k9YNIVWBw1n/egmRPn+COsFNIHeBRhoHYz8ofAHLTAxk904Zj1vaqjAFsiFL31gdxDuxduFxfe2/0qlgemFY6L34QR9DuX5qtHvXqbhUyt5L/vnGGaoneczDWFs5v5uxmFHNcOuTVQc3emWAy8vfSgits0o33wuypbb1qUrRGx/r0kz4DP8gHMybx6MvhEB2QYROReZzHxu+TRZAvQSaU0jsJCClrTTcGHVtE6u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, 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 v6: - provide sufficient description for the first patch - rename the utility function for checking pp page Liang Chen (4): page_pool: transition to reference count management after page draining 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 | 6 +-- net/core/page_pool.c | 14 +++--- net/core/skbuff.c | 48 +++++++++++++----- 6 files changed, 78 insertions(+), 46 deletions(-)