diff options
author | Miaohe Lin <linmiaohe@huawei.com> | 2022-07-04 16:21:55 +0300 |
---|---|---|
committer | akpm <akpm@linux-foundation.org> | 2022-07-18 03:14:45 +0300 |
commit | 3ce4fee4401206cf5a2c476ec0ee6c90191dfade (patch) | |
tree | 10573cb345959ad3e2d8a557b07c6c9ae3992c8c /include/linux/huge_mm.h | |
parent | 749290799e72f05f7311ec8e85a47664dd7be37e (diff) | |
download | linux-3ce4fee4401206cf5a2c476ec0ee6c90191dfade.tar.xz |
mm/huge_memory: check pmd_present first in is_huge_zero_pmd
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.
Link: https://lkml.kernel.org/r/20220704132201.14611-11-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zach O'Keefe <zokeefe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/huge_mm.h')
-rw-r--r-- | include/linux/huge_mm.h | 2 |
1 files changed, 1 insertions, 1 deletions
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) |