# \[patch 127/192\] mm/swap: make NODE\_DATA an inline function on CONFIG\_FLATMEM

- From: Andrew Morton \<akpm@linux-foundation.org\>
- Date: 2021-07-01 01:53:59 
- List: linux-mm
- Page: https://ratatoskr.run/linux-mm/2021/07/6509519
- Thread: https://ratatoskr.run/linux-mm/2021/07/6509393/t/2.md

```text
From: Mel Gorman <redacted>
Subject: mm/swap: make NODE_DATA an inline function on CONFIG_FLATMEM

make W=1 generates the following warning in mm/workingset.c for allnoconfig

  mm/workingset.c: In function `unpack_shadow':
  mm/workingset.c:201:15: warning: variable `nid' set but not used [-Wunused-but-set-variable]
    int memcgid, nid;
                 ^~~

On FLATMEM, NODE_DATA returns a global pglist_data without dereferencing
nid.  Make the helper an inline function to suppress the warning, add type
checking and to apply any side-effects in the parameter list.

Link: https://lkml.kernel.org/r/20210520084809.8576-15-mgorman@techsingularity.net
Signed-off-by: Mel Gorman <redacted>
Reviewed-by: Yang Shi <redacted>
Acked-by: Vlastimil Babka <redacted>
Cc: Dan Streetman <redacted>
Cc: David Hildenbrand <redacted>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/mmzone.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/include/linux/mmzone.h~mm-swap-make-node_data-an-inline-function-on-config_flatmem
+++ a/include/linux/mmzone.h
@@ -1064,7 +1064,10 @@ extern char numa_zonelist_order[];
 #ifndef CONFIG_NUMA
 
 extern struct pglist_data contig_page_data;
-#define NODE_DATA(nid)		(&contig_page_data)
+static inline struct pglist_data *NODE_DATA(int nid)
+{
+	return &contig_page_data;
+}
 #define NODE_MEM_MAP(nid)	mem_map
 
 #else /* CONFIG_NUMA */
_

```
