From: Jingqi Liu <jingqi.liu@xxxxxxxxx> ept-idle will clear PMD accessed bit to speedup PTE scan -- if the bit remains unset in the next scan, all the 512 PTEs can be skipped. So don't complain on !_PAGE_ACCESSED in pmd_bad(). Note that clearing PMD accessed bit has its own cost, the optimization may only be worthwhile for - large idle area - sparsely populated area Signed-off-by: Jingqi Liu <jingqi.liu@xxxxxxxxx> Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx> --- arch/x86/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- linux.orig/arch/x86/include/asm/pgtable.h 2018-12-23 19:50:50.917902600 +0800 +++ linux/arch/x86/include/asm/pgtable.h 2018-12-23 19:50:50.913902605 +0800 @@ -821,7 +821,8 @@ static inline pte_t *pte_offset_kernel(p static inline int pmd_bad(pmd_t pmd) { - return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE; + return (pmd_flags(pmd) & ~(_PAGE_USER | _PAGE_ACCESSED)) != + (_KERNPG_TABLE & ~_PAGE_ACCESSED); } static inline unsigned long pages_to_mb(unsigned long npg)