Message ID | 20200317131753.4074-2-srikar@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix kmalloc_node on offline nodes | expand |
* Srikar Dronamraju <srikar@linux.vnet.ibm.com> [2020-03-17 18:47:50]: > > Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com> > Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com> > Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> > --- > include/linux/mmzone.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index f3f264826423..88078a3b95e5 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -756,8 +756,10 @@ typedef struct pglist_data { > atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS]; > } pg_data_t; > > -#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) > -#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) > +#define node_present_pages(nid) \ > + (node_online(nid) ? NODE_DATA(nid)->node_present_pages : 0) > +#define node_spanned_pages(nid) \ > + (node_online(nid) ? NODE_DATA(nid)->node_spanned_pages : 0) > #ifdef CONFIG_FLAT_NODE_MEM_MAP > #define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr)) > #else If we indeed start having pgdat/NODE_DATA for even offline nodes as Michal Hocko, then we may not this particular patch.
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f3f264826423..88078a3b95e5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -756,8 +756,10 @@ typedef struct pglist_data { atomic_long_t vm_stat[NR_VM_NODE_STAT_ITEMS]; } pg_data_t; -#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) -#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) +#define node_present_pages(nid) \ + (node_online(nid) ? NODE_DATA(nid)->node_present_pages : 0) +#define node_spanned_pages(nid) \ + (node_online(nid) ? NODE_DATA(nid)->node_spanned_pages : 0) #ifdef CONFIG_FLAT_NODE_MEM_MAP #define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr)) #else