Skip to content

Commit 5292e24

Browse files
committed
mm/mmu_notifiers: Use 'interval_sub' as the variable for mmu_interval_notifier
The 'interval_sub' is placed on the 'notifier_subscriptions' interval tree. This eliminates the poor name 'mni' for this variable. Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 1991722 commit 5292e24

File tree

3 files changed

+104
-90
lines changed

3 files changed

+104
-90
lines changed

Documentation/vm/hmm.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ CPU page table into a device page table; HMM helps keep both synchronized. A
149149
device driver that wants to mirror a process address space must start with the
150150
registration of a mmu_interval_notifier::
151151

152-
mni->ops = &driver_ops;
153-
int mmu_interval_notifier_insert(struct mmu_interval_notifier *mni,
154-
unsigned long start, unsigned long length,
155-
struct mm_struct *mm);
152+
int mmu_interval_notifier_insert(struct mmu_interval_notifier *interval_sub,
153+
struct mm_struct *mm, unsigned long start,
154+
unsigned long length,
155+
const struct mmu_interval_notifier_ops *ops);
156156

157-
During the driver_ops->invalidate() callback the device driver must perform
158-
the update action to the range (mark range read only, or fully unmap,
159-
etc.). The device must complete the update before the driver callback returns.
157+
During the ops->invalidate() callback the device driver must perform the
158+
update action to the range (mark range read only, or fully unmap, etc.). The
159+
device must complete the update before the driver callback returns.
160160

161161
When the device driver wants to populate a range of virtual addresses, it can
162162
use::
@@ -183,19 +183,19 @@ The usage pattern is::
183183
struct hmm_range range;
184184
...
185185

186-
range.notifier = &mni;
186+
range.notifier = &interval_sub;
187187
range.start = ...;
188188
range.end = ...;
189189
range.pfns = ...;
190190
range.flags = ...;
191191
range.values = ...;
192192
range.pfn_shift = ...;
193193

194-
if (!mmget_not_zero(mni->notifier.mm))
194+
if (!mmget_not_zero(interval_sub->notifier.mm))
195195
return -EFAULT;
196196

197197
again:
198-
range.notifier_seq = mmu_interval_read_begin(&mni);
198+
range.notifier_seq = mmu_interval_read_begin(&interval_sub);
199199
down_read(&mm->mmap_sem);
200200
ret = hmm_range_fault(&range, HMM_RANGE_SNAPSHOT);
201201
if (ret) {

include/linux/mmu_notifier.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ struct mmu_notifier {
237237
* was required but mmu_notifier_range_blockable(range) is false.
238238
*/
239239
struct mmu_interval_notifier_ops {
240-
bool (*invalidate)(struct mmu_interval_notifier *mni,
240+
bool (*invalidate)(struct mmu_interval_notifier *interval_sub,
241241
const struct mmu_notifier_range *range,
242242
unsigned long cur_seq);
243243
};
@@ -292,20 +292,21 @@ extern int __mmu_notifier_register(struct mmu_notifier *subscription,
292292
extern void mmu_notifier_unregister(struct mmu_notifier *subscription,
293293
struct mm_struct *mm);
294294

295-
unsigned long mmu_interval_read_begin(struct mmu_interval_notifier *mni);
296-
int mmu_interval_notifier_insert(struct mmu_interval_notifier *mni,
295+
unsigned long
296+
mmu_interval_read_begin(struct mmu_interval_notifier *interval_sub);
297+
int mmu_interval_notifier_insert(struct mmu_interval_notifier *interval_sub,
297298
struct mm_struct *mm, unsigned long start,
298299
unsigned long length,
299300
const struct mmu_interval_notifier_ops *ops);
300301
int mmu_interval_notifier_insert_locked(
301-
struct mmu_interval_notifier *mni, struct mm_struct *mm,
302+
struct mmu_interval_notifier *interval_sub, struct mm_struct *mm,
302303
unsigned long start, unsigned long length,
303304
const struct mmu_interval_notifier_ops *ops);
304-
void mmu_interval_notifier_remove(struct mmu_interval_notifier *mni);
305+
void mmu_interval_notifier_remove(struct mmu_interval_notifier *interval_sub);
305306

306307
/**
307308
* mmu_interval_set_seq - Save the invalidation sequence
308-
* @mni - The mni passed to invalidate
309+
* @interval_sub - The subscription passed to invalidate
309310
* @cur_seq - The cur_seq passed to the invalidate() callback
310311
*
311312
* This must be called unconditionally from the invalidate callback of a
@@ -316,15 +317,16 @@ void mmu_interval_notifier_remove(struct mmu_interval_notifier *mni);
316317
* If the caller does not call mmu_interval_read_begin() or
317318
* mmu_interval_read_retry() then this call is not required.
318319
*/
319-
static inline void mmu_interval_set_seq(struct mmu_interval_notifier *mni,
320-
unsigned long cur_seq)
320+
static inline void
321+
mmu_interval_set_seq(struct mmu_interval_notifier *interval_sub,
322+
unsigned long cur_seq)
321323
{
322-
WRITE_ONCE(mni->invalidate_seq, cur_seq);
324+
WRITE_ONCE(interval_sub->invalidate_seq, cur_seq);
323325
}
324326

325327
/**
326328
* mmu_interval_read_retry - End a read side critical section against a VA range
327-
* mni: The range
329+
* interval_sub: The subscription
328330
* seq: The return of the paired mmu_interval_read_begin()
329331
*
330332
* This MUST be called under a user provided lock that is also held
@@ -336,15 +338,16 @@ static inline void mmu_interval_set_seq(struct mmu_interval_notifier *mni,
336338
* Returns true if an invalidation collided with this critical section, and
337339
* the caller should retry.
338340
*/
339-
static inline bool mmu_interval_read_retry(struct mmu_interval_notifier *mni,
340-
unsigned long seq)
341+
static inline bool
342+
mmu_interval_read_retry(struct mmu_interval_notifier *interval_sub,
343+
unsigned long seq)
341344
{
342-
return mni->invalidate_seq != seq;
345+
return interval_sub->invalidate_seq != seq;
343346
}
344347

345348
/**
346349
* mmu_interval_check_retry - Test if a collision has occurred
347-
* mni: The range
350+
* interval_sub: The subscription
348351
* seq: The return of the matching mmu_interval_read_begin()
349352
*
350353
* This can be used in the critical section between mmu_interval_read_begin()
@@ -359,11 +362,12 @@ static inline bool mmu_interval_read_retry(struct mmu_interval_notifier *mni,
359362
* This call can be used as part of loops and other expensive operations to
360363
* expedite a retry.
361364
*/
362-
static inline bool mmu_interval_check_retry(struct mmu_interval_notifier *mni,
363-
unsigned long seq)
365+
static inline bool
366+
mmu_interval_check_retry(struct mmu_interval_notifier *interval_sub,
367+
unsigned long seq)
364368
{
365369
/* Pairs with the WRITE_ONCE in mmu_interval_set_seq() */
366-
return READ_ONCE(mni->invalidate_seq) != seq;
370+
return READ_ONCE(interval_sub->invalidate_seq) != seq;
367371
}
368372

369373
extern void __mmu_notifier_subscriptions_destroy(struct mm_struct *mm);

0 commit comments

Comments
 (0)