mm: fix potential build error in compaction.h
PATCH 1/1 mm: fix potential build error in compaction.h
Declaration of struct node is required regardless. On UMA system, including compaction.h without proceeding node.h shouldn't cause build error.
--- include/linux/compaction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compaction.h +1 -1
@@ -220,22 +220,22 @@ static inline int kcompactd_run(int nid)static inline void kcompactd_stop (int nid) { }static inline void wakeup_kcompactd (pg_data_t *pgdat,int order,int classzone_idx) { }#endif /* CONFIG_COMPACTION */ -#if defined(CONFIG_COMPACTION ) && defined(CONFIG_SYSFS ) && defined(CONFIG_NUMA )struct node ; +#if defined(CONFIG_COMPACTION ) && defined(CONFIG_SYSFS ) && defined(CONFIG_NUMA )extern int compaction_register_node (struct node *node);extern void compaction_unregister_node (struct node *node);#else static inline int compaction_register_node (struct node *node) {return 0 ; }
Signature · 1 line
2.20.1.791.gb4d0f1c61a-goog
Quoted 3 lines · Yu Zhao
Declaration of struct node is required regardless. On UMA system, including
compaction.hwithout proceedingnode.hshouldn't cause build error.
Anybody requiring struct node shouldn't depend on compaction.h to get the declaration. Anyway have you seen an actual build breakage?
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 7 lines · Michal Hocko
Quoted 3 lines · Yu Zhao
Declaration of struct node is required regardless. On UMA system, including
compaction.hwithout proceedingnode.hshouldn't cause build error.Anybody requiring struct node shouldn't depend on
compaction.hto get the declaration.
Yes, but the problem is the other way around. Build error happens when somebody includes compaction.h without definition or declaration of struct node, if CONFIG_NUMA is not set.
compaction.h already has struct node declaration to avoid the error when CONFIG_NUMA is set, but we need it for both cases.
Quoted 1 line
Anyway have you seen an actual build breakage?
Yes. I ran into the problem while trying to include compaction.h in this order, and had to move it to the bottom as a workaround.
#include <linux/backing-dev.h>
#include <linux/compaction.h>
#include <linux/ctype.h>
#include <linux/freezer.h>
#include <linux/hugetlb.h>
#include <linux/kstaled.h>
#include <linux/kthread.h>
#include <linux/mm_inline.h>
#include <linux/mm_types.h>
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/sched/task_stack.h>
#include <linux/swap.h>
Michal Hocko
Acked-byQuoted 21 lines · Yu Zhao
Quoted 7 lines · Michal Hocko
Quoted 3 lines · Yu Zhao
Declaration of struct node is required regardless. On UMA system, including
compaction.hwithout proceedingnode.hshouldn't cause build error.Anybody requiring struct node shouldn't depend on
compaction.hto get the declaration.Yes, but the problem is the other way around. Build error happens when somebody includes
compaction.hwithout definition or declaration of struct node, ifCONFIG_NUMAis not set.
compaction.halready has struct node declaration to avoid the error whenCONFIG_NUMAis set, but we need it for both cases.Quoted 1 line
Anyway have you seen an actual build breakage?
Yes. I ran into the problem while trying to include
compaction.hin this order, and had to move it to the bottom as a workaround.
Quoted 13 lines
#include <
linux/backing-dev.h>
#include <linux/compaction.h>
#include <linux/ctype.h>
#include <linux/freezer.h>
#include <linux/hugetlb.h>
#include <linux/kstaled.h>
#include <linux/kthread.h>
#include <linux/mm_inline.h>
#include <linux/mm_types.h>
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/sched/task_stack.h>
#include <linux/swap.h>
OK, fair enough. A subtle header file ordering dependencies are PITA.
Signature · 2 lines
Michal Hocko SUSE Labs