Re: [PATCH v2 1/2] khugepaged: enable collapse pmd for pte-mapped THP

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

 




> On Aug 1, 2019, at 5:43 AM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> 
> On 07/31, Song Liu wrote:
>> 
>> +void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long haddr)
>> +{
>> +	struct vm_area_struct *vma = find_vma(mm, haddr);
>> +	pmd_t *pmd = mm_find_pmd(mm, haddr);
>> +	struct page *hpage = NULL;
>> +	unsigned long addr;
>> +	spinlock_t *ptl;
>> +	int count = 0;
>> +	pmd_t _pmd;
>> +	int i;
>> +
>> +	VM_BUG_ON(haddr & ~HPAGE_PMD_MASK);
>> +
>> +	if (!vma || !pmd || pmd_trans_huge(*pmd))
>                            ^^^^^^^^^^^^^^^^^^^^
> 
> mm_find_pmd() returns NULL if pmd_trans_huge()

Good catch! I will simplify this one in v3. 

> 
>> +	/* step 1: check all mapped PTEs are to the right huge page */
>> +	for (i = 0, addr = haddr; i < HPAGE_PMD_NR; i++, addr += PAGE_SIZE) {
>> +		pte_t *pte = pte_offset_map(pmd, addr);
>> +		struct page *page;
>> +
>> +		if (pte_none(*pte))
>> +			continue;
>> +
>> +		page = vm_normal_page(vma, addr, *pte);
>> +
>> +		if (!PageCompound(page))
>> +			return;
>> +
>> +		if (!hpage) {
>> +			hpage = compound_head(page);
>> +			if (hpage->mapping != vma->vm_file->f_mapping)
> 
> Hmm. But how can we know this is still the same vma ?
> 
> If nothing else, why vma->vm_file can't be NULL?

Good point. We should confirm vma->vm_file is not NULL. 

Thanks,
Song





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux