* [PATCH v2] mm/hmm/test: use xa_for_each_range instead of looping
@ 2020-05-16 1:04 Ralph Campbell
2020-05-19 19:50 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Ralph Campbell @ 2020-05-16 1:04 UTC (permalink / raw)
To: linux-rdma, linux-mm, linux-kselftest, linux-kernel
Cc: Jerome Glisse, John Hubbard, Christoph Hellwig, Jason Gunthorpe,
Andrew Morton, Shuah Khan, Ralph Campbell
The test driver uses an xa_array to store virtual to physical address
translations for a simulated hardware device. The MMU notifier
invalidation callback is used to keep the table consistent with the CPU
page table and is frequently called only for a page or two. However, if
the test process exits unexpectedly or is killed, the range can be
[0..ULONG_MAX] in which case calling xa_erase() for every possible PFN
results in CPU timeouts.
Use xa_for_each_range() to efficiently erase entries in the range.
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
---
This patch is based on Jason Gunthorpe's hmm tree and should be folded
into the ("mm/hmm/test: add selftest driver for HMM") patch once this
patch is reviewed, etc.
v1 -> v2:
Use xa_for_each_range() instead of special casing [0..ULONG_MAX].
lib/test_hmm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 8b36c26b717b..5c1858e325ba 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -196,13 +196,15 @@ static void dmirror_do_update(struct dmirror *dmirror, unsigned long start,
unsigned long end)
{
unsigned long pfn;
+ void *entry;
/*
* The XArray doesn't hold references to pages since it relies on
* the mmu notifier to clear page pointers when they become stale.
* Therefore, it is OK to just clear the entry.
*/
- for (pfn = start >> PAGE_SHIFT; pfn < (end >> PAGE_SHIFT); pfn++)
+ xa_for_each_range(&dmirror->pt, pfn, entry, start >> PAGE_SHIFT,
+ end >> PAGE_SHIFT)
xa_erase(&dmirror->pt, pfn);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mm/hmm/test: use xa_for_each_range instead of looping
2020-05-16 1:04 [PATCH v2] mm/hmm/test: use xa_for_each_range instead of looping Ralph Campbell
@ 2020-05-19 19:50 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-05-19 19:50 UTC (permalink / raw)
To: Ralph Campbell
Cc: linux-rdma, linux-mm, linux-kselftest, linux-kernel,
Jerome Glisse, John Hubbard, Christoph Hellwig, Andrew Morton,
Shuah Khan
On Fri, May 15, 2020 at 06:04:24PM -0700, Ralph Campbell wrote:
> The test driver uses an xa_array to store virtual to physical address
> translations for a simulated hardware device. The MMU notifier
> invalidation callback is used to keep the table consistent with the CPU
> page table and is frequently called only for a page or two. However, if
> the test process exits unexpectedly or is killed, the range can be
> [0..ULONG_MAX] in which case calling xa_erase() for every possible PFN
> results in CPU timeouts.
> Use xa_for_each_range() to efficiently erase entries in the range.
>
> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
> ---
>
> This patch is based on Jason Gunthorpe's hmm tree and should be folded
> into the ("mm/hmm/test: add selftest driver for HMM") patch once this
> patch is reviewed, etc.
>
> v1 -> v2:
> Use xa_for_each_range() instead of special casing [0..ULONG_MAX].
>
> lib/test_hmm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
I squashed this in
Thanks,
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-19 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 1:04 [PATCH v2] mm/hmm/test: use xa_for_each_range instead of looping Ralph Campbell
2020-05-19 19:50 ` Jason Gunthorpe
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).