From nobody Wed Dec 31 02:35:12 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6E5EC4167B for ; Mon, 13 Nov 2023 13:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbjKMNBA (ORCPT ); Mon, 13 Nov 2023 08:01:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjKMNAn (ORCPT ); Mon, 13 Nov 2023 08:00:43 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC701984; Mon, 13 Nov 2023 05:00:38 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4STTwZ5Mryz1P8HW; Mon, 13 Nov 2023 20:57:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 13 Nov 2023 21:00:35 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin Subject: [PATCH RFC 4/8] skbuff: explicitize the semantics of skb_frag_fill_page_desc() Date: Mon, 13 Nov 2023 21:00:36 +0800 Message-ID: <20231113130041.58124-5-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231113130041.58124-1-linyunsheng@huawei.com> References: <20231113130041.58124-1-linyunsheng@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As we have ensured that the page and the offset to the page for the skb frag is passed togetherly in one function call, see [1], make it explicit that skb_frag_fill_page_desc() expect a base page or head page for a compound page, so that we can avoid the compound_head() in the net stack. Log a warning if the caller passes a tail page of compoud page and adjust 'page' to point to it's head page and 'offset' to point to start of it's head page. The warning can be removed if we have ensured all the caller is passing non tail page to skb_frag_fill_page_desc() in the future. 1. https://lore.kernel.org/all/20230511011213.59091-2-linyunsheng@huawei.co= m/ Signed-off-by: Yunsheng Lin --- include/linux/skbuff.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 27998f73183e..3e2f806c8ed8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2423,6 +2423,14 @@ static inline void skb_frag_fill_page_desc(skb_frag_= t *frag, struct page *page, int off, int size) { + /* expect head page for compound page */ + if (WARN_ON_ONCE(PageTail(page))) { + struct page *head =3D compound_head(page); + + off +=3D (page_to_pfn(page) - page_to_pfn(head)) * PAGE_SIZE; + page =3D head; + } + frag->bv_page =3D page; frag->bv_offset =3D off; skb_frag_size_set(frag, size); --=20 2.33.0