On Mon, May 06, 2019 at 04:29:38PM -0700, rcampb...@nvidia.com wrote:
> From: Ralph Campbell <rcampb...@nvidia.com>
> 
> Update the HMM documentation to reflect the latest API and make a few minor
> wording changes.
> 
> Signed-off-by: Ralph Campbell <rcampb...@nvidia.com>
> Reviewed-by: Jérôme Glisse <jgli...@redhat.com>
> Cc: John Hubbard <jhubb...@nvidia.com>
> Cc: Ira Weiny <ira.we...@intel.com>
> Cc: Dan Williams <dan.j.willi...@intel.com>
> Cc: Arnd Bergmann <a...@arndb.de>
> Cc: Balbir Singh <bsinghar...@gmail.com>
> Cc: Dan Carpenter <dan.carpen...@oracle.com>
> Cc: Matthew Wilcox <wi...@infradead.org>
> Cc: Souptick Joarder <jrdr.li...@gmail.com>
> Cc: Andrew Morton <a...@linux-foundation.org>
>  Documentation/vm/hmm.rst | 139 ++++++++++++++++++++-------------------
>  1 file changed, 73 insertions(+), 66 deletions(-)

Okay, lets start picking up hmm patches in to the new shared hmm.git,
as promised I will take responsibility to send these to Linus. The
tree is here:

https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/log/?h=hmm

This looks fine to me with one minor comment:

> diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst
> index ec1efa32af3c..7c1e929931a0 100644
> +++ b/Documentation/vm/hmm.rst
>  
> @@ -151,21 +151,27 @@ registration of an hmm_mirror struct::
>  
>   int hmm_mirror_register(struct hmm_mirror *mirror,
>                           struct mm_struct *mm);
> - int hmm_mirror_register_locked(struct hmm_mirror *mirror,
> -                                struct mm_struct *mm);
>  
> -
> -The locked variant is to be used when the driver is already holding mmap_sem
> -of the mm in write mode. The mirror struct has a set of callbacks that are 
> used
> +The mirror struct has a set of callbacks that are used
>  to propagate CPU page tables::
>  
>   struct hmm_mirror_ops {
> +     /* release() - release hmm_mirror
> +      *
> +      * @mirror: pointer to struct hmm_mirror
> +      *
> +      * This is called when the mm_struct is being released.
> +      * The callback should make sure no references to the mirror occur
> +      * after the callback returns.
> +      */

This is not quite accurate (at least, as the other series I sent
intends), the struct hmm_mirror is valid up until
hmm_mirror_unregister() is called - specifically it remains valid
after the release() callback.

I will revise it (and the hmm.h comment it came from) to read the
below. Please let me know if you'd like something else:

        /* release() - release hmm_mirror
         *
         * @mirror: pointer to struct hmm_mirror
         *
         * This is called when the mm_struct is being released.  The callback
         * must ensure that all access to any pages obtained from this mirror
         * is halted before the callback returns. All future access should
         * fault.
         */

The key task for release is to fence off all device access to any
related pages as the mm is about to recycle them and the device must
not cause a use-after-free.

I applied it to hmm.git

Thanks,
Jason

Reply via email to