Message ID | 20231218024024.3516870-3-almasrymina@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp992618dyi; Sun, 17 Dec 2023 18:42:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoAuNdEzUsFKpxxc6nYbuH+1c9l2a5KfW/8QTym4jxjBVuNtWr4X54oi0UO4BvBXM1c32s X-Received: by 2002:a05:6358:e48b:b0:172:d778:5ef9 with SMTP id by11-20020a056358e48b00b00172d7785ef9mr261646rwb.42.1702867334520; Sun, 17 Dec 2023 18:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702867334; cv=none; d=google.com; s=arc-20160816; b=PPQb42S2DXLbyG1v5/I2V00ZiSyqQd8S16oudcRnBC/wH25mLk+D8/GI3IcxcdZtsP lwAbg+DphfH/qy0HtczHPKhVAzm+lqDx7xr9ZaP2y+HmcDN9a2ItiGRPIo4VXxLpgDy2 fLiq2V1Hg4r5AjzfMfzIlO1vBiya3IVX5LXzWIIUSnDdgINiB9lEH0NFzeQ/EL5e00cU QG1883sFtCAJ8k6/RVvR0F901fq0eWNEBizWTX2j0rZ/D+eU4eT9Z9SFsL/rpuhRM+1L 6KQLKZ0vg9L4PzyC6cuRVpQep8WwgXEVQ+9rkZYAoLkafYj75tXKc2m+9Ryv+P8zNlJB PyFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=goaaxpdo4bsNfCqF/IRbg9OCDHUZobJiFZIImpZ+yx8=; fh=8Y9D+7Eqr15uC+q4uaUvZHfnG7pix6ubnhqqWosbV7w=; b=WkjntE6r5zeUsb0gLsygvedKyLJKJm3jEWiulmpwSx3wCSo9T6rcbTe1qDA0NR6NBt VnT0/gMcaqwplYVzNyfZl/gosUNv3a3r49w/UV4k62ZA8cCiKVMhWfre4ZozkOmYDzmw FH+LLY11oL5jELEEBWYWGv2VCRstEpUFMs3290l08y51Bxl0V+TyfrRmTHW60RcYjFWl ab9s0HNnLylVbCTThXgltk2UpBjJVFyhxPigRf01V7/bCFKzvEAEKNXpcZi08r1nfz3V rL/tFAgREsCz0u3Y9LEmWm2OkP84j+SJrLQYuIw/Cgb8k/SMEMGTneC2tsyaMxEyk28G LoBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KiDuVyBp; spf=pass (google.com: domain of linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b23-20020a170902b61700b001d0cb6306c5si16730803pls.387.2023.12.17.18.42.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 18:42:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KiDuVyBp; spf=pass (google.com: domain of linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2926-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 826EBB21B0A for <ouuuleilei@gmail.com>; Mon, 18 Dec 2023 02:42:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0699CA51; Mon, 18 Dec 2023 02:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KiDuVyBp" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D84DA525A for <linux-kernel@vger.kernel.org>; Mon, 18 Dec 2023 02:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5cb6271b225so31273397b3.1 for <linux-kernel@vger.kernel.org>; Sun, 17 Dec 2023 18:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702867233; x=1703472033; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=goaaxpdo4bsNfCqF/IRbg9OCDHUZobJiFZIImpZ+yx8=; b=KiDuVyBpSqAKZrXxIilkzfl0cIDoRr8K2tNUpCk96bIY3jZlBZ3owgVr+8xxrMA4xD PEQ6gYqYaWutJFGoAZqVd96kn8iCfMvff8epiyGuWh8Y6EhM4OLH2gf49lxm5mT6lhir PVlh3GHgdja4tPnHgCrb8MAr30phqimI0FNSj8sIM/QvNPdeBPqENdKkVVfPwtwZvNXS Vkd52KPOGUDGseTKG5zWL9vq/HGu5AlXF2ltdh/EABWBVn79dszDVJfDdLF2wQbXT/zE tQfHitMpxSL+ZGcfuOrtSZczEL5Bi/sbdvI6ayCBsgZTZjc5o8bsDjdvUmqOObHVakQo 7QlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702867233; x=1703472033; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=goaaxpdo4bsNfCqF/IRbg9OCDHUZobJiFZIImpZ+yx8=; b=QJTLGX+iSksYH29EOr7j8lmhwsBxAzGfAnoM5llnMCGF5roJOAdt11MDbq3kqsSc0o y00EhmeRrHV1Yl/nVEbUBM9umoNQTZZ6fwoj22qg4HOIs1NPtzgexxTfa/0UEF8nY1sj WqIgYXxN9t+gz/pbWWmYo2NZRLYLrrasVlfFF//TTv4y5CXMFlXWqVouWM4z/MLV/ejT TWDXBmJo2wT7e66guHS9Vy2kBvIN4oXdJaDkyzgakjfvTe4ItdPJYUCvKpM4tv5mCHBu UfCLDuu1alKM3USe6FsLiOzh6qaURp5r10wfiyPjgWPqXoD+jNa1MyvsY8KsTMwhvULe 1iNA== X-Gm-Message-State: AOJu0YxBwI00qv1/ERHfcZFdaJR9VIOb7/4jYQYejDQL5xdhYVNWd+3h HOSSWdoez7XsLJjTplFPGSACfnZ8K/z6bW5dyA== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:5cbf:3534:fb34:758e]) (user=almasrymina job=sendgmr) by 2002:a05:690c:83:b0:5d7:29d7:8a35 with SMTP id be3-20020a05690c008300b005d729d78a35mr1936565ywb.5.1702867232915; Sun, 17 Dec 2023 18:40:32 -0800 (PST) Date: Sun, 17 Dec 2023 18:40:09 -0800 In-Reply-To: <20231218024024.3516870-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20231218024024.3516870-1-almasrymina@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231218024024.3516870-3-almasrymina@google.com> Subject: [RFC PATCH net-next v5 02/14] net: page_pool: factor out page_pool recycle check From: Mina Almasry <almasrymina@google.com> To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Mina Almasry <almasrymina@google.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Richard Henderson <richard.henderson@linaro.org>, Ivan Kokshaysky <ink@jurassic.park.msu.ru>, Matt Turner <mattst88@gmail.com>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>, Helge Deller <deller@gmx.de>, Jesper Dangaard Brouer <hawk@kernel.org>, Ilias Apalodimas <ilias.apalodimas@linaro.org>, Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, David Ahern <dsahern@kernel.org>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, Shuah Khan <shuah@kernel.org>, Sumit Semwal <sumit.semwal@linaro.org>, " =?utf-8?q?Christian_K=C3=B6nig?= " <christian.koenig@amd.com>, Pavel Begunkov <asml.silence@gmail.com>, David Wei <dw@davidwei.uk>, Jason Gunthorpe <jgg@ziepe.ca>, Yunsheng Lin <linyunsheng@huawei.com>, Shailend Chand <shailend@google.com>, Harshitha Ramamurthy <hramamurthy@google.com>, Shakeel Butt <shakeelb@google.com>, Jeroen de Borst <jeroendb@google.com>, Praveen Kaligineedi <pkaligineedi@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785585818195473296 X-GMAIL-MSGID: 1785585818195473296 |
Series |
Device Memory TCP
|
|
Commit Message
Mina Almasry
Dec. 18, 2023, 2:40 a.m. UTC
The check is duplicated in 2 places, factor it out into a common helper.
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
net/core/page_pool.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 45bb4210412d..0edb9251d98d 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -657,6 +657,11 @@ static bool page_pool_recycle_in_cache(struct page *page, return true; } +static bool __page_pool_page_can_be_recycled(const struct page *page) +{ + return page_ref_count(page) == 1 && !page_is_pfmemalloc(page); +} + /* If the page refcnt == 1, this will try to recycle the page. * if PP_FLAG_DMA_SYNC_DEV is set, we'll try to sync the DMA area for * the configured size min(dma_sync_size, pool->max_len). @@ -678,7 +683,7 @@ __page_pool_put_page(struct page_pool *pool, struct page *page, * page is NOT reusable when allocated when system is under * some pressure. (page_is_pfmemalloc) */ - if (likely(page_ref_count(page) == 1 && !page_is_pfmemalloc(page))) { + if (likely(__page_pool_page_can_be_recycled(page))) { /* Read barrier done in page_ref_count / READ_ONCE */ if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) @@ -793,7 +798,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, if (likely(page_pool_unref_page(page, drain_count))) return NULL; - if (page_ref_count(page) == 1 && !page_is_pfmemalloc(page)) { + if (__page_pool_page_can_be_recycled(page)) { if (pool->p.flags & PP_FLAG_DMA_SYNC_DEV) page_pool_dma_sync_for_device(pool, page, -1);