Re: [PATCH v9 03/11] mm/hugetlb: Free the vmemmap pages associated with each HugeTLB page

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

 



On Wed, Dec 16, 2020 at 02:08:30PM -0800, Mike Kravetz wrote:
> > + * vmemmap_rmap_walk - walk vmemmap page table
> 
> I am not sure if 'rmap' should be part of these names.  rmap today is mostly
> about reverse mapping lookup.  Did you use rmap for 'remap', or because this
> code is patterned after the page table walking rmap code?  Just think the
> naming could cause some confusion.

I also had the same feeling about the 'rmap' usage.

> > +
> > +static void vmemmap_pte_range(pmd_t *pmd, unsigned long addr,
> > +			      unsigned long end, struct vmemmap_rmap_walk *walk)
> > +{
> > +	pte_t *pte;
> > +
> > +	pte = pte_offset_kernel(pmd, addr);
> > +	do {
> > +		BUG_ON(pte_none(*pte));
> > +
> > +		if (!walk->reuse)
> > +			walk->reuse = pte_page(pte[VMEMMAP_TAIL_PAGE_REUSE]);
> 
> It may be just me, but I don't like the pte[-1] here.  It certainly does work
> as designed because we want to remap all pages in the range to the page before
> the range (at offset -1).  But, we do not really validate this 'reuse' page.
> There is the BUG_ON(pte_none(*pte)) as a sanity check, but we do nothing similar
> for pte[-1].  Based on the usage for HugeTLB pages, we can be confident that
> pte[-1] is actually a pte.  In discussions with Oscar, you mentioned another
> possible use for these routines.

Without giving it much of a thought, I guess we could duplicate the
BUG_ON for the pte outside the loop, and add a new one for pte[-1].
Also, since walk->reuse seems to not change once it is set, we can take
it outside the loop? e.g:

	pte *pte;

	pte = pte_offset_kernel(pmd, addr);
	BUG_ON(pte_none(*pte));
	BUG_ON(pte_none(pte[VMEMMAP_TAIL_PAGE_REUSE]));
	walk->reuse = pte_page(pte[VMEMMAP_TAIL_PAGE_REUSE]);
	do {
		....
	} while...

Or I am not sure whether we want to keep it inside the loop in case
future cases change walk->reuse during the operation.
But to be honest, I do not think it is realistic of all future possible
uses of this, so I would rather keep it simple for now.

-- 
Oscar Salvador
SUSE L3



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux