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] [day] [month] [year] [list]
Message-ID: <CAPTztWaCFYgQo1Bk6w-f_2=aYBbYfXeLy_WPw3XRJ+a3RDwnzg@mail.gmail.com>
Date: Thu, 25 Jul 2024 09:18:33 -0700
From: Frank van der Linden <fvdl@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/cma: export total and free number of pages for CMA areas

On Wed, Jul 24, 2024 at 12:49 PM Andrew Morton
<akpm@...ux-foundation.org> wrote:
>
> On Tue,  9 Jul 2024 16:30:53 +0000 Frank van der Linden <fvdl@...gle.com> 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.
> >
> > ...
> >
> > @@ -382,7 +383,7 @@ static void cma_debug_show_areas(struct cma *cma)
> >  {
> >       unsigned long next_zero_bit, next_set_bit, nr_zero;
> >       unsigned long start = 0;
> > -     unsigned long nr_part, nr_total = 0;
> > +     unsigned long nr_part;
> >       unsigned long nbits = cma_bitmap_maxno(cma);
> >
> >       spin_lock_irq(&cma->lock);
> > @@ -394,12 +395,12 @@ static void cma_debug_show_areas(struct cma *cma)
> >               next_set_bit = find_next_bit(cma->bitmap, nbits, next_zero_bit);
> >               nr_zero = next_set_bit - next_zero_bit;
> >               nr_part = nr_zero << cma->order_per_bit;
> > -             pr_cont("%s%lu@%lu", nr_total ? "+" : "", nr_part,
> > +             pr_cont("%s%lu@%lu", start ? "+" : "", nr_part,
> >                       next_zero_bit);
> > -             nr_total += nr_part;
> >               start = next_zero_bit + nr_zero;
> >       }
>
> Can you please explain the above change?

Sure - there's no need anymore to keep a count of available pages for
the debug output, since that's already tracked in the available_count
field. So, 'nr_total' can be removed. But you still need to check for
this being the first instance of the loop, so use 'start' for that
instead.
>
> > -     pr_cont("=> %lu free of %lu total pages\n", nr_total, cma->count);
> > +     pr_cont("=> %lu free of %lu total pages\n", cma->available_count,
> > +                     cma->count);
> >       spin_unlock_irq(&cma->lock);
> >  }
> >
> > @@ -446,6 +447,10 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
> >
> >       for (;;) {
> >               spin_lock_irq(&cma->lock);
> > +             if (count > cma->available_count) {
>
> Right here would be a nice place for a comment?
>
Yes, I'll add one.

> > +                     spin_unlock_irq(&cma->lock);
> > +                     break;
> > +             }
> >               bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
> >                               bitmap_maxno, start, bitmap_count, mask,
> >                               offset);
>

I'll re-send a v2 with some Cc: lines added.

Thanks!

- Frank

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ