Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp438415lqh; Thu, 28 Mar 2024 06:42:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHoIaONu8/coX2sbBN77Born+/ViZXBQAbbZxKLSi56p5zM2ntao65kcAUo77I67T3ZiMiheM9P0q6RAMfbWIGnfTbYrSVzpukEux3iQ== X-Google-Smtp-Source: AGHT+IEBHYTwcdMuTLbbXfVB9jDolUlhRgvCp0gqNXEFrIX66/7vX03VSPYZW9eSDVtPkxwixHfz X-Received: by 2002:a05:6a00:4fd0:b0:6ea:e2fd:6100 with SMTP id le16-20020a056a004fd000b006eae2fd6100mr11588pfb.30.1711633338530; Thu, 28 Mar 2024 06:42:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711633338; cv=pass; d=google.com; s=arc-20160816; b=pSBewd67JufMfqNyleF/jBfzobvhxQWJWjATcjjkuovGhUQHhAo9nZOwYv0y2xakeY cvAA3rSCLYib8WKdpBdk2pho91WNWNGVV2X0B4cMkBdNM0qPe62RDN3/FWNaJum2RaEe OJRiG1PYHFgi2TDCKX64L/QXmMMWbLgSeLVuX9fE4pjCboWAcY0A+4YEJeV2x7+ORCUn TMEg8ndjB1OAD+mYCgnzpoxccYmFb3exOwhW5xsBuka5w0C+qz4iKpTSbQzJ7qKN2Ykw cT3EDClxeCxQ1JM/qaYSGrkZjE48ka6A1SpiWiMiSVj/2Kn3CpEeGhexcNq+FcnZObK9 Py/A== 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=vbKHpGj9C7ZPz3kFxumqcrbCmjjN1o6Ndlst9Wj+Kfs=; fh=vYITzyZLJX16jXDwWPo3knSVfvuuqkSL6U9UDa1KcBc=; b=q08fqiUmxs0XV1bTajxV1ZRhHupG42/4Myvwrf3NsRmu0MmKXfcSpL/oZfy6VW5s89 6rKQJTf+d/hVrG+nGs2Qe5FOSmzF3Qsu5nNOSIQEzVZoNWpeBoUJQM15mxpQnd/yJwLB dg77579OVoAVUN9wq87K5nYu9VL/JXz1HyoOqYWGvSYuSpxwKDk7MWqUa0+qV8J9JbZX OEMr0bqrFEjK2Y+qkXlVSRqBnGKw8dmpLOdvk/GuTVoQ7OkhS+mkdIz3VVSCBvNcfBpa DgXAUJaXuSVNydEM/oWuV2Cd2pKViv0gxdh8AyWUoGJwxlv6PlmszW+fBWM1cWCRqsjf xxIw==; 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-122974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id dq12-20020a056a020f8c00b005d2c05c7039si1508141pgb.865.2024.03.28.06.42.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 06:42:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-122974-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122974-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 394A8293AC6 for ; Thu, 28 Mar 2024 13:42:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5664B12E1D6; Thu, 28 Mar 2024 13:40:58 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 3E50E12D1E8; Thu, 28 Mar 2024 13:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711633257; cv=none; b=bM0IT0JdrfSGxFhzms3SjqJHynHpqg+2qR41UgvtIy41koGjtva35STwgBPaKsTP9R3xy6Sm+NNmQt3V4qKxa4y3VxVGDIRUdRaJst2FvgDQ/QW6QPKdya/bxktGsej/ZRjPbzVQFe6uhRynMxRN9A1XqI/afx9HBUMNoNcKzGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711633257; c=relaxed/simple; bh=XGIOGFAiA4HuxyP7QKZjbc02X2oTT7KGKjHMM4PfX+8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p0jpPrVUY7YOHOi1QEuPHne+hIizRFCQ5IKXZuzM3fkMyv6AKFf/DAVHXuFaONmvWYf8xOv89XY8y0dLgn8i5NjE5nML4dieztlyH2MUaXb+smhhEt/ekl9duHnPj6Y7Lte6aFTL7bnHO1TPkQt/0jDEPkdN+gTbFXMUMohmOxY= 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.35 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.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4V54P074DJz1R8gB; Thu, 28 Mar 2024 21:38:12 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id D62381A0172; Thu, 28 Mar 2024 21:40:53 +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; Thu, 28 Mar 2024 21:40:53 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Andrew Morton , Eric Dumazet , Subject: [PATCH RFC 05/10] mm: page_frag: add two inline helper for page_frag API Date: Thu, 28 Mar 2024 21:38:34 +0800 Message-ID: <20240328133839.13620-6-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240328133839.13620-1-linyunsheng@huawei.com> References: <20240328133839.13620-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: dggems705-chm.china.huawei.com (10.3.19.182) 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 aa3adaa2c466..e6bc0dec7463 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