Re: [RFC PATCH 1/5] mm: intorduce __GFP_UNMAPPED and unmapped_alloc()
From: Edgecombe, Rick P
Date: Thu Mar 09 2023 - 10:40:20 EST
On Thu, 2023-03-09 at 16:39 +0200, Mike Rapoport wrote:
> On Thu, Mar 09, 2023 at 01:56:37AM +0000, Edgecombe, Rick P wrote:
> > On Wed, 2023-03-08 at 11:41 +0200, Mike Rapoport wrote:
> > > +
> > > +static inline void __free_one_page(struct page *page, unsigned
> > > int
> > > order,
> > > + bool cache_refill)
> > > +{
> > > + unsigned long pfn = page_to_pfn(page);
> > > + unsigned long buddy_pfn;
> > > + unsigned long combined_pfn;
> > > + struct page *buddy;
> > > + unsigned long flags;
> > > +
> > > + spin_lock_irqsave(&free_area->lock, flags);
> > > +
> > > + if (cache_refill) {
> > > + set_pageblock_unmapped(page);
> > > + free_area[order].nr_cached++;
> > > + }
> > > +
> > > + while (order < MAX_ORDER - 1) {
> > > + buddy = find_unmapped_buddy_page_pfn(page, pfn,
> > > order,
> > > + &buddy_pfn);
> > > + if (!buddy)
> > > + break;
> > > +
> > > + del_page_from_free_list(buddy, order);
> > > + combined_pfn = buddy_pfn & pfn;
> > > + page = page + (combined_pfn - pfn);
> > > + pfn = combined_pfn;
> > > + order++;
> > > + }
> > > +
> > > + set_unmapped_order(page, order);
> > > + add_to_free_list(page, order);
> > > + spin_unlock_irqrestore(&free_area->lock, flags);
> > > +}
> > > +
> >
> > The page has to be zeroed before it goes back on the list, right? I
> > didn't see it.
>
> You are right, I missed it.
The text_poke() family is probably the way on x86, but I don't think
there is a cross-arch way that doesn't involve kernel shootdowns...