Re: [PATCH] mm/device-public-memory: Enable move_pages() to stat device memory

From: Jerome Glisse
Date: Tue Sep 26 2017 - 12:20:03 EST


On Tue, Sep 26, 2017 at 09:47:10AM -0500, Reza Arbab wrote:
> On Tue, Sep 26, 2017 at 01:37:07PM +0000, Michal Hocko wrote:
> > On Fri 22-09-17 15:13:56, Reza Arbab wrote:
> > > The move_pages() syscall can be used to find the numa node where a page
> > > currently resides. This is not working for device public memory pages,
> > > which erroneously report -EFAULT (unmapped or zero page).
> > >
> > > Enable by adding a FOLL_DEVICE flag for follow_page(), which
> > > move_pages() will use. This could be done unconditionally, but adding a
> > > flag seems like a safer change.
> >
> > I do not understand purpose of this patch. What is the numa node of a
> > device memory?
>
> Well, using hmm_devmem_pages_create() it is added to this node:
>
> nid = dev_to_node(device);
> if (nid < 0)
> nid = numa_mem_id();
>
> I understand it's minimally useful information to userspace, but the memory
> does have a nid and move_pages() is supposed to be able to return what that
> is. I ran into this using a testcase which tries to verify that user
> addresses were correctly migrated to coherent device memory.
>
> That said, I'm okay with dropping this if you don't think it's worthwhile.

Just to add a data point, PCIE devices are tie to one CPU (architecturaly PCIE
lane are connected to CPU at least on x86/ppc AFAIK) and thus to one numa node.


Right now i am traveling but i want to check that this patch does not allow
user to inadvertaly pin device memory page. I will look into it once i am
back.

Cheers,
Jérôme