提交 ae70eddd 编写于 作者: A Anshuman Khandual 提交者: Linus Torvalds

mm/page_alloc: restrict and formalize compound_page_dtors[]

Restrict elements in compound_page_dtors[] array per NR_COMPOUND_DTORS and
explicitly position them according to enum compound_dtor_id.  This
improves protection against possible misalignment between
compound_page_dtors[] and enum compound_dtor_id later on.
Signed-off-by: NAnshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: NDavid Hildenbrand <david@redhat.com>
Link: http://lkml.kernel.org/r/1589795958-19317-1-git-send-email-anshuman.khandual@arm.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 aa092591
...@@ -867,7 +867,7 @@ enum compound_dtor_id { ...@@ -867,7 +867,7 @@ enum compound_dtor_id {
#endif #endif
NR_COMPOUND_DTORS, NR_COMPOUND_DTORS,
}; };
extern compound_page_dtor * const compound_page_dtors[]; extern compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS];
static inline void set_compound_page_dtor(struct page *page, static inline void set_compound_page_dtor(struct page *page,
enum compound_dtor_id compound_dtor) enum compound_dtor_id compound_dtor)
......
...@@ -302,14 +302,14 @@ const char * const migratetype_names[MIGRATE_TYPES] = { ...@@ -302,14 +302,14 @@ const char * const migratetype_names[MIGRATE_TYPES] = {
#endif #endif
}; };
compound_page_dtor * const compound_page_dtors[] = { compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS] = {
NULL, [NULL_COMPOUND_DTOR] = NULL,
free_compound_page, [COMPOUND_PAGE_DTOR] = free_compound_page,
#ifdef CONFIG_HUGETLB_PAGE #ifdef CONFIG_HUGETLB_PAGE
free_huge_page, [HUGETLB_PAGE_DTOR] = free_huge_page,
#endif #endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
free_transhuge_page, [TRANSHUGE_PAGE_DTOR] = free_transhuge_page,
#endif #endif
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册