linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: "Kai Mäkisara (Kolumbus)" <kai.makisara@kolumbus.fi>,
	"Bart Van Assche" <bvanassche@acm.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	<linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] scsi: st: convert convert get_user_pages() --> pin_user_pages()
Date: Tue, 26 May 2020 11:15:30 -0700	[thread overview]
Message-ID: <53ba75b6-4be5-c7be-20dd-808bee4e2edc@nvidia.com> (raw)
In-Reply-To: <C1CFE522-CEA6-4130-9433-73243BC00782@kolumbus.fi>

On 2020-05-22 01:32, "Kai Mäkisara (Kolumbus)" wrote:
>> On 21. May 2020, at 22.47, Bart Van Assche <bvanassche@acm.org> wrote:
>>
>> On 2020-05-18 21:55, John Hubbard wrote:
>>> This code was using get_user_pages*(), in a "Case 2" scenario
>>> (DMA/RDMA), using the categorization from [1]. That means that it's
>>> time to convert the get_user_pages*() + put_page() calls to
>>> pin_user_pages*() + unpin_user_pages() calls.
>>>
>>> There is some helpful background in [2]: basically, this is a small
>>> part of fixing a long-standing disconnect between pinning pages, and
>>> file systems' use of those pages.
>>>
>>> Note that this effectively changes the code's behavior as well: it now
>>> ultimately calls set_page_dirty_lock(), instead of SetPageDirty().This
>>> is probably more accurate.
>>>
>>> As Christoph Hellwig put it, "set_page_dirty() is only safe if we are
>>> dealing with a file backed page where we have reference on the inode it
>>> hangs off." [3]
>>>
>>> Also, this deletes one of the two FIXME comments (about refcounting),
>>> because there is nothing wrong with the refcounting at this point.
>>>
>>> [1] Documentation/core-api/pin_user_pages.rst
>>>
>>> [2] "Explicit pinning of user-space pages":
>>>     https://lwn.net/Articles/807108/
>>>
>>> [3] https://lore.kernel.org/r/20190723153640.GB720@lst.de
>>
>> Kai, why is the st driver calling get_user_pages_fast() directly instead
>> of calling blk_rq_map_user()? blk_rq_map_user() is already used in
>> st_scsi_execute(). I think that the blk_rq_map_user() implementation is
>> also based on get_user_pages_fast(). See also iov_iter_get_pages_alloc()
>> in lib/iov_iter.c.
>>
> The reason is that the blk_ functions were not available when that part
> of the code was done. Nobody has converted that to use the more
> modern functions because the old method still works.
> 


Hi Kai, Bart,

Say, thinking about this some more, it seems like: as only sgl_unmap_user_pages()
is allowed to release the pages that were pinned in sgl_map_user_pages(), then
this is a clear case of Direct IO (not DMA/RDMA, as I first thought) that needs
to be handled via pin_user_pages_fast().

I'll send a v2 with the commit log updated to refer to Direct IO, because this
does still apply, after all.

thanks,
-- 
John Hubbard
NVIDIA

      reply	other threads:[~2020-05-26 18:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  4:55 [PATCH] scsi: st: convert convert get_user_pages() --> pin_user_pages() John Hubbard
2020-05-19 20:12 ` John Hubbard
2020-05-20  1:57   ` Martin K. Petersen
2020-05-21 19:47 ` Bart Van Assche
2020-05-21 19:57   ` John Hubbard
2020-05-21 20:58     ` Bart Van Assche
2020-05-22  8:32   ` "Kai Mäkisara (Kolumbus)"
2020-05-26 18:15     ` John Hubbard [this message]

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=53ba75b6-4be5-c7be-20dd-808bee4e2edc@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=kai.makisara@kolumbus.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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).