Q:

Given a page pointer in a linux kernel module, how to get the NUMA node id on which it is assigned?

I am working on a checkpoint/Restart Linux kernel module. 
Wherein, a process sends a request to this module to checkpoint itself. In this process information about the process is stored in a file, which is used later on to restart the process.
Now when this module is storing the information related to pages (of the process) in a file, we also want to know on which NUMA node this page was assigned
Can you suggest what will be the best way to get this data (page to NUMA node mapping). As I am in the kernel space, I would like to use the linux kernel functions itself to get this information.
I tried using page_to_nid(page), but I am not really sure it gives me correct value.
(Like, I am working on linux 2.6.32, 64 bit machine with 16 cores and there are 4 NUMA nodes (4 cores on each) on it, but this function returns 32 when called)
Thanks,
Ajay

A:

You can read "Understanding the Linux Virtual Memory Manager", it states that:

node id: This is the Node ID (NID) of the node ...

So I'm pretty sure that page_to_nid should be the right function.

