From patchwork Mon Nov 13 13:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 164464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1182798vqg; Mon, 13 Nov 2023 05:01:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcDmJT2txZmM4zY6diMDEA62ZBytzUePK90ivBmFh7X+ApNch+/gmfemuhFFra+hhaINR0 X-Received: by 2002:a17:903:248:b0:1cc:78a5:50a2 with SMTP id j8-20020a170903024800b001cc78a550a2mr9249122plh.39.1699880507723; Mon, 13 Nov 2023 05:01:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699880507; cv=none; d=google.com; s=arc-20160816; b=qMdDqSk8mJiRprV7nCRv7ZUOSJdQJosHBfL5AWy5vapzJbNwnaMGFOvW2MlogfVMfx ndwEejFrLBNE8JxiVK81cTOKG1BKpIK5mJpE3fVPFtoPUxsqOCaFXb8aqLGxYM8QHmzy KCfskxZFHnrOJQ8DWK+DzFPeftaDnUAGYQsGZdMaiqinzMyW6HNZuCKjFTUhymj1h1P+ uB/ZfWHOLq3nYpb+u/KZrnCW+L8v/nZoq83WN+7oijUBmDwXnAJyd4RsRhuYzlZuTjrB NbHuyXSfKBor0wMtb0Rgbfv3CLqCvhrrT0oKhT8WYWYmNlkNw7secM1nXYe0lIkoukuq qW5w== 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; bh=0veeVgGcPKI6vl8TxRqQ/3Hmtiyt8E5Ws6REHZvgTlc=; fh=D6xVSegNul4KrUJ9ERmiGKlse4yUgZ/4HEoMM009vXk=; b=TIqjB/CKCI+1fT7Gfgow75tfWvvu/pr/SBeXvoSPfJ8gU0W/qXgc7FurAgncqm+qo6 rjpTCbkr1IRr9+k1SSeatJZgRVGZ6886A+urDwP0/mqUvlYSKoZ/O54nImhgUpESPq50 P/QWnmUfQWaegGl/btkvRkGm0dSbHLZQjVn96QIqiJnCSk8IgURbY3SMoTsDMV70JlTD MLzZ5+UDfLcKPBr+53YOrjecHRkVIJzd6Hrrq02C2cteVcIbXTQ1ZFsD+X6OkA0MC2Vg V/onKQgktqcr8D0voETNywGGuWjd/rOY5nDYiGOGIYkN1Q1FUmaRfV6FR5ToAVAtH/FV tvkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id lk8-20020a17090308c800b001cc6529c7besi6097388plb.88.2023.11.13.05.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 05:01:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 01C3B8057429; Mon, 13 Nov 2023 05:01:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231180AbjKMNAz (ORCPT + 29 others); Mon, 13 Nov 2023 08:00:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbjKMNAn (ORCPT ); Mon, 13 Nov 2023 08:00:43 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3726519A7; Mon, 13 Nov 2023 05:00:39 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4STTvY6l89zPnY6; Mon, 13 Nov 2023 20:56:25 +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:37 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Eric Dumazet Subject: [PATCH RFC 5/8] skbuff: remove compound_head() related function calling Date: Mon, 13 Nov 2023 21:00:37 +0800 Message-ID: <20231113130041.58124-6-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 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 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 13 Nov 2023 05:01:44 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782453903022975916 X-GMAIL-MSGID: 1782453903022975916 As we have ensured that the page for the skb frag is always a base page or head page for a compound page, we can remove some compound_head() related function. Signed-off-by: Yunsheng Lin --- include/linux/skbuff.h | 8 +++++--- net/core/skbuff.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 3e2f806c8ed8..1889b0968be0 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2473,13 +2473,15 @@ static inline void skb_len_add(struct sk_buff *skb, int delta) static inline void __skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size) { - __skb_fill_page_desc_noacc(skb_shinfo(skb), i, page, off, size); + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + + skb_frag_fill_page_desc(frag, page, off, size); /* Propagate page pfmemalloc to the skb if we can. The problem is * that not all callers have unique ownership of the page but rely * on page_is_pfmemalloc doing the right thing(tm). */ - page = compound_head(page); + page = frag->bv_page; if (page_is_pfmemalloc(page)) skb->pfmemalloc = true; } @@ -3429,7 +3431,7 @@ static inline struct page *skb_frag_page(const skb_frag_t *frag) */ static inline void __skb_frag_ref(skb_frag_t *frag) { - get_page(skb_frag_page(frag)); + page_ref_inc(skb_frag_page(frag)); } /** diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b157efea5dea..ada3da4fe221 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -896,8 +896,6 @@ bool napi_pp_put_page(struct page *page, bool napi_safe) bool allow_direct = false; struct page_pool *pp; - page = compound_head(page); - /* page->pp_magic is OR'ed with PP_SIGNATURE after the allocation * in order to preserve any existing bits, such as bit 0 for the * head page of compound page and bit 1 for pfmemalloc page, so @@ -939,7 +937,7 @@ static bool skb_pp_recycle(struct sk_buff *skb, void *data, bool napi_safe) { if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle) return false; - return napi_pp_put_page(virt_to_page(data), napi_safe); + return napi_pp_put_page(virt_to_head_page(data), napi_safe); } static void skb_kfree_head(void *head, unsigned int end_offset)