Re: [PATCH v12 07/29] HMM: add per mirror page table v4.

From: John Hubbard
Date: Tue Mar 29 2016 - 18:58:36 EST


On Tue, 8 Mar 2016, JÃrÃme Glisse wrote:

> This patch add the per mirror page table. It also propagate CPU page
> table update to this per mirror page table using mmu_notifier callback.
> All update are contextualized with an HMM event structure that convey
> all information needed by device driver to take proper actions (update
> its own mmu to reflect changes and schedule proper flushing).
>
> Core HMM is responsible for updating the per mirror page table once
> the device driver is done with its update. Most importantly HMM will
> properly propagate HMM page table dirty bit to underlying page.
>
> Changed since v1:
> - Removed unused fence code to defer it to latter patches.
>
> Changed since v2:
> - Use new bit flag helper for mirror page table manipulation.
> - Differentiate fork event with HMM_FORK from other events.
>
> Changed since v3:
> - Get rid of HMM_ISDIRTY and rely on write protect instead.
> - Adapt to HMM page table changes
>
> Signed-off-by: JÃrÃme Glisse <jglisse@xxxxxxxxxx>
> Signed-off-by: Sherry Cheung <SCheung@xxxxxxxxxx>
> Signed-off-by: Subhash Gutti <sgutti@xxxxxxxxxx>
> Signed-off-by: Mark Hairgrove <mhairgrove@xxxxxxxxxx>
> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
> Signed-off-by: Jatin Kumar <jakumar@xxxxxxxxxx>
> ---
> include/linux/hmm.h | 83 ++++++++++++++++++++
> mm/hmm.c | 221 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 304 insertions(+)
>
> diff --git a/include/linux/hmm.h b/include/linux/hmm.h
> index b559c0b..5488fa9 100644
> --- a/include/linux/hmm.h
> +++ b/include/linux/hmm.h
> @@ -46,6 +46,7 @@
> #include <linux/mmu_notifier.h>
> #include <linux/workqueue.h>
> #include <linux/mman.h>
> +#include <linux/hmm_pt.h>
>
>
> struct hmm_device;
> @@ -53,6 +54,38 @@ struct hmm_mirror;
> struct hmm;
>
>
> +/*
> + * hmm_event - each event is described by a type associated with a struct.
> + */
> +enum hmm_etype {
> + HMM_NONE = 0,
> + HMM_FORK,
> + HMM_MIGRATE,
> + HMM_MUNMAP,
> + HMM_DEVICE_RFAULT,
> + HMM_DEVICE_WFAULT,

Hi Jerome,

Just a tiny thing I noticed, while connecting HMM to NVIDIA's upcoming
device driver: the last two enum items above should probably be named
like this:

HMM_DEVICE_READ_FAULT,
HMM_DEVICE_WRITE_FAULT,

instead of _WFAULT / _RFAULT. (Earlier code reviewers asked for more
clarity on these types of names.)

thanks,
John Hubbard

> + HMM_WRITE_PROTECT,
> +};
> +