Message ID | 20231215073119.543560-1-ilias.apalodimas@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9100704dys; Thu, 14 Dec 2023 23:32:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGB6BJfQrBAlxkUA4fyA+o56RvqqJcMMDl7FTndrRBR8VVGgwDbn9p/a4qFmDa6v9G3lD9Q X-Received: by 2002:a05:622a:46:b0:425:4043:2a0b with SMTP id y6-20020a05622a004600b0042540432a0bmr15390302qtw.134.1702625523899; Thu, 14 Dec 2023 23:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702625523; cv=none; d=google.com; s=arc-20160816; b=FCOMtWT2xNfD1KxJ03+vf7UJ2PYIjmQwku9hQ71k+mmWzcOtU7GoRjgozOEsfyinOp 9ro3ATb4PLbzhl9uiFOVK06qitAiu/Mi1eUZFXiXXVIm4+7O2yLRiVp1bRsWcTfX78rK DLY6nDnzo1nrbX3EsRnRqdIMDzYAvthG4i+e9fs/HqRaKE1muHMjol4BHLjLqQ109lXp SNevO8JFQ6aQwZ9XQHaYctlSTldD6h3nsnqGiwK2RRTQWxAGu99Rz8DSkjCdX0p/3LjC +AEfIyDYw7hHYMOoQ0uxtRSWv9Rb6NlW87V3JhUSapgcbkWox/v+ZkI1X0eJl9iJ0Un5 iZ6w== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=y3LpvrqPMHTpFgWHeM6VHdWnvBHwIABqDsat0ivEWK0=; fh=Ep9OtI3hwH+mjkSKerJ++vABqu0V3puokxRkxJA5gW8=; b=S31c1nZBDuWsbQuMIBwcr0hsypGUbWZzLJktUBIevXbN6bbzdspgXjfn1phrCQ/za1 p7HSraGG8U1OUsibgJdXPyU2HHsfImJ+IyxNN8z+3TycvDYBtMnHJ1/mKYPqo+ZarIIS 06xYIyBWNM96GSQwlB2HkiUc6Cq8SXrXkecCFivl2V1QL/M47pzibwwuBu2H2/58JZ4K L3jeBuq9L2rF3mr7Muuh2+UwIsY614HUpaSnXKTO8t4euARHgM0OW3r+t4fMC3fHwpeg HrhGeVUq8/7j/Tk0PynL/i5OCPqJt4LcMj4xg0/87cAOhEfShYxBc3XqY7jggY7UDX8C RBEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oK+WEWb7; spf=pass (google.com: domain of linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r9-20020a05622a034900b004257a107643si18440557qtw.426.2023.12.14.23.32.03 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 23:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oK+WEWb7; spf=pass (google.com: domain of linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-520-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 9FCB51C2132E for <ouuuleilei@gmail.com>; Fri, 15 Dec 2023 07:32:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A59F101E4; Fri, 15 Dec 2023 07:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oK+WEWb7" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 BCCADD2F0 for <linux-kernel@vger.kernel.org>; Fri, 15 Dec 2023 07:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a1d2f89ddabso40383466b.1 for <linux-kernel@vger.kernel.org>; Thu, 14 Dec 2023 23:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702625500; x=1703230300; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y3LpvrqPMHTpFgWHeM6VHdWnvBHwIABqDsat0ivEWK0=; b=oK+WEWb7yYhqHH8CkLL+1rpsbBvE7Yb3cM6grtxi48LC4dU+4d3vkV7lPITOdxLW1O bWqNbvd2+PwtJh11J49SeLZpApDLR55cY0ylzey7fWFrWBmKLyvNu10OtxVqEYsH7VvO XudGHcALJ5OmSKcZdW0m/ndVQRzU3n+HnjBxVMJExnpVVW3znzKv76iBPd9UyTtQUonr 9BGRyTGD2LozK1/keBUvFwiIjOMt8VHkY52+jGfTVufJXoxhjiXxwUXzyqgC42gC9tvy LzghMz4wvuMaaMZBOPm5WGnvmUcUcvBGCVv48TZhpFOO4iOJlHMKtdqo8cnS9JKfhTTS bXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702625500; x=1703230300; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y3LpvrqPMHTpFgWHeM6VHdWnvBHwIABqDsat0ivEWK0=; b=DPVZmIQaTSEpY9kVPoaGrSk69yaZQ3aTO7cOfhij0zxkf7OLkD1S8pxZUUOuvhSoFg A1ScfHnQQXgbG/AjFhmSd9OmuTrWVmpfWvrP+IE42Cn2oZbzJNEymrtxLldwUC4etrno 3ln56F4R4GGGB+LRQdvcfFlxQK5BvAYd+4KYmQw3Qr5PnukcmWCsAVgr4vos83FRvZGr Z0ziV6fgFazMyYEEVXORRBdrx54r+YHzajQaaYHmpdga7laCg7rxsfI28BAs30bX1YGi Y0vt4Mz399UN13i2lZv57ZJQLDEI2N/+4Vd+hSetxciw1AIXMIEGjV0MD+D4GVQZJhQQ VM1w== X-Gm-Message-State: AOJu0YxhPigklyDQ3XwoG03xsQ/k3g76dSPjt/hLRphvpjjA5QW81sXP MyKOLz/lklt+fshJF4gYEGt2hQ== X-Received: by 2002:a17:907:7677:b0:a09:589f:8853 with SMTP id kk23-20020a170907767700b00a09589f8853mr5786522ejc.66.1702625499973; Thu, 14 Dec 2023 23:31:39 -0800 (PST) Received: from hades.. (ppp089210121239.access.hol.gr. [89.210.121.239]) by smtp.gmail.com with ESMTPSA id vc11-20020a170907d08b00b00a1ce58e9fc7sm10372337ejc.64.2023.12.14.23.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 23:31:39 -0800 (PST) From: Ilias Apalodimas <ilias.apalodimas@linaro.org> To: netdev@vger.kernel.org Cc: linyunsheng@huawei.com, Ilias Apalodimas <ilias.apalodimas@linaro.org>, Jesper Dangaard Brouer <hawk@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-kernel@vger.kernel.org Subject: [PATCH net-next] page_pool: Rename frag_users to frag_cnt Date: Fri, 15 Dec 2023 09:31:19 +0200 Message-Id: <20231215073119.543560-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 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 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785332261369531111 X-GMAIL-MSGID: 1785332261369531111 |
Series |
[net-next] page_pool: Rename frag_users to frag_cnt
|
|
Commit Message
Ilias Apalodimas
Dec. 15, 2023, 7:31 a.m. UTC
Since [0] got merged, it's clear that 'pp_ref_count' is used to track
the number of users for each page. On struct_page though we have
a member called 'frag_users'. Despite of what the name suggests this is
not the number of users. It instead represents the number of fragments of
the current page. When we have a single page this is set to one. When we
split the page this is set to the actual number of frags and later used
in page_pool_drain_frag() to infer the real number of users.
So let's rename it to something that matches the description above
[0]
Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
include/net/page_pool.h | 2 +-
net/core/page_pool.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
--
2.37.2
Comments
On Fri, 15 Dec 2023 at 09:31, Ilias Apalodimas <ilias.apalodimas@linaro.org> wrote: > > Since [0] got merged, it's clear that 'pp_ref_count' is used to track > the number of users for each page. On struct_page though we have > a member called 'frag_users'. Despite of what the name suggests this is > not the number of users. It instead represents the number of fragments of > the current page. When we have a single page this is set to one. Replying to myself here, but this is a typo. On single pages, we set pp_ref_count to one, not this. > When we > split the page this is set to the actual number of frags and later used > in page_pool_drain_frag() to infer the real number of users. > > So let's rename it to something that matches the description above > > [0] > Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/ > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> > --- > include/net/page_pool.h | 2 +- > net/core/page_pool.c | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/net/page_pool.h b/include/net/page_pool.h > index 813c93499f20..957cd84bb3f4 100644 > --- a/include/net/page_pool.h > +++ b/include/net/page_pool.h > @@ -158,7 +158,7 @@ struct page_pool { > u32 pages_state_hold_cnt; > unsigned int frag_offset; > struct page *frag_page; > - long frag_users; > + long frag_cnt; > > #ifdef CONFIG_PAGE_POOL_STATS > /* these stats are incremented while in softirq context */ > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index 9b203d8660e4..19a56a52ac8f 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > static struct page *page_pool_drain_frag(struct page_pool *pool, > struct page *page) > { > - long drain_count = BIAS_MAX - pool->frag_users; > + long drain_count = BIAS_MAX - pool->frag_cnt; > > /* Some user is still using the page frag */ > if (likely(page_pool_defrag_page(page, drain_count))) > @@ -678,7 +678,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, > > static void page_pool_free_frag(struct page_pool *pool) > { > - long drain_count = BIAS_MAX - pool->frag_users; > + long drain_count = BIAS_MAX - pool->frag_cnt; > struct page *page = pool->frag_page; > > pool->frag_page = NULL; > @@ -721,14 +721,14 @@ struct page *page_pool_alloc_frag(struct page_pool *pool, > pool->frag_page = page; > > frag_reset: > - pool->frag_users = 1; > + pool->frag_cnt = 1; > *offset = 0; > pool->frag_offset = size; > page_pool_fragment_page(page, BIAS_MAX); > return page; > } > > - pool->frag_users++; > + pool->frag_cnt++; > pool->frag_offset = *offset + size; > alloc_stat_inc(pool, fast); > return page; > -- > 2.37.2 >
On 2023/12/15 15:31, Ilias Apalodimas wrote: > Since [0] got merged, it's clear that 'pp_ref_count' is used to track > the number of users for each page. On struct_page though we have > a member called 'frag_users'. Despite of what the name suggests this is > not the number of users. It instead represents the number of fragments of > the current page. When we have a single page this is set to one. When we > split the page this is set to the actual number of frags and later used > in page_pool_drain_frag() to infer the real number of users. > > So let's rename it to something that matches the description above > > [0] > Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/ > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> > --- > include/net/page_pool.h | 2 +- > net/core/page_pool.c | 8 ++++---- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/net/page_pool.h b/include/net/page_pool.h > index 813c93499f20..957cd84bb3f4 100644 > --- a/include/net/page_pool.h > +++ b/include/net/page_pool.h > @@ -158,7 +158,7 @@ struct page_pool { > u32 pages_state_hold_cnt; > unsigned int frag_offset; > struct page *frag_page; > - long frag_users; > + long frag_cnt; I would rename it to something like refcnt_bais to mirror the pagecnt_bias in struct page_frag_cache. > > #ifdef CONFIG_PAGE_POOL_STATS > /* these stats are incremented while in softirq context */ > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index 9b203d8660e4..19a56a52ac8f 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > static struct page *page_pool_drain_frag(struct page_pool *pool, > struct page *page) > { > - long drain_count = BIAS_MAX - pool->frag_users; > + long drain_count = BIAS_MAX - pool->frag_cnt; drain_count = pool->refcnt_bais; or remove it and use pool->refcnt_bais directly. > > /* Some user is still using the page frag */ > if (likely(page_pool_defrag_page(page, drain_count))) > @@ -678,7 +678,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, > > static void page_pool_free_frag(struct page_pool *pool) > { > - long drain_count = BIAS_MAX - pool->frag_users; > + long drain_count = BIAS_MAX - pool->frag_cnt; Same here. > struct page *page = pool->frag_page; > > pool->frag_page = NULL; > @@ -721,14 +721,14 @@ struct page *page_pool_alloc_frag(struct page_pool *pool, > pool->frag_page = page; > > frag_reset: > - pool->frag_users = 1; > + pool->frag_cnt = 1; pool->refcnt_bais = BIAS_MAX - 1; > *offset = 0; > pool->frag_offset = size; > page_pool_fragment_page(page, BIAS_MAX); > return page; > } > > - pool->frag_users++; > + pool->frag_cnt++; pool->refcnt_bais--; > pool->frag_offset = *offset + size; > alloc_stat_inc(pool, fast); > return page; > -- > 2.37.2 > > . >
Hi Yunsheng, On Fri, 15 Dec 2023 at 13:10, Yunsheng Lin <linyunsheng@huawei.com> wrote: > > On 2023/12/15 15:31, Ilias Apalodimas wrote: > > Since [0] got merged, it's clear that 'pp_ref_count' is used to track > > the number of users for each page. On struct_page though we have > > a member called 'frag_users'. Despite of what the name suggests this is > > not the number of users. It instead represents the number of fragments of > > the current page. When we have a single page this is set to one. When we > > split the page this is set to the actual number of frags and later used > > in page_pool_drain_frag() to infer the real number of users. > > > > So let's rename it to something that matches the description above > > > > [0] > > Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/ > > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> > > --- > > include/net/page_pool.h | 2 +- > > net/core/page_pool.c | 8 ++++---- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/net/page_pool.h b/include/net/page_pool.h > > index 813c93499f20..957cd84bb3f4 100644 > > --- a/include/net/page_pool.h > > +++ b/include/net/page_pool.h > > @@ -158,7 +158,7 @@ struct page_pool { > > u32 pages_state_hold_cnt; > > unsigned int frag_offset; > > struct page *frag_page; > > - long frag_users; > > + long frag_cnt; > > I would rename it to something like refcnt_bais to mirror the pagecnt_bias > in struct page_frag_cache. Sure > > > > > #ifdef CONFIG_PAGE_POOL_STATS > > /* these stats are incremented while in softirq context */ > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > > index 9b203d8660e4..19a56a52ac8f 100644 > > --- a/net/core/page_pool.c > > +++ b/net/core/page_pool.c > > @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > > static struct page *page_pool_drain_frag(struct page_pool *pool, > > struct page *page) > > { > > - long drain_count = BIAS_MAX - pool->frag_users; > > + long drain_count = BIAS_MAX - pool->frag_cnt; > > drain_count = pool->refcnt_bais; I think this is a typo right? This still remains long drain_count = BIAS_MAX - pool->refcnt_bias; > > or > > remove it and use pool->refcnt_bais directly. I don't see any reason for inverting the logic. The bias is the number of refs that should be accounted for during allocation. I'll just stick with the rename > > > > > /* Some user is still using the page frag */ > > if (likely(page_pool_defrag_page(page, drain_count))) > > @@ -678,7 +678,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, > > > > static void page_pool_free_frag(struct page_pool *pool) > > { > > - long drain_count = BIAS_MAX - pool->frag_users; > > + long drain_count = BIAS_MAX - pool->frag_cnt; > > Same here. > > > struct page *page = pool->frag_page; > > > > pool->frag_page = NULL; > > @@ -721,14 +721,14 @@ struct page *page_pool_alloc_frag(struct page_pool *pool, > > pool->frag_page = page; > > > > frag_reset: > > - pool->frag_users = 1; > > + pool->frag_cnt = 1; > > pool->refcnt_bais = BIAS_MAX - 1; > > > *offset = 0; > > pool->frag_offset = size; > > page_pool_fragment_page(page, BIAS_MAX); > > return page; > > } > > > > - pool->frag_users++; > > + pool->frag_cnt++; > > pool->refcnt_bais--; > > > pool->frag_offset = *offset + size; > > alloc_stat_inc(pool, fast); > > return page; > > -- > > 2.37.2 > > > > . > > Thanks /Ilias
Hi Yunsheng, On Fri, 15 Dec 2023 at 14:34, Yunsheng Lin <linyunsheng@huawei.com> wrote: > > On 2023/12/15 19:58, Ilias Apalodimas wrote: > > Hi Yunsheng, > > > > On Fri, 15 Dec 2023 at 13:10, Yunsheng Lin <linyunsheng@huawei.com> wrote: > >> > >> On 2023/12/15 15:31, Ilias Apalodimas wrote: > >>> Since [0] got merged, it's clear that 'pp_ref_count' is used to track > >>> the number of users for each page. On struct_page though we have > >>> a member called 'frag_users'. Despite of what the name suggests this is > >>> not the number of users. It instead represents the number of fragments of > >>> the current page. When we have a single page this is set to one. When we > >>> split the page this is set to the actual number of frags and later used > >>> in page_pool_drain_frag() to infer the real number of users. > >>> > >>> So let's rename it to something that matches the description above > >>> > >>> [0] > >>> Link: https://lore.kernel.org/netdev/20231212044614.42733-2-liangchen.linux@gmail.com/ > >>> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> > >>> --- > >>> include/net/page_pool.h | 2 +- > >>> net/core/page_pool.c | 8 ++++---- > >>> 2 files changed, 5 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/include/net/page_pool.h b/include/net/page_pool.h > >>> index 813c93499f20..957cd84bb3f4 100644 > >>> --- a/include/net/page_pool.h > >>> +++ b/include/net/page_pool.h > >>> @@ -158,7 +158,7 @@ struct page_pool { > >>> u32 pages_state_hold_cnt; > >>> unsigned int frag_offset; > >>> struct page *frag_page; > >>> - long frag_users; > >>> + long frag_cnt; > >> > >> I would rename it to something like refcnt_bais to mirror the pagecnt_bias > >> in struct page_frag_cache. > > > > Sure > > > >> > >>> > >>> #ifdef CONFIG_PAGE_POOL_STATS > >>> /* these stats are incremented while in softirq context */ > >>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c > >>> index 9b203d8660e4..19a56a52ac8f 100644 > >>> --- a/net/core/page_pool.c > >>> +++ b/net/core/page_pool.c > >>> @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > >>> static struct page *page_pool_drain_frag(struct page_pool *pool, > >>> struct page *page) > >>> { > >>> - long drain_count = BIAS_MAX - pool->frag_users; > >>> + long drain_count = BIAS_MAX - pool->frag_cnt; > >> > >> drain_count = pool->refcnt_bais; > > > > I think this is a typo right? This still remains > > It would be better to invert logic too, as it is mirroring: > > https://elixir.bootlin.com/linux/v6.7-rc5/source/mm/page_alloc.c#L4745 This is still a bit confusing for me since the actual bias is the number of fragments that you initially split the page. But I am fine with having a common approach. I'll send the rename again shortly, and I can send the logic invert a bit later (or feel free to send it, since it was your idea). Thanks /Ilias
Hi Yunsheng, On Thu, 21 Dec 2023 at 04:07, Yunsheng Lin <linyunsheng@huawei.com> wrote: > > On 2023/12/20 15:56, Ilias Apalodimas wrote: > > Hi Yunsheng, > >>>>> #ifdef CONFIG_PAGE_POOL_STATS > >>>>> /* these stats are incremented while in softirq context */ > >>>>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c > >>>>> index 9b203d8660e4..19a56a52ac8f 100644 > >>>>> --- a/net/core/page_pool.c > >>>>> +++ b/net/core/page_pool.c > >>>>> @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); > >>>>> static struct page *page_pool_drain_frag(struct page_pool *pool, > >>>>> struct page *page) > >>>>> { > >>>>> - long drain_count = BIAS_MAX - pool->frag_users; > >>>>> + long drain_count = BIAS_MAX - pool->frag_cnt; > >>>> > >>>> drain_count = pool->refcnt_bais; > >>> > >>> I think this is a typo right? This still remains > >> > >> It would be better to invert logic too, as it is mirroring: > >> > >> https://elixir.bootlin.com/linux/v6.7-rc5/source/mm/page_alloc.c#L4745 > > > > This is still a bit confusing for me since the actual bias is the > > number of fragments that you initially split the page. But I am fine > Acctually there are two bais numbers for a page used by > page_pool_alloc_frag(). > the one for page->pp_ref_count, which already use the BIAS_MAX, which > indicates the initial bais number: > https://elixir.bootlin.com/linux/latest/source/net/core/page_pool.c#L779 > > Another one for pool->frag_users indicating the runtime bais number, which > need changing when a page is split into more fragments: > https://elixir.bootlin.com/linux/latest/source/net/core/page_pool.c#L776 > https://elixir.bootlin.com/linux/latest/source/net/core/page_pool.c#L783 I know, and that's exactly what my commit message explains. Also, that's the reason that the rename was 'frag_cnt' on v1. /Ilias > > > with having a common approach. I'll send the rename again shortly, and > > I can send the logic invert a bit later (or feel free to send it, > > since it was your idea). > > > > Thanks > > /Ilias > > . > >
diff --git a/include/net/page_pool.h b/include/net/page_pool.h index 813c93499f20..957cd84bb3f4 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -158,7 +158,7 @@ struct page_pool { u32 pages_state_hold_cnt; unsigned int frag_offset; struct page *frag_page; - long frag_users; + long frag_cnt; #ifdef CONFIG_PAGE_POOL_STATS /* these stats are incremented while in softirq context */ diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 9b203d8660e4..19a56a52ac8f 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -659,7 +659,7 @@ EXPORT_SYMBOL(page_pool_put_page_bulk); static struct page *page_pool_drain_frag(struct page_pool *pool, struct page *page) { - long drain_count = BIAS_MAX - pool->frag_users; + long drain_count = BIAS_MAX - pool->frag_cnt; /* Some user is still using the page frag */ if (likely(page_pool_defrag_page(page, drain_count))) @@ -678,7 +678,7 @@ static struct page *page_pool_drain_frag(struct page_pool *pool, static void page_pool_free_frag(struct page_pool *pool) { - long drain_count = BIAS_MAX - pool->frag_users; + long drain_count = BIAS_MAX - pool->frag_cnt; struct page *page = pool->frag_page; pool->frag_page = NULL; @@ -721,14 +721,14 @@ struct page *page_pool_alloc_frag(struct page_pool *pool, pool->frag_page = page; frag_reset: - pool->frag_users = 1; + pool->frag_cnt = 1; *offset = 0; pool->frag_offset = size; page_pool_fragment_page(page, BIAS_MAX); return page; } - pool->frag_users++; + pool->frag_cnt++; pool->frag_offset = *offset + size; alloc_stat_inc(pool, fast); return page;