Re: mm/ksm.c:492: error: implicit declaration of function ʽpfn_to_nidʼ

From: Hugh Dickins
Date: Mon Mar 04 2013 - 18:06:50 EST


On Mon, 4 Mar 2013, Geert Uytterhoeven wrote:
> On one of my m68k configs, v3.9-rc1 gives me:
>
> mm/ksm.c: In function âget_kpfn_nidâ:
> mm/ksm.c:492: error: implicit declaration of function âpfn_to_nidâ
>
> It turns out <linux/mmzone.h> lacks a definition for pfn_to_nid() if
> CONFIG_DISCONTIGMEM=y.

Thanks for reporting, sorry about that. Patch below should fix it.

I think it's quite likely that m68k will hit this again in future, from
some other new usage of pfn_to_nid() in generic code: so you might want
also to put a DISCONTIGMEM pfn_to_nid() in arch/m68k/include/asm/mmzone.h.
I'd say "instead" rather than "also" if I were sure that m68k is the only
architecture needing it, but I'm not at all sure of that.


[PATCH] ksm: fix m68k build: only NUMA needs pfn_to_nid

A CONFIG_DISCONTIGMEM=y m68k config gave

mm/ksm.c: In function âget_kpfn_nid':
mm/ksm.c:492: error: implicit declaration of function `pfn_to_nid'

linux/mmzone.h declares it for CONFIG_SPARSEMEM and CONFIG_FLATMEM, but
expects the arch's asm/mmzone.h to declare it for CONFIG_DISCONTIGMEM
(see arch/mips/include/asm/mmzone.h for example).

Or perhaps it is only expected when CONFIG_NUMA=y: too much of a maze,
and m68k got away without it so far, so fix the build in mm/ksm.c.

Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx>
---

mm/ksm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- 3.9-rc1/mm/ksm.c 2013-03-03 19:35:40.120006587 -0800
+++ linux/mm/ksm.c 2013-03-04 14:20:12.464047569 -0800
@@ -489,7 +489,7 @@ out: page = NULL;
*/
static inline int get_kpfn_nid(unsigned long kpfn)
{
- return ksm_merge_across_nodes ? 0 : pfn_to_nid(kpfn);
+ return ksm_merge_across_nodes ? 0 : NUMA(pfn_to_nid(kpfn));
}

static void remove_node_from_stable_tree(struct stable_node *stable_node)