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]
Message-ID: <CAPTztWZBm3M6CxDLj_XkX2-xYWEzPdibhGno47ELEHFjmefZ=A@mail.gmail.com>
Date: Mon, 10 Feb 2025 10:18:07 -0800
From: Frank van der Linden <fvdl@...gle.com>
To: Oscar Salvador <osalvador@...e.de>
Cc: akpm@...ux-foundation.org, muchun.song@...ux.dev, linux-mm@...ck.org, 
	linux-kernel@...r.kernel.org, yuzhao@...gle.com, usamaarif642@...il.com, 
	joao.m.martins@...cle.com, roman.gushchin@...ux.dev
Subject: Re: [PATCH v3 01/28] mm/cma: export total and free number of pages
 for CMA areas

On Mon, Feb 10, 2025 at 2:22 AM Oscar Salvador <osalvador@...e.de> wrote:
>
> On Thu, Feb 06, 2025 at 06:50:41PM +0000, Frank van der Linden wrote:
> > In addition to the number of allocations and releases, system
> > management software may like to be aware of the size of CMA
> > areas, and how many pages are available in it. This information
> > is currently not available, so export it in total_page and
> > available_pages, respectively.
> >
> > The name 'available_pages' was picked over 'free_pages' because
> > 'free' implies that the pages are unused. But they might not
> > be, they just haven't been used by cma_alloc
> >
> > The number of available pages is tracked regardless of
> > CONFIG_CMA_SYSFS, allowing for a few minor shortcuts in
> > the code, avoiding bitmap operations.
> >
> > Signed-off-by: Frank van der Linden <fvdl@...gle.com>
>
> LGTM,
>
> nit below
>
> Reviewed-by: Oscar Salvador <osalvador@...e.de>

Thanks for the review!

>
> > ---
> ...
> > @@ -444,6 +445,14 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count,
> >
> >       for (;;) {
> >               spin_lock_irq(&cma->lock);
> > +             /*
> > +              * If the request is larger than the available number
> > +              * of pages, stop right away.
> > +              */
> > +             if (count > cma->available_count) {
> > +                     spin_unlock_irq(&cma->lock);
> > +                     break;
> > +             }
> >               bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
> >                               bitmap_maxno, start, bitmap_count, mask,
> >                               offset);
> > @@ -452,6 +461,7 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count,
> >                       break;
> >               }
> >               bitmap_set(cma->bitmap, bitmap_no, bitmap_count);
> > +             cma->available_count -= count;
>
> I wonder whether we should have a cma_bitmat_set, so available_count would be
> touched in there.

Yeah, I initially thought so as well. Then I realized that for one of
the later patches (early CMA reservations), I'd need to decouple the
bitmap set and adjusting available_count again. For cma_reserve_early,
you don't have a bitmap yet, but you can use available_count to see if
you can get what you want.

So, I decided to not combine the two.

- Frank

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ