@@ -183,16 +183,20 @@ EXPORT_SYMBOL_GPL(contpte_ptep_get);
183
183
pte_t contpte_ptep_get_lockless (pte_t * orig_ptep )
184
184
{
185
185
/*
186
- * Gather access/dirty bits, which may be populated in any of the ptes
187
- * of the contig range. We may not be holding the PTL, so any contiguous
188
- * range may be unfolded/modified/refolded under our feet. Therefore we
189
- * ensure we read a _consistent_ contpte range by checking that all ptes
190
- * in the range are valid and have CONT_PTE set, that all pfns are
191
- * contiguous and that all pgprots are the same (ignoring access/dirty).
192
- * If we find a pte that is not consistent, then we must be racing with
193
- * an update so start again. If the target pte does not have CONT_PTE
194
- * set then that is considered consistent on its own because it is not
195
- * part of a contpte range.
186
+ * The ptep_get_lockless() API requires us to read and return *orig_ptep
187
+ * so that it is self-consistent, without the PTL held, so we may be
188
+ * racing with other threads modifying the pte. Usually a READ_ONCE()
189
+ * would suffice, but for the contpte case, we also need to gather the
190
+ * access and dirty bits from across all ptes in the contiguous block,
191
+ * and we can't read all of those neighbouring ptes atomically, so any
192
+ * contiguous range may be unfolded/modified/refolded under our feet.
193
+ * Therefore we ensure we read a _consistent_ contpte range by checking
194
+ * that all ptes in the range are valid and have CONT_PTE set, that all
195
+ * pfns are contiguous and that all pgprots are the same (ignoring
196
+ * access/dirty). If we find a pte that is not consistent, then we must
197
+ * be racing with an update so start again. If the target pte does not
198
+ * have CONT_PTE set then that is considered consistent on its own
199
+ * because it is not part of a contpte range.
196
200
*/
197
201
198
202
pgprot_t orig_prot ;
0 commit comments