linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralph Campbell <rcampbell@nvidia.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Ira Weiny" <ira.weiny@intel.com>,
	"Dan Williams" <dan.j.williams@intel.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Balbir Singh" <bsingharora@gmail.com>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Souptick Joarder" <jrdr.linux@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Jérôme Glisse" <jglisse@redhat.com>
Subject: Re: [PATCH 1/5] mm/hmm: Update HMM documentation
Date: Thu, 6 Jun 2019 11:50:15 -0700	[thread overview]
Message-ID: <e1fad454-ac9b-4069-1bc8-8149c72655ca@nvidia.com> (raw)
In-Reply-To: <20190606140239.GA21778@ziepe.ca>


On 6/6/19 7:02 AM, Jason Gunthorpe wrote:
> On Mon, May 06, 2019 at 04:29:38PM -0700, rcampbell@nvidia.com wrote:
>> From: Ralph Campbell <rcampbell@nvidia.com>
>>
>> Update the HMM documentation to reflect the latest API and make a few minor
>> wording changes.
>>
>> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
>> Reviewed-by: Jérôme Glisse <jglisse@redhat.com>
>> Cc: John Hubbard <jhubbard@nvidia.com>
>> Cc: Ira Weiny <ira.weiny@intel.com>
>> Cc: Dan Williams <dan.j.williams@intel.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Balbir Singh <bsingharora@gmail.com>
>> Cc: Dan Carpenter <dan.carpenter@oracle.com>
>> Cc: Matthew Wilcox <willy@infradead.org>
>> Cc: Souptick Joarder <jrdr.linux@gmail.com>
>> Cc: Andrew Morton <akpm@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
> 

Yes, I agree this is better.

Also, I noticed the sample code for hmm_range_register() is wrong.
If you could merge this minor change into this patch, that
would be appreciated.

diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst
index dc8fe4241a18..b5fb9bc02aa2 100644
--- a/Documentation/vm/hmm.rst
+++ b/Documentation/vm/hmm.rst
@@ -245,7 +245,7 @@ The usage pattern is::
              hmm_range_wait_until_valid(&range, TIMEOUT_IN_MSEC);
              goto again;
            }
-          hmm_mirror_unregister(&range);
+          hmm_range_unregister(&range);
            return ret;
        }
        take_lock(driver->update);
@@ -257,7 +257,7 @@ The usage pattern is::

        // Use pfns array content to update device page table

-      hmm_mirror_unregister(&range);
+      hmm_range_unregister(&range);
        release_lock(driver->update);
        up_read(&mm->mmap_sem);
        return 0;

  reply	other threads:[~2019-06-06 18:50 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 23:29 [PATCH 0/5] mm/hmm: HMM documentation updates and code fixes rcampbell
2019-05-06 23:29 ` [PATCH 1/5] mm/hmm: Update HMM documentation rcampbell
2019-06-06 14:02   ` Jason Gunthorpe
2019-06-06 18:50     ` Ralph Campbell [this message]
2019-06-06 19:32       ` Jason Gunthorpe
2019-05-06 23:29 ` [PATCH 2/5] mm/hmm: Clean up some coding style and comments rcampbell
2019-06-06 14:16   ` Jason Gunthorpe
2019-06-06 14:27     ` Jerome Glisse
2019-06-06 15:41       ` Jason Gunthorpe
2019-06-06 15:52         ` Jerome Glisse
2019-06-06 16:55           ` Joe Perches
2019-06-06 18:54           ` Jason Gunthorpe
2019-06-06 15:57   ` Jason Gunthorpe
2019-06-07  0:44     ` Ralph Campbell
2019-05-06 23:29 ` [PATCH 3/5] mm/hmm: Use mm_get_hmm() in hmm_range_register() rcampbell
2019-05-23 12:51   ` Jason Gunthorpe
2019-05-23 18:19     ` Ralph Campbell
2019-05-23 18:46     ` John Hubbard
2019-05-06 23:29 ` [PATCH 4/5] mm/hmm: hmm_vma_fault() doesn't always call hmm_range_unregister() rcampbell
2019-05-07 13:15   ` Souptick Joarder
2019-05-07 18:12     ` Ralph Campbell
2019-05-09  4:42       ` Souptick Joarder
2019-05-12 15:07       ` Jerome Glisse
2019-05-12 15:28         ` Jerome Glisse
2019-05-13 17:23         ` Ralph Campbell
2019-06-06 14:50   ` Jason Gunthorpe
2019-06-06 19:44     ` Ralph Campbell
2019-06-06 19:54       ` Jason Gunthorpe
2019-06-06 21:08         ` Ralph Campbell
2019-05-12 15:08 ` [PATCH 0/5] mm/hmm: HMM documentation updates and code fixes Jerome Glisse
2019-05-13 17:26   ` Ralph Campbell
2019-05-13 18:10     ` Jerome Glisse
2019-06-06 14:53 ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1fad454-ac9b-4069-1bc8-8149c72655ca@nvidia.com \
    --to=rcampbell@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bsingharora@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=jrdr.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).