From: Fenghua Yu <fenghua.yu@intel.com>
To: Christoph Hellwig <hch@infradead.org>,
Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>, Dave Jiang <dave.jiang@intel.com>,
<dmaengine@vger.kernel.org>, Tony Zhu <tony.zhu@intel.com>,
Andrew Morton <akpm@linux-foundation.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 09/17] mm: export access_remote_vm() symbol
Date: Wed, 1 Mar 2023 15:39:50 -0800 [thread overview]
Message-ID: <f1f6e3b9-a1cb-cebe-d173-a42cec7febd1@intel.com> (raw)
In-Reply-To: <Y7r/BjWEP2q64TGy@infradead.org>
Hi, Christoph,
On 1/8/23 09:36, Christoph Hellwig wrote:
> Exporting access_remote_vm just seems like a horrible idea.
>
> If a driver needs to access a different VM from a completion path
> in some thread or workqueue (which I assume this does, if not please
> explain the use case), it should use kthread_use_mm to associate the
> mm struct and then just use all the normal uaccess helpers.
To trigger fault by IDXD device, user app frees the fault_addr pages.
After kthread_use_mm(), the IDXD driver cannot directly call
copy_to_user() to copy data to fault_addr because
the pages are freed by the app. If the IDXD driver
tries to copy to the app's fault_addr, it needs to get all the pages,
kmap, copy_to_user_page() etc, basically majority of the
__access_remote_vm() code. Without exporting access_remote_vm(),
the driver has to re-implement the function for the copy to work
in IDXD driver.
Maybe a simple exported IOMMU wrapper in iommu-sva.c can help here?
CONFIG_IOMMU_SVA is bool and needs to be set for Event Log to work.
So the wrapper is exported and can be called the IDXD driver or any
driver that is on top of IOMMU SVA.
No need to export access_remote_vm() any more.
Plus with this wrapper, no need to export iommu_sva_find()
(in an earlier patch). So the code will be more clean and concise.
Is this OK for you?
struct mm_struct
*iommu_access_remote_vm(ioasid_t pasid, unsigned long addr,
void *buf, int len, unsigned int gup_flags, int *copied)
{
struct mm_struct *mm;
mm = iommu_sva_find(pasid);
if (!IS_ERR_OR_NULL(mm)) {
/* A reference on @mm has been held. */
*copied = access_remote_vm(mm, addr, buf, len, gup_flags);
}
return mm;
}
EXPORT_SYMBOL_GPL(iommu_access_remote_vm);
Thanks.
-Fenghua
next prev parent reply other threads:[~2023-03-01 23:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230103163505.1569356-1-fenghua.yu@intel.com>
2023-01-03 16:34 ` [PATCH 09/17] mm: export access_remote_vm() symbol Fenghua Yu
2023-01-03 17:45 ` Lorenzo Stoakes
2023-01-03 17:50 ` Lorenzo Stoakes
2023-01-03 19:20 ` Yu, Fenghua
2023-01-03 20:13 ` Lorenzo Stoakes
2023-01-04 5:06 ` Yu, Fenghua
2023-01-04 6:12 ` Alistair Popple
2023-01-04 19:00 ` Yu, Fenghua
2023-01-04 20:00 ` Lorenzo Stoakes
2023-01-04 19:56 ` Lorenzo Stoakes
2023-01-04 21:05 ` Lorenzo Stoakes
2023-01-04 23:57 ` Alistair Popple
2023-01-05 3:08 ` Yu, Fenghua
2023-01-05 3:22 ` Alistair Popple
2023-01-05 20:58 ` Yu, Fenghua
2023-01-05 21:04 ` Lorenzo Stoakes
2023-01-05 7:26 ` Lorenzo Stoakes
2023-01-08 17:36 ` Christoph Hellwig
2023-03-01 23:39 ` Fenghua Yu [this message]
[not found] <20230103162920.1569002-1-fenghua.yu@intel.com>
2023-01-03 16:29 ` Fenghua Yu
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=f1f6e3b9-a1cb-cebe-d173-a42cec7febd1@intel.com \
--to=fenghua.yu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=hch@infradead.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=tony.zhu@intel.com \
--cc=vkoul@kernel.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).