From patchwork Mon Apr 15 13:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13630032 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 48EA3C4345F for ; Mon, 15 Apr 2024 13:22:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C6246B009F; Mon, 15 Apr 2024 09:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 277396B00A0; Mon, 15 Apr 2024 09:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13DCE6B00A1; Mon, 15 Apr 2024 09:22:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DBB856B009F for ; Mon, 15 Apr 2024 09:22:17 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ABC93405E1 for ; Mon, 15 Apr 2024 13:22:17 +0000 (UTC) X-FDA: 82011829914.13.C26A089 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf19.hostedemail.com (Postfix) with ESMTP id 6AA0F1A0006 for ; Mon, 15 Apr 2024 13:22:15 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713187335; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n7kWKGNhRlCo3a8YMhRYkOnZd9Li/ML6T++WAa5LpeA=; b=CYDQo/TCmXzPFoY8DQZWJ7jI2dtPnm2feSEsQRRZpN9ibDUNbM7Klg556LU7ETcCgVZhcp alwya2pcre7AE2YrrH7CV252k/5QJjUjUOg5QAtTzvUIBdR8dAp+hzQowI+W9CRfDesjO+ UJGR1iqDeT9BRS2/FqqCuHZ5nJosoMM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713187335; a=rsa-sha256; cv=none; b=6Q/X2Yl9s2b+7vu8Kjr+ikBy344xJR3f6Vo/tvHTAqRbJ+nKgf/oNFkCiSaaJIlhYPydHn Hir9MFEJOpfgzIxum3wjbdIxZQwsun2R4X5bd9KkzaAqwHZwx1bWOYLqv9OqSdgzb7wcTA NwYRTbE0OjE/3GOTt7krJrAkjLZWoVU= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VJ76y3P1Zz1R5sP; Mon, 15 Apr 2024 21:19:22 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 57EB718007D; Mon, 15 Apr 2024 21:22:12 +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_256_GCM_SHA384) id 15.1.2507.35; Mon, 15 Apr 2024 21:22:12 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Eric Dumazet , Subject: [PATCH net-next v2 08/15] mm: page_frag: add two inline helper for page_frag API Date: Mon, 15 Apr 2024 21:19:33 +0800 Message-ID: <20240415131941.51153-9-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240415131941.51153-1-linyunsheng@huawei.com> References: <20240415131941.51153-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500005.china.huawei.com (7.185.36.74) X-Rspam-User: X-Stat-Signature: 6nz7bz5heohyphy5x3f1kxrmor4cboz8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6AA0F1A0006 X-HE-Tag: 1713187335-997323 X-HE-Meta: U2FsdGVkX18gCC+LPuGC6otmt5BJf13wn9RWFHEy/mPcpuQ0k8yPeWloPOMcQq27XUN9qP0TC5CrVtGwqRFbGtRiRLJI4+E7ytHC9xP4kEh3KKQO1P6loIcwsqM0iIC1YIWex4Q57l2SjkGnIb9V29cgxgkHLAh5kW/76mJL3GTYjAeyLg4yF0ojJ9meDiKv9M6uLLrnjzFzq0/SY+JfPr1TZI4hbH3j1gTs8kZ2yWS5ppFx4PdAb/SwnPl0P1NV5Z5VLHPOCjbMDhHjFX5g1rlwJftCTeQxA7SHwB/znboSUZi51lkjioy4r9UERpzcTn+ktRsdl6tOjMoKnRvLMCESSkk+sA7jX6VE9UrjU3oJrI0kGjH1uLel32dqXLnqYlug80fQc5OTXpf1snqOEG4YFlKzrzpblWH2P/B6+jYdvblGgpCwMK6gB/+tRZGIxMRreIFBlipZl2oZv07Y375RNQf0IcjxzcyeG6LsYQKPk96iBkPB3aibtIwVcyV+7GqXUtsRZmSa7aB16c0LkkU9ETMIS5xaFb4ZJLdU3k6Tbyph1SbdNgIdg4/RXAM+Jj5GJno7aXJc+mVPWHl3o16FBJwVdOxsuXBKgx+m6AQxh+wYZMI4dDLGLCRczV/gFq9nE3Dt611TKgHMNhoIlE6gVh40hBCKJks+OKm6o0fY1UZ0W3szetPrWeksfmqsCpXied2G5532L/VPIWL1S7HgJBhqSkInxjMGTKXzS3Vb3zhzyl6VPBpMSHEb86eC4e75ACATJmaR8KBEFk0+nXMIL4jawIzhmHNIt/y9S5fcLBWLg9yDuJiZv+vJQNW9597GBvuHRYZKvJ8+eoihpEKUHfxSfFv9ujRJ8lxBXPNTkGQ6tGeLmvcqNSrykN3stYP2OAnpSn8SBFj1K/MOwvqwhDQS0uGsKv/eMcvTszGvaQehbx86SWHYGI5H13mVSZMy0NSZx1ctd+bdzU2 Lso9/A/p E5XHU7/vPwAkXZLixrYSX3fi4tzFu/sYfm2bPISADLf+2Q4hZ3wbqIYBpclw1vN0l/ivEuoU6XjHkeHAOgqalPMsXXMpIijLQijJusTkkqvv6G6YBVKLGhiUXzWUbS/eS2aKmap8FLJpWAmpwvjpnKN7trBz2rGOIDFcS9xVNyYnwr97yByXpxjgzXt7MgcJp170VWCg2ORqZs9A1R2PDFI4jx8DPpUKvrpG4USJDnE0ldmPDldIbRAse5XmYE2qjKtY/mxsEuFYpHRs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add two inline helpers for page_frag API to avoid calling accessing the field of 'struct page_frag_cache'. Signed-off-by: Yunsheng Lin --- include/linux/page_frag_cache.h | 10 ++++++++++ mm/page_frag_test.c | 2 +- net/core/skbuff.c | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/page_frag_cache.h b/include/linux/page_frag_cache.h index 9d5d86b2d3ab..fe5faa80b6c3 100644 --- a/include/linux/page_frag_cache.h +++ b/include/linux/page_frag_cache.h @@ -23,6 +23,16 @@ struct page_frag_cache { bool pfmemalloc; }; +static inline void page_frag_cache_init(struct page_frag_cache *nc) +{ + nc->va = NULL; +} + +static inline bool page_frag_cache_is_pfmemalloc(struct page_frag_cache *nc) +{ + return !!nc->pfmemalloc; +} + void page_frag_cache_drain(struct page_frag_cache *nc); void __page_frag_cache_drain(struct page *page, unsigned int count); void *page_frag_alloc_va(struct page_frag_cache *nc, unsigned int fragsz, diff --git a/mm/page_frag_test.c b/mm/page_frag_test.c index cab05b8a2e77..20756b28df4a 100644 --- a/mm/page_frag_test.c +++ b/mm/page_frag_test.c @@ -318,7 +318,7 @@ static int __init page_frag_test_init(void) u64 duration; int ret; - test_frag.va = NULL; + page_frag_cache_init(&test_frag); atomic_set(&nthreads, 2); init_completion(&wait); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 139a193853cc..cdbfdf651001 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -743,12 +743,12 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, if (in_hardirq() || irqs_disabled()) { nc = this_cpu_ptr(&netdev_alloc_cache); data = page_frag_alloc_va(nc, len, gfp_mask); - pfmemalloc = nc->pfmemalloc; + pfmemalloc = page_frag_cache_is_pfmemalloc(nc); } else { local_bh_disable(); nc = this_cpu_ptr(&napi_alloc_cache.page); data = page_frag_alloc_va(nc, len, gfp_mask); - pfmemalloc = nc->pfmemalloc; + pfmemalloc = page_frag_cache_is_pfmemalloc(nc); local_bh_enable(); }