History

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 .

Jérôme Glisse committed 7 years ago

Commit dfcd6661 parent 4a83bfe8 files · +19 −17Browse files

Unified · Split

8 files
  1. drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c +4 −4
  2. drivers/gpu/drm/i915/i915_gem_userptr.c +1 −1
  3. drivers/gpu/drm/radeon/radeon_mn.c +2 −2
  4. drivers/infiniband/core/umem_odp.c +3 −2
  5. drivers/xen/gntdev.c +3 −3
  6. mm/hmm.c +3 −3
  7. mm/mmu_notifier.c +1 −1
  8. virt/kvm/kvm_main.c +2 −1
drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c+4−4
@@ -256,14 +256,14 @@ static int amdgpu_mn_invalidate_range_start_gfx(struct mmu_notifier *mn, · 255 unmodified lines
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,7 +299,7 @@ static int amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, · 29 unmodified lines
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);
@@ -307,7 +307,7 @@ static int amdgpu_mn_invalidate_range_start_hsa(struct mmu_notifier *mn, · 1 unmodified line
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+1−1
@@ -122,7 +122,7 @@ userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, · 121 unmodified lines
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+2−2
@@ -133,7 +133,7 @@ static int radeon_mn_invalidate_range_start(struct mmu_notifier *mn, · 132 unmodified lines
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, · 4 unmodified lines
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+3−2
@@ -152,7 +152,7 @@ static int ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn, · 151 unmodified lines
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, · 11 unmodified lines
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+3−3
@@ -526,20 +526,20 @@ static int mn_invl_range_start(struct mmu_notifier *mn, · 525 unmodified lines
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+3−3
@@ -205,9 +205,9 @@ static int hmm_invalidate_range_start(struct mmu_notifier *mn, · 204 unmodified lines
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, · 8 unmodified lines
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+1−1
@@ -180,7 +180,7 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) · 179 unmodified lines
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+2−1
@@ -391,7 +391,8 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, · 390 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t