Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp833952lqe; Sun, 7 Apr 2024 06:12:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlp//+ndy3bKTALuYBT3fywjiVXGvNr2B7TK1kAyZMq9b+8saRuKGokm4S4OP1QVFAXmeMMfAUnNP7ZqHsyZ22eOMPXq2k/ESGKax42w== X-Google-Smtp-Source: AGHT+IGkCTnEgCU6vTGRppOcGbumHUhm6xENcMAkvzfD0zGXOWhD8wX99QCNOr+Oi9pzhgsd5vQY X-Received: by 2002:aca:130e:0:b0:3c3:e307:5038 with SMTP id e14-20020aca130e000000b003c3e3075038mr5932993oii.57.1712495558508; Sun, 07 Apr 2024 06:12:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712495558; cv=pass; d=google.com; s=arc-20160816; b=rgaz/UmRyZxZplbszyfbyQ7rjNNDOtHKq/ZoOz8V8TKpeLNqNMHi3LR2K8et/Uet7Z 5M30T1xq2ATy+OUPXvljoXIqsNA1j3mUFB9JVzVwnnGXbfVpe+azhJGL9FoesRNOpnYa HkQkM2ykT2RPb+Sw/14CT7ZkTMcAjms1/hYt3zRRPxuawCxotfZma+qzzrqH1nm/OYs7 eGJOgP+0M6ASx/Lkgqy19//80LTj1RiTRAr9grhSvqFkhb6GdfoVL1avu2iBLJSGe+Yx TOFHitW0pJsUEMHEpWwfd1u1U5GZbbmh7WWH9RvtoI4IX8W7zrmb89t2hwOMnqmLDXoc WVtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=LAWRg82LuO3Rutlr6lQsMdGczkdPOra0hMaVHt1I+Uw=; fh=vYITzyZLJX16jXDwWPo3knSVfvuuqkSL6U9UDa1KcBc=; b=xEwBnESMRxmkUVz6DX7r+h8sovOvOAc8jvpX+2+3fDB5lyNFcLqAF3AVNhO4mOuHx0 oSRkSsq9pZVxIZWqc8h03/10Et01Hq3uGen5yI81i48snJF17Iv+82cS2wnSckQcnfIZ FVACWQMCk+z/yuhfa40ovgfYZLEy6jlnbIbIWQ3VsW93W3rhClRezMSmO/ctj7+/IrCW CDcvot/t/oTkJSRXA4zo/qpJ89U58XdbmHS48OsaG1eSMIxGgmhfSZaswSfjV3L2SL1N JSgD0IMhYtwMer+y9+iglPhqJ86ovoYrF3al2jdYzurG153RuHlMDM1Qe2CtgvsFntjh L1dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-134401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p8-20020a05622a13c800b004346100ebe8si5602993qtk.538.2024.04.07.06.12.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 06:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-134401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DBD501C2110B for ; Sun, 7 Apr 2024 13:12:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D8453838A; Sun, 7 Apr 2024 13:11:14 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3970D3BBEA; Sun, 7 Apr 2024 13:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495473; cv=none; b=dNpHEF3tcufmYZzAuS/5jBwYxVV2+Z3q2EPWWY4BMUfSi90ZJkUEMdxgomrYyKku3yhKGuHOFg5zlKYdN3N22TMpGXMPe9Gd5VR85iREF3/pB8JW6GryFUQfwi4FpjrEGCmLXrhtdFEagg1iC4qpl5o12mDEg1LhLqSWwE1U0Kw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712495473; c=relaxed/simple; bh=hDg7jA1fPAoBoi0a6T0CNtFlVqTTcsoVa4Nj+L71Yvs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XpjQV6T8CbeL71vZ8HfyuMUq+mnLwkWnGhFQ56ADJlZEqoUe1S8wgNAvMLvl2o6hfnHRJ/yV/4YhwE8aDW1BG4ePU3UWXtoVFU5GPbCj0XatF5zd5p8Rx1vo1o1aVsFA77zivEDhX3w4+2OGs2F+o/YamkSv2viYZcdgHK/Fs0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VCCFf2sgGzXkvV; Sun, 7 Apr 2024 21:08:06 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 462851404F7; Sun, 7 Apr 2024 21:11:10 +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; Sun, 7 Apr 2024 21:11:10 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Andrew Morton , Eric Dumazet , Subject: [PATCH net-next v1 05/12] mm: page_frag: add two inline helper for page_frag API Date: Sun, 7 Apr 2024 21:08:42 +0800 Message-ID: <20240407130850.19625-6-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240407130850.19625-1-linyunsheng@huawei.com> References: <20240407130850.19625-1-linyunsheng@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500005.china.huawei.com (7.185.36.74) 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 ++++++++++ net/core/skbuff.c | 4 ++-- 2 files changed, 12 insertions(+), 2 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/net/core/skbuff.c b/net/core/skbuff.c index 2c10ebd133ac..4ad4db7403ba 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -742,12 +742,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(); } -- 2.33.0