Re: [PATCHv6 1/1] mm: optimization on page allocation when CMA enabled

From: Zhaoyang Huang
Date: Tue Jan 02 2024 - 00:50:37 EST


On Sat, Dec 30, 2023 at 3:40 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, 8 Nov 2023 16:55:19 +0800 Zhaoyang Huang <huangzhaoyang@xxxxxxxxx> wrote:
>
> > > > +static bool use_cma_first(struct zone *zone, unsigned int order, unsigned int alloc_flags)
> > > > +{
> > > > + unsigned long watermark;
> > > > + bool cma_first = false;
> > > > +
> > > > + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
> > > > + /* check if GFP_MOVABLE pass previous zone_watermark_ok via the help of CMA */
> > > > + if (zone_watermark_ok(zone, order, watermark, 0, alloc_flags & (~ALLOC_CMA))) {
> > > > + /*
> > > > + * Balance movable allocations between regular and CMA areas by
> > > > + * allocating from CMA when over half of the zone's free memory
> > > > + * is in the CMA area.
> > > > + */
> > ok, thanks for point out.
> > Could we simple it like this, which will mis-judge kmalloc within
> > ioctl as GFP_USER. I think it is ok as it is rare
> > if (current_is_kswapd() || !current->mm)
> > gfp_flags = GFP_KERNEL;
> > else
> > gfp_flags = GFP_USER;
> > free_pages = zone_page_state(zone, NR_FREE_PAGES);
> > free_pages -= zone->lowmem_reserve[gfp_zone(gfp_flags)];
> > free_pages -= wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
> > cma_first = free_pages > zone_page_state(zone, NR_FREE_PAGES) / 2);
> >
>
> This went all quiet. Do we feel that "mm: optimization on page
> allocation when CMA enabled" should be merged as-is, or dropped in the
> expectation that something based on Johannes's suggestion will be
> developed?
I just establish a v6.6 environment and will provide comparison
results with and without the patch
>