lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 15 Dec 2023 13:58:19 +0200
From: Ilias Apalodimas <ilias.apalodimas@...aro.org>
To: Yunsheng Lin <linyunsheng@...wei.com>
Cc: netdev@...r.kernel.org, Jesper Dangaard Brouer <hawk@...nel.org>, 
	"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, 
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] page_pool: Rename frag_users to frag_cnt

Hi Yunsheng,

On Fri, 15 Dec 2023 at 13:10, Yunsheng Lin <linyunsheng@...wei.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@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ