Message ID | 20220622170627.19786-11-linmiaohe@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | A few cleanup patches for huge_memory | expand |
On Thu, Jun 23, 2022 at 01:06:21AM +0800, Miaohe Lin wrote: > When pmd is non-present, pmd_pfn returns an insane value. So we should Although it does not cause any problems, it is better to check pmd_present() in advance. The change looks good to me. So > check pmd_present first to avoid acquiring such insane value and also > avoid touching possible cold huge_zero_pfn cache line when pmd isn't > present. > > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index ae3d8e2fd9e2..12b297f9951d 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -273,7 +273,7 @@ static inline bool is_huge_zero_page(struct page *page) static inline bool is_huge_zero_pmd(pmd_t pmd) { - return READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd) && pmd_present(pmd); + return pmd_present(pmd) && READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd); } static inline bool is_huge_zero_pud(pud_t pud)
When pmd is non-present, pmd_pfn returns an insane value. So we should check pmd_present first to avoid acquiring such insane value and also avoid touching possible cold huge_zero_pfn cache line when pmd isn't present. Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> --- include/linux/huge_mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)