Skip to content

Commit dfcd666

Browse files
Jérôme Glissetorvalds
authored andcommitted
mm/mmu_notifier: convert user range->blockable to helper function
Use the mmu_notifier_range_blockable() helper function instead of directly dereferencing the range->blockable field. This is done to make it easier to change the mmu_notifier range field. This patch is the outcome of the following coccinelle patch: %<------------------------------------------------------------------- @@ identifier I1, FN; @@ FN(..., struct mmu_notifier_range *I1, ...) { <... -I1->blockable +mmu_notifier_range_blockable(I1) ...> } ------------------------------------------------------------------->% spatch --in-place --sp-file blockable.spatch --dir . Link: http://lkml.kernel.org/r/20190326164747.24405-3-jglisse@redhat.com Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Reviewed-by: Ralph Campbell <rcampbell@nvidia.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Cc: Christian König <christian.koenig@amd.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Felix Kuehling <Felix.Kuehling@amd.com> Cc: Jason Gunthorpe <jgg@mellanox.com> Cc: Ross Zwisler <zwisler@kernel.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krcmar <rkrcmar@redhat.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Christian Koenig <christian.koenig@amd.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4a83bfe commit dfcd666

8 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ static int amdgpu_mn_invalidate_range_start_gfx(struct mmu_notifier *mn,
256256
/* TODO we should be able to split locking for interval tree and
257257
* amdgpu_mn_invalidate_node
258258
*/
259-
if (amdgpu_mn_read_lock(amn, range->blockable))
259+
if (amdgpu_mn_read_lock(amn, mmu_notifier_range_blockable(range)))
260260
return -EAGAIN;
261261

262262
it = interval_tree_iter_first(&amn->objects, range->start, end);
263263
while (it) {
264264
struct amdgpu_mn_node *node;
265265

266-
if (!range->blockable) {
266+
if (!mmu_notifier_range_blockable(range)) {
267267
amdgpu_mn_read_unlock(amn);
268268
return -EAGAIN;
269269
}
@@ -299,15 +299,15 @@ static int amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn,
299299
/* notification is exclusive, but interval is inclusive */
300300
end = range->end - 1;
301301

302-
if (amdgpu_mn_read_lock(amn, range->blockable))
302+
if (amdgpu_mn_read_lock(amn, mmu_notifier_range_blockable(range)))
303303
return -EAGAIN;
304304

305305
it = interval_tree_iter_first(&amn->objects, range->start, end);
306306
while (it) {
307307
struct amdgpu_mn_node *node;
308308
struct amdgpu_bo *bo;
309309

310-
if (!range->blockable) {
310+
if (!mmu_notifier_range_blockable(range)) {
311311
amdgpu_mn_read_unlock(amn);
312312
return -EAGAIN;
313313
}

‎drivers/gpu/drm/i915/i915_gem_userptr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
122122
while (it) {
123123
struct drm_i915_gem_object *obj;
124124

125-
if (!range->blockable) {
125+
if (!mmu_notifier_range_blockable(range)) {
126126
ret = -EAGAIN;
127127
break;
128128
}

‎drivers/gpu/drm/radeon/radeon_mn.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
133133
/* TODO we should be able to split locking for interval tree and
134134
* the tear down.
135135
*/
136-
if (range->blockable)
136+
if (mmu_notifier_range_blockable(range))
137137
mutex_lock(&rmn->lock);
138138
else if (!mutex_trylock(&rmn->lock))
139139
return -EAGAIN;
@@ -144,7 +144,7 @@ static int radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
144144
struct radeon_bo *bo;
145145
long r;
146146

147-
if (!range->blockable) {
147+
if (!mmu_notifier_range_blockable(range)) {
148148
ret = -EAGAIN;
149149
goto out_unlock;
150150
}

‎drivers/infiniband/core/umem_odp.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
152152
struct ib_ucontext_per_mm *per_mm =
153153
container_of(mn, struct ib_ucontext_per_mm, mn);
154154

155-
if (range->blockable)
155+
if (mmu_notifier_range_blockable(range))
156156
down_read(&per_mm->umem_rwsem);
157157
else if (!down_read_trylock(&per_mm->umem_rwsem))
158158
return -EAGAIN;
@@ -170,7 +170,8 @@ static int ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
170170
return rbt_ib_umem_for_each_in_range(&per_mm->umem_tree, range->start,
171171
range->end,
172172
invalidate_range_start_trampoline,
173-
range->blockable, NULL);
173+
mmu_notifier_range_blockable(range),
174+
NULL);
174175
}
175176

176177
static int invalidate_range_end_trampoline(struct ib_umem_odp *item, u64 start,

‎drivers/xen/gntdev.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,20 @@ static int mn_invl_range_start(struct mmu_notifier *mn,
526526
struct gntdev_grant_map *map;
527527
int ret = 0;
528528

529-
if (range->blockable)
529+
if (mmu_notifier_range_blockable(range))
530530
mutex_lock(&priv->lock);
531531
else if (!mutex_trylock(&priv->lock))
532532
return -EAGAIN;
533533

534534
list_for_each_entry(map, &priv->maps, next) {
535535
ret = unmap_if_in_range(map, range->start, range->end,
536-
range->blockable);
536+
mmu_notifier_range_blockable(range));
537537
if (ret)
538538
goto out_unlock;
539539
}
540540
list_for_each_entry(map, &priv->freeable_maps, next) {
541541
ret = unmap_if_in_range(map, range->start, range->end,
542-
range->blockable);
542+
mmu_notifier_range_blockable(range));
543543
if (ret)
544544
goto out_unlock;
545545
}

‎mm/hmm.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ static int hmm_invalidate_range_start(struct mmu_notifier *mn,
205205
update.start = nrange->start;
206206
update.end = nrange->end;
207207
update.event = HMM_UPDATE_INVALIDATE;
208-
update.blockable = nrange->blockable;
208+
update.blockable = mmu_notifier_range_blockable(nrange);
209209

210-
if (nrange->blockable)
210+
if (mmu_notifier_range_blockable(nrange))
211211
mutex_lock(&hmm->lock);
212212
else if (!mutex_trylock(&hmm->lock)) {
213213
ret = -EAGAIN;
@@ -222,7 +222,7 @@ static int hmm_invalidate_range_start(struct mmu_notifier *mn,
222222
}
223223
mutex_unlock(&hmm->lock);
224224

225-
if (nrange->blockable)
225+
if (mmu_notifier_range_blockable(nrange))
226226
down_read(&hmm->mirrors_sem);
227227
else if (!down_read_trylock(&hmm->mirrors_sem)) {
228228
ret = -EAGAIN;

‎mm/mmu_notifier.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
180180
if (_ret) {
181181
pr_info("%pS callback failed with %d in %sblockable context.\n",
182182
mn->ops->invalidate_range_start, _ret,
183-
!range->blockable ? "non-" : "");
183+
!mmu_notifier_range_blockable(range) ? "non-" : "");
184184
ret = _ret;
185185
}
186186
}

‎virt/kvm/kvm_main.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
391391
spin_unlock(&kvm->mmu_lock);
392392

393393
ret = kvm_arch_mmu_notifier_invalidate_range(kvm, range->start,
394-
range->end, range->blockable);
394+
range->end,
395+
mmu_notifier_range_blockable(range));
395396

396397
srcu_read_unlock(&kvm->srcu, idx);
397398

0 commit comments

Comments
 (0)