Re: [PATCH v7 06/10] mm: thp: check pmd migration entry in common path

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

 



On 21 Jun 2017, at 7:49, Kirill A. Shutemov wrote:

> On Tue, Jun 20, 2017 at 07:07:11PM -0400, Zi Yan wrote:
>> @@ -1220,6 +1238,9 @@ int do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd)
>>  	if (unlikely(!pmd_same(*vmf->pmd, orig_pmd)))
>>  		goto out_unlock;
>>
>> +	if (unlikely(!pmd_present(orig_pmd)))
>> +		goto out_unlock;
>> +
>
> Hm. Shouldn't we wait for the page here?

Thanks for pointing this out.

This chunk is unnecessary, since do_huge_pmd_wp_page() is called by wp_huge_pmd(),
which is called only when orig_pmd is present. Thus, this code is useless.
And pmd_same() will also preclude vmf->pmd from not present.


>>  	page = pmd_page(orig_pmd);
>>  	VM_BUG_ON_PAGE(!PageCompound(page) || !PageHead(page), page);
>>  	/*
>> @@ -1556,6 +1577,12 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
>>  	if (is_huge_zero_pmd(orig_pmd))
>>  		goto out;
>>
>> +	if (unlikely(!pmd_present(orig_pmd))) {
>> +		VM_BUG_ON(IS_ENABLED(CONFIG_MIGRATION) &&
>> +				  !is_pmd_migration_entry(orig_pmd));
>> +		goto out;
>> +	}
>> +
>>  	page = pmd_page(orig_pmd);
>>  	/*
>>  	 * If other processes are mapping this page, we couldn't discard
>> @@ -1770,6 +1797,23 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
>>  	preserve_write = prot_numa && pmd_write(*pmd);
>>  	ret = 1;
>>
>> +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
>> +	if (is_swap_pmd(*pmd)) {
>> +		swp_entry_t entry = pmd_to_swp_entry(*pmd);
>> +
>> +		VM_BUG_ON(IS_ENABLED(CONFIG_MIGRATION) &&
>> +				  !is_pmd_migration_entry(*pmd));
>> +		if (is_write_migration_entry(entry)) {
>> +			pmd_t newpmd;
>> +
>> +			make_migration_entry_read(&entry);
>> +			newpmd = swp_entry_to_pmd(entry);
>> +			set_pmd_at(mm, addr, pmd, newpmd);
>
> I was confused by this. Could you copy comment from change_pte_range()
> here?

Sure. Will do.

>> +		}
>> +		goto unlock;
>> +	}
>> +#endif
>> +
>>  	/*
>>  	 * Avoid trapping faults against the zero page. The read-only
>>  	 * data is likely to be read-cached on the local CPU and

Thanks for your review.

--
Best Regards
Yan Zi

Attachment: signature.asc
Description: OpenPGP digital signature


[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