diff mbox series

MIPS: fix pmd_mkinvalid

Message ID 1653971769-14152-1-git-send-email-zhanghongchen@loongson.cn (mailing list archive)
State Superseded
Headers show
Series MIPS: fix pmd_mkinvalid | expand

Commit Message

Hongchen Zhang May 31, 2022, 4:36 a.m. UTC
pmd_mkinvalid should not clear dirty flag,otherwise the pmd
dirty flag,it's ok to just clear _PAGE_VALID.

Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
 arch/mips/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiaxun Yang May 31, 2022, 3:40 p.m. UTC | #1
在 2022/5/31 5:36, Hongchen Zhang 写道:
> pmd_mkinvalid should not clear dirty flag,otherwise the pmd
> dirty flag,it's ok to just clear _PAGE_VALID.
Hi Hongcheng,

Sorry, what is meant by "otherwise the pmd dirty flag"? Could you please
elaborate?
In my humble opinion _PAGE_PRESENT must be cleared in mkinvalid as it
nolonger present here. And thus it lose the dirty status.

Thanks
- Jiaxun

> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
> ---
>   arch/mips/include/asm/pgtable.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
> index 374c632..d30a186 100644
> --- a/arch/mips/include/asm/pgtable.h
> +++ b/arch/mips/include/asm/pgtable.h
> @@ -698,7 +698,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
>   
>   static inline pmd_t pmd_mkinvalid(pmd_t pmd)
>   {
> -	pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY);
> +	pmd_val(pmd) &= ~_PAGE_VALID;
>   
>   	return pmd;
>   }
Hongchen Zhang June 1, 2022, 12:55 a.m. UTC | #2
On 2022/5/31 下午11:40, Jiaxun Yang wrote:
> 
> 
> 在 2022/5/31 5:36, Hongchen Zhang 写道:
>> pmd_mkinvalid should not clear dirty flag,otherwise the pmd
>> dirty flag,it's ok to just clear _PAGE_VALID.
> Hi Hongcheng,
> 
> Sorry, what is meant by "otherwise the pmd dirty flag"? Could you please
> elaborate?
> In my humble opinion _PAGE_PRESENT must be cleared in mkinvalid as it
> nolonger present here. And thus it lose the dirty status.
> 
> Thanks
> - Jiaxun
> 
>> Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
>> ---
>>   arch/mips/include/asm/pgtable.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/include/asm/pgtable.h 
>> b/arch/mips/include/asm/pgtable.h
>> index 374c632..d30a186 100644
>> --- a/arch/mips/include/asm/pgtable.h
>> +++ b/arch/mips/include/asm/pgtable.h
>> @@ -698,7 +698,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t 
>> newprot)
>>   static inline pmd_t pmd_mkinvalid(pmd_t pmd)
>>   {
>> -    pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY);
>> +    pmd_val(pmd) &= ~_PAGE_VALID;
>>       return pmd;
>>   }
Hi Jiaxun,

Refer to [ https://lkml.org/lkml/2018/10/17/231 ],Andrea said "
The clear of the real present bit during pmd (virtual) splitting is
done with pmdp_invalidate, that is created specifically to keeps
pmd_trans_huge=true, pmd_present=true despite the present bit is not
set. ". So it's wrong to clear _PAGE_PRESENT,because this will make 
pmd_present=false.

On the other hand, There is no need to clear dirty flag too.

Thanks.
diff mbox series

Patch

diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index 374c632..d30a186 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -698,7 +698,7 @@  static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 
 static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 {
-	pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY);
+	pmd_val(pmd) &= ~_PAGE_VALID;
 
 	return pmd;
 }