lkml.org 
[lkml]   [2021]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [External] Re: [PATCH v12 04/13] mm/hugetlb: Free the vmemmap pages associated with each HugeTLB page
On Thu, Jan 14, 2021 at 06:54:30PM +0800, Muchun Song wrote:
> I think this approach may be only suitable for generic huge page only.
> So we can implement it only for huge page.
>
> Hi Oscar,
>
> What's your opinion about this?

I tried something like:

static void vmemmap_pte_range(pmd_t *pmd, unsigned long addr,
unsigned long end,
struct vmemmap_remap_walk *walk)
{
pte_t *pte;

pte = pte_offset_kernel(pmd, addr);

if (!walk->reuse_page) {
BUG_ON(pte_none(*pte));

walk->reuse_page = pte_page(*pte++);
addr = walk->remap_start;
}

for (; addr != end; addr += PAGE_SIZE, pte++) {
BUG_ON(pte_none(*pte));

walk->remap_pte(pte, addr, walk);
}
}

void vmemmap_remap_free(unsigned long start, unsigned long end,
unsigned long reuse)
{
LIST_HEAD(vmemmap_pages);
struct vmemmap_remap_walk walk = {
.remap_pte = vmemmap_remap_pte,
.reuse_addr = reuse,
.remap_start = start,
.vmemmap_pages = &vmemmap_pages,
};

BUG_ON(start != reuse + PAGE_SIZE);

vmemmap_remap_range(reuse, end, &walk);
free_vmemmap_page_list(&vmemmap_pages);
}

but it might overcomplicate things and I am not sure it is any better.
So I am fine with keeping it as is.
Should another user come in the future, we can always revisit.
Maybe just add a little comment in vmemmap_pte_range(), explaining while we
are "+= PAGE_SIZE" for address and I would like to see a comment in
vmemmap_remap_free why the BUG_ON and more important what it is checking.

--
Oscar Salvador
SUSE L3

\
 
 \ /
  Last update: 2021-01-14 12:55    [W:0.060 / U:1.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site