* [PATCH] MIPS: fix pmd_mkinvalid
@ 2022-07-07 8:11 Hongchen Zhang
2022-07-07 9:22 ` Thomas Bogendoerfer
0 siblings, 1 reply; 11+ messages in thread
From: Hongchen Zhang @ 2022-07-07 8:11 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel, Hongchen Zhang
When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
return true.
So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
present but invalidated by pmd_mkinvalid.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
arch/mips/include/asm/pgtable-64.h | 2 +-
arch/mips/include/asm/pgtable-bits.h | 2 ++
arch/mips/include/asm/pgtable.h | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 41921ac..050cf66 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -265,7 +265,7 @@ static inline int pmd_present(pmd_t pmd)
{
#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
- return pmd_val(pmd) & _PAGE_PRESENT;
+ return pmd_val(pmd) & (_PAGE_PRESENT | _PMD_PRESENT_INVALID);
#endif
return pmd_val(pmd) != (unsigned long) invalid_pte_table;
diff --git a/arch/mips/include/asm/pgtable-bits.h b/arch/mips/include/asm/pgtable-bits.h
index 2362842..72cd88a 100644
--- a/arch/mips/include/asm/pgtable-bits.h
+++ b/arch/mips/include/asm/pgtable-bits.h
@@ -130,6 +130,7 @@ enum pgtable_bits {
_PAGE_MODIFIED_SHIFT,
#if defined(CONFIG_MIPS_HUGE_TLB_SUPPORT)
_PAGE_HUGE_SHIFT,
+ _PMD_PRESENT_INVALID_SHIFT,
#endif
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
_PAGE_SPECIAL_SHIFT,
@@ -157,6 +158,7 @@ enum pgtable_bits {
#define _PAGE_MODIFIED (1 << _PAGE_MODIFIED_SHIFT)
#if defined(CONFIG_MIPS_HUGE_TLB_SUPPORT)
# define _PAGE_HUGE (1 << _PAGE_HUGE_SHIFT)
+#define _PMD_PRESENT_INVALID (1 << _PMD_PRESENT_INVALID_SHIFT)
#endif
#if defined(CONFIG_ARCH_HAS_PTE_SPECIAL)
# define _PAGE_SPECIAL (1 << _PAGE_SPECIAL_SHIFT)
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index 374c632..a75f461 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -696,12 +696,15 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
return pmd;
}
+#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
static inline pmd_t pmd_mkinvalid(pmd_t pmd)
{
+ pmd_val(pmd) |= _PMD_PRESENT_INVALID;
pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY);
return pmd;
}
+#endif
/*
* The generic version pmdp_huge_get_and_clear uses a version of pmd_clear() with a
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-07 8:11 [PATCH] MIPS: fix pmd_mkinvalid Hongchen Zhang
@ 2022-07-07 9:22 ` Thomas Bogendoerfer
2022-07-07 11:12 ` Hongchen Zhang
0 siblings, 1 reply; 11+ messages in thread
From: Thomas Bogendoerfer @ 2022-07-07 9:22 UTC (permalink / raw)
To: Hongchen Zhang; +Cc: linux-mips, linux-kernel
On Thu, Jul 07, 2022 at 04:11:35PM +0800, Hongchen Zhang wrote:
> When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
> return true.
> So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
> present but invalidated by pmd_mkinvalid.
What problem are you trying to fix ? What are the symptoms ?
> Reported-by: kernel test robot <lkp@intel.com>
the test robot showed problems with your last version of the patch,
which hasn't been integrated into at least the MIPS tree, so no
need to that.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-07 9:22 ` Thomas Bogendoerfer
@ 2022-07-07 11:12 ` Hongchen Zhang
2022-07-12 10:01 ` Hongchen Zhang
0 siblings, 1 reply; 11+ messages in thread
From: Hongchen Zhang @ 2022-07-07 11:12 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel
On 2022/7/7 下午5:22, Thomas Bogendoerfer wrote:
> On Thu, Jul 07, 2022 at 04:11:35PM +0800, Hongchen Zhang wrote:
>> When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
>> return true.
>> So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
>> present but invalidated by pmd_mkinvalid.
>
> What problem are you trying to fix ? What are the symptoms ?
>
>> Reported-by: kernel test robot <lkp@intel.com>
>
> the test robot showed problems with your last version of the patch,
> which hasn't been integrated into at least the MIPS tree, so no
> need to that.
>
> Thomas.
>
Hi Thomas,
The idea come from the commit:
b65399f6111b(arm64/mm: Change THP helpers to comply with generic MM
semantics).
There is an problem now:
CPU 0 CPU 1
pmdp_invalidate do_page_fault
... __handle_mm_fault
is_swap_pmd == true
trigger VM_BUG_ON() ?
set_pmd_at
the reason is that pmd_present return true,after this commit
pmd_present will return false,and the VM_BUG_ON will not be triggered.
Like arm64 does,we can introduce a new bit to fix this.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-07 11:12 ` Hongchen Zhang
@ 2022-07-12 10:01 ` Hongchen Zhang
2022-07-12 11:19 ` Thomas Bogendoerfer
0 siblings, 1 reply; 11+ messages in thread
From: Hongchen Zhang @ 2022-07-12 10:01 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel
On 2022/7/7 下午7:12, Hongchen Zhang wrote:
> On 2022/7/7 下午5:22, Thomas Bogendoerfer wrote:
>> On Thu, Jul 07, 2022 at 04:11:35PM +0800, Hongchen Zhang wrote:
>>> When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
>>> return true.
>>> So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
>>> present but invalidated by pmd_mkinvalid.
>>
>> What problem are you trying to fix ? What are the symptoms ?
>>
>>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> the test robot showed problems with your last version of the patch,
>> which hasn't been integrated into at least the MIPS tree, so no
>> need to that.
>>
>> Thomas.
>>
>
> Hi Thomas,
> The idea come from the commit:
> b65399f6111b(arm64/mm: Change THP helpers to comply with generic MM
> semantics).
> There is an problem now:
> CPU 0 CPU 1
> pmdp_invalidate do_page_fault
> ... __handle_mm_fault
> is_swap_pmd == true
> trigger VM_BUG_ON() ?
> set_pmd_at
> the reason is that pmd_present return true,after this commit
> pmd_present will return false,and the VM_BUG_ON will not be triggered.
> Like arm64 does,we can introduce a new bit to fix this.
>
> Thanks.
Hi Thomas,
Is there problem of this patch? What's your opinion of this patch?
Thanks
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-12 10:01 ` Hongchen Zhang
@ 2022-07-12 11:19 ` Thomas Bogendoerfer
2022-07-12 12:08 ` Hongchen Zhang
0 siblings, 1 reply; 11+ messages in thread
From: Thomas Bogendoerfer @ 2022-07-12 11:19 UTC (permalink / raw)
To: Hongchen Zhang; +Cc: linux-mips, linux-kernel
On Tue, Jul 12, 2022 at 06:01:08PM +0800, Hongchen Zhang wrote:
> On 2022/7/7 下午7:12, Hongchen Zhang wrote:
> > On 2022/7/7 下午5:22, Thomas Bogendoerfer wrote:
> > > On Thu, Jul 07, 2022 at 04:11:35PM +0800, Hongchen Zhang wrote:
> > > > When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
> > > > return true.
> > > > So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
> > > > present but invalidated by pmd_mkinvalid.
> > >
> > > What problem are you trying to fix ? What are the symptoms ?
> > >
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > the test robot showed problems with your last version of the patch,
> > > which hasn't been integrated into at least the MIPS tree, so no
> > > need to that.
> > >
> > > Thomas.
> > >
> >
> > Hi Thomas,
> > The idea come from the commit:
> > b65399f6111b(arm64/mm: Change THP helpers to comply with generic MM
> > semantics).
> > There is an problem now:
> > CPU 0 CPU 1
> > pmdp_invalidate do_page_fault
> > ... __handle_mm_fault
> > is_swap_pmd == true
> > trigger VM_BUG_ON() ?
> > set_pmd_at
> > the reason is that pmd_present return true,after this commit
> > pmd_present will return false,and the VM_BUG_ON will not be triggered.
> > Like arm64 does,we can introduce a new bit to fix this.
> >
> > Thanks.
> Hi Thomas,
> Is there problem of this patch? What's your opinion of this patch?
I haven't dig deeper into it, but needing more page bits is a pain
for 32bit kernel and would make it nearly impossible to get huge
page support there. And the description you gave me, needs to be
in the commit description.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-12 11:19 ` Thomas Bogendoerfer
@ 2022-07-12 12:08 ` Hongchen Zhang
0 siblings, 0 replies; 11+ messages in thread
From: Hongchen Zhang @ 2022-07-12 12:08 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel
On 2022/7/12 下午7:19, Thomas Bogendoerfer wrote:
> On Tue, Jul 12, 2022 at 06:01:08PM +0800, Hongchen Zhang wrote:
>> On 2022/7/7 下午7:12, Hongchen Zhang wrote:
>>> On 2022/7/7 下午5:22, Thomas Bogendoerfer wrote:
>>>> On Thu, Jul 07, 2022 at 04:11:35PM +0800, Hongchen Zhang wrote:
>>>>> When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
>>>>> return true.
>>>>> So introduce a _PMD_PRESENT_INVALID_SHIFT bit to check if a pmd is
>>>>> present but invalidated by pmd_mkinvalid.
>>>>
>>>> What problem are you trying to fix ? What are the symptoms ?
>>>>
>>>>> Reported-by: kernel test robot <lkp@intel.com>
>>>>
>>>> the test robot showed problems with your last version of the patch,
>>>> which hasn't been integrated into at least the MIPS tree, so no
>>>> need to that.
>>>>
>>>> Thomas.
>>>>
>>>
>>> Hi Thomas,
>>> The idea come from the commit:
>>> b65399f6111b(arm64/mm: Change THP helpers to comply with generic MM
>>> semantics).
>>> There is an problem now:
>>> CPU 0 CPU 1
>>> pmdp_invalidate do_page_fault
>>> ... __handle_mm_fault
>>> is_swap_pmd == true
>>> trigger VM_BUG_ON() ?
>>> set_pmd_at
>>> the reason is that pmd_present return true,after this commit
>>> pmd_present will return false,and the VM_BUG_ON will not be triggered.
>>> Like arm64 does,we can introduce a new bit to fix this.
>>>
>>> Thanks.
>> Hi Thomas,
>> Is there problem of this patch? What's your opinion of this patch?
>
> I haven't dig deeper into it, but needing more page bits is a pain
> for 32bit kernel and would make it nearly impossible to get huge
> page support there. And the description you gave me, needs to be
> in the commit description.
>
> Thomas.
>
Hi Thomas,
Thanks for your patiently review. For your question,
1. I think there may be problem when compile 32bit kernel with huge
page support,because _PAGE_HUGE_SHIFT is only defined for R4K now.
2. I will modify the commit as you said and make a v2 patch.
Thanks.
Hongchen Zhang
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-07-06 9:07 Hongchen Zhang
@ 2022-07-06 19:23 ` kernel test robot
0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2022-07-06 19:23 UTC (permalink / raw)
To: Hongchen Zhang, Thomas Bogendoerfer
Cc: llvm, kbuild-all, linux-mips, linux-kernel, Hongchen Zhang
Hi Hongchen,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.19-rc5 next-20220706]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Hongchen-Zhang/MIPS-fix-pmd_mkinvalid/20220706-171327
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e35e5b6f695d241ffb1d223207da58a1fbcdff4b
config: mips-maltaaprp_defconfig (https://download.01.org/0day-ci/archive/20220707/202207070340.HGbiEUlO-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project f553287b588916de09c66e3e32bf75e5060f967f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mipsel-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/cc17741b8218515ea05dd64f5db2402a67e7a821
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Hongchen-Zhang/MIPS-fix-pmd_mkinvalid/20220706-171327
git checkout cc17741b8218515ea05dd64f5db2402a67e7a821
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
arch/mips/mm/init.c:60:6: warning: no previous prototype for function 'setup_zero_pages' [-Wmissing-prototypes]
void setup_zero_pages(void)
^
arch/mips/mm/init.c:60:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void setup_zero_pages(void)
^
static
>> arch/mips/mm/init.c:454:2: error: call to __compiletime_assert_347 declared with 'error' attribute: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT)
BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT));
^
include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^
include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^
include/linux/compiler_types.h:354:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:342:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:335:4: note: expanded from macro '__compiletime_assert'
prefix ## suffix(); \
^
<scratch space>:174:1: note: expanded from here
__compiletime_assert_347
^
1 warning and 1 error generated.
vim +/error +454 arch/mips/mm/init.c
1132137e87898d Jiang Liu 2013-07-03 447
1132137e87898d Jiang Liu 2013-07-03 448 void __init mem_init(void)
1132137e87898d Jiang Liu 2013-07-03 449 {
05d013a0366d50 Paul Burton 2019-09-18 450 /*
05d013a0366d50 Paul Burton 2019-09-18 451 * When _PFN_SHIFT is greater than PAGE_SHIFT we won't have enough PTE
05d013a0366d50 Paul Burton 2019-09-18 452 * bits to hold a full 32b physical address on MIPS32 systems.
05d013a0366d50 Paul Burton 2019-09-18 453 */
05d013a0366d50 Paul Burton 2019-09-18 @454 BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT));
05d013a0366d50 Paul Burton 2019-09-18 455
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] MIPS: fix pmd_mkinvalid
@ 2022-07-06 9:07 Hongchen Zhang
2022-07-06 19:23 ` kernel test robot
0 siblings, 1 reply; 11+ messages in thread
From: Hongchen Zhang @ 2022-07-06 9:07 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel, Hongchen Zhang
When a pmd entry is invalidated by pmd_mkinvalid,pmd_present should
return true.
So introduce a _PAGE_PRESENT_INVALID_SHIFT bit to check if a pmd is
present but invalidated by pmd_mkinvalid.
Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
arch/mips/include/asm/pgtable-64.h | 2 +-
arch/mips/include/asm/pgtable-bits.h | 5 +++++
arch/mips/include/asm/pgtable.h | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 41921ac..1c5ef41 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -265,7 +265,7 @@ static inline int pmd_present(pmd_t pmd)
{
#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
- return pmd_val(pmd) & _PAGE_PRESENT;
+ return pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PRESENT_INVALID);
#endif
return pmd_val(pmd) != (unsigned long) invalid_pte_table;
diff --git a/arch/mips/include/asm/pgtable-bits.h b/arch/mips/include/asm/pgtable-bits.h
index 2362842..3c176a1e 100644
--- a/arch/mips/include/asm/pgtable-bits.h
+++ b/arch/mips/include/asm/pgtable-bits.h
@@ -49,6 +49,7 @@ enum pgtable_bits {
/* Used only by software (masked out before writing EntryLo*) */
_PAGE_PRESENT_SHIFT = 24,
+ _PAGE_PRESENT_INVALID_SHIFT,
_PAGE_WRITE_SHIFT,
_PAGE_ACCESSED_SHIFT,
_PAGE_MODIFIED_SHIFT,
@@ -80,6 +81,7 @@ enum pgtable_bits {
/* Used only by software (masked out before writing EntryLo*) */
_PAGE_PRESENT_SHIFT = _CACHE_SHIFT + 3,
+ _PAGE_PRESENT_INVALID_SHIFT,
_PAGE_NO_READ_SHIFT,
_PAGE_WRITE_SHIFT,
_PAGE_ACCESSED_SHIFT,
@@ -98,6 +100,7 @@ enum pgtable_bits {
enum pgtable_bits {
/* Used only by software (writes to EntryLo ignored) */
_PAGE_PRESENT_SHIFT,
+ _PAGE_PRESENT_INVALID_SHIFT,
_PAGE_NO_READ_SHIFT,
_PAGE_WRITE_SHIFT,
_PAGE_ACCESSED_SHIFT,
@@ -122,6 +125,7 @@ enum pgtable_bits {
enum pgtable_bits {
/* Used only by software (masked out before writing EntryLo*) */
_PAGE_PRESENT_SHIFT,
+ _PAGE_PRESENT_INVALID_SHIFT,
#if !defined(CONFIG_CPU_HAS_RIXI)
_PAGE_NO_READ_SHIFT,
#endif
@@ -152,6 +156,7 @@ enum pgtable_bits {
/* Used only by software */
#define _PAGE_PRESENT (1 << _PAGE_PRESENT_SHIFT)
+#define _PAGE_PRESENT_INVALID (1 << _PAGE_PRESENT_INVALID_SHIFT)
#define _PAGE_WRITE (1 << _PAGE_WRITE_SHIFT)
#define _PAGE_ACCESSED (1 << _PAGE_ACCESSED_SHIFT)
#define _PAGE_MODIFIED (1 << _PAGE_MODIFIED_SHIFT)
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index 374c632..cc80211 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -698,7 +698,8 @@ 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_PRESENT_INVALID;
+ pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID);
return pmd;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-05-31 15:40 ` Jiaxun Yang
@ 2022-06-01 0:55 ` Hongchen Zhang
0 siblings, 0 replies; 11+ messages in thread
From: Hongchen Zhang @ 2022-06-01 0:55 UTC (permalink / raw)
To: Jiaxun Yang, Thomas Bogendoerfer, Matthew Wilcox (Oracle),
Zhaolong Zhang
Cc: linux-mips, linux-kernel
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MIPS: fix pmd_mkinvalid
2022-05-31 4:36 Hongchen Zhang
@ 2022-05-31 15:40 ` Jiaxun Yang
2022-06-01 0:55 ` Hongchen Zhang
0 siblings, 1 reply; 11+ messages in thread
From: Jiaxun Yang @ 2022-05-31 15:40 UTC (permalink / raw)
To: Hongchen Zhang, Thomas Bogendoerfer, Matthew Wilcox (Oracle),
Zhaolong Zhang
Cc: linux-mips, linux-kernel
在 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;
> }
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] MIPS: fix pmd_mkinvalid
@ 2022-05-31 4:36 Hongchen Zhang
2022-05-31 15:40 ` Jiaxun Yang
0 siblings, 1 reply; 11+ messages in thread
From: Hongchen Zhang @ 2022-05-31 4:36 UTC (permalink / raw)
To: Thomas Bogendoerfer, Matthew Wilcox (Oracle), Zhaolong Zhang
Cc: linux-mips, linux-kernel, Hongchen Zhang
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(-)
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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-07-12 12:08 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 8:11 [PATCH] MIPS: fix pmd_mkinvalid Hongchen Zhang
2022-07-07 9:22 ` Thomas Bogendoerfer
2022-07-07 11:12 ` Hongchen Zhang
2022-07-12 10:01 ` Hongchen Zhang
2022-07-12 11:19 ` Thomas Bogendoerfer
2022-07-12 12:08 ` Hongchen Zhang
-- strict thread matches above, loose matches on Subject: below --
2022-07-06 9:07 Hongchen Zhang
2022-07-06 19:23 ` kernel test robot
2022-05-31 4:36 Hongchen Zhang
2022-05-31 15:40 ` Jiaxun Yang
2022-06-01 0:55 ` Hongchen Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.