Re: [PATCH v3 01/28] mm/cma: export total and free number of pages for CMA areas

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 10, 2025 at 2:22 AM Oscar Salvador <osalvador@xxxxxxx> 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@xxxxxxxxxx>
>
> LGTM,
>
> nit below
>
> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>

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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux