[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20180326213009.2460-3-jglisse@redhat.com>
Date: Mon, 26 Mar 2018 17:30:09 -0400
From: jglisse@...hat.com
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Ralph Campbell <rcampbell@...dia.com>,
Jérôme Glisse <jglisse@...hat.com>,
Evgeny Baskakov <ebaskakov@...dia.com>,
Mark Hairgrove <mhairgrove@...dia.com>,
John Hubbard <jhubbard@...dia.com>
Subject: [PATCH 2/2] mm/hmm: clarify fault logic for device private memory
From: Ralph Campbell <rcampbell@...dia.com>
For device private memory caller of hmm_vma_fault() want to be able to
carefully control fault behavior. Update logic to only fault on device
private entry if explicitly requested.
Before this patch a read only device private CPU page table entry would
fault if caller requested write permission without the device private
flag set (in caller's flag fault request). After this patch it will only
fault if the device private flag is also set.
Signed-off-by: Ralph Campbell <rcampbell@...dia.com>
Signed-off-by: Jérôme Glisse <jglisse@...hat.com>
Cc: Evgeny Baskakov <ebaskakov@...dia.com>
Cc: Mark Hairgrove <mhairgrove@...dia.com>
Cc: John Hubbard <jhubbard@...dia.com>
---
mm/hmm.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/mm/hmm.c b/mm/hmm.c
index ba912da1c1a1..398d0214be66 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -390,18 +390,22 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
/* We aren't ask to do anything ... */
if (!(pfns & range->flags[HMM_PFN_VALID]))
return;
+ /* If this is device memory than only fault if explicitly requested */
+ if ((cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
+ /* Do we fault on device memory ? */
+ if (pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) {
+ *write_fault = pfns & range->flags[HMM_PFN_WRITE];
+ *fault = true;
+ }
+ return;
+ }
+
/* If CPU page table is not valid then we need to fault */
- *fault = cpu_flags & range->flags[HMM_PFN_VALID];
+ *fault = !(cpu_flags & range->flags[HMM_PFN_VALID]);
/* Need to write fault ? */
if ((pfns & range->flags[HMM_PFN_WRITE]) &&
!(cpu_flags & range->flags[HMM_PFN_WRITE])) {
- *fault = *write_fault = false;
- return;
- }
- /* Do we fault on device memory ? */
- if ((pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) &&
- (cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
- *write_fault = pfns & range->flags[HMM_PFN_WRITE];
+ *write_fault = true;
*fault = true;
}
}
--
2.14.3
Powered by blists - more mailing lists