mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 10:39:23 +07:00
f86dbacb30
The trouble with having a plain nesting flag for locks which do not
naturally nest (unlike block devices and their partitions, which is
the original motivation for nesting levels) is that lockdep will
never spot a true deadlock if you screw up.
This patch is an attempt at trying better, by highlighting a bit more
of the actual nature of the nesting that's going on. Essentially we
have two kinds of objects:
- objects without pages allocated, which cannot be on any lru and are
hence inaccessible to the shrinker.
- objects which have pages allocated, which are on an lru, and which
the shrinker can decide to throw out.
For the former type of object, memory allocations while holding
obj->mm.lock are permissible. For the latter they are not. And
get/put_pages transitions between the two types of objects.
This is still not entirely fool-proof since the rules might change.
But as long as we run such a code ever at runtime lockdep should be
able to observe the inconsistency and complain (like with any other
lockdep class that we've split up in multiple classes). But there are
a few clear benefits:
- We can drop the nesting flag parameter from
__i915_gem_object_put_pages, because that function by definition is
never going allocate memory, and calling it on an object which
doesn't have its pages allocated would be a bug.
- We strictly catch more bugs, since there's not only one place in the
entire tree which is annotated with the special class. All the
other places that had explicit lockdep nesting annotations we're now
going to leave up to lockdep again.
- Specifically this catches stuff like calling get_pages from
put_pages (which isn't really a good idea, if we can call get_pages
so could the shrinker). I've seen patches do exactly that.
Of course I fully expect CI will show me for the fool I am with this
one here :-)
v2: There can only be one (lockdep only has a cache for the first
subclass, not for deeper ones, and we don't want to make these locks
even slower). Still separate enums for better documentation.
Real fix: don't forget about phys objs and pin_map(), and fix the
shrinker to have the right annotations ... silly me.
v3: Forgot usertptr too ...
v4: Improve comment for pages_pin_count, drop the IMPORTANT comment
and instead prime lockdep (Chris).
v5: Appease checkpatch, no double empty lines (Chris)
v6: More rebasing over selftest changes. Also somehow I forgot to
push this patch :-/
Also format comments consistently while at it.
v7: Fix typo in commit message (Joonas)
Also drop the priming, with the lmem merge we now have allocations
while holding the lmem lock, which wreaks the generic priming I've
done in earlier patches. Should probably be resurrected when lmem is
fixed. See
commit
|
||
---|---|---|
.. | ||
i915_active.c | ||
i915_buddy.c | ||
i915_gem_evict.c | ||
i915_gem_gtt.c | ||
i915_gem.c | ||
i915_live_selftests.h | ||
i915_mock_selftests.h | ||
i915_perf.c | ||
i915_random.c | ||
i915_random.h | ||
i915_request.c | ||
i915_selftest.c | ||
i915_sw_fence.c | ||
i915_syncmap.c | ||
i915_vma.c | ||
igt_atomic.h | ||
igt_flush_test.c | ||
igt_flush_test.h | ||
igt_live_test.c | ||
igt_live_test.h | ||
igt_reset.c | ||
igt_reset.h | ||
igt_spinner.c | ||
igt_spinner.h | ||
intel_memory_region.c | ||
intel_uncore.c | ||
lib_sw_fence.c | ||
lib_sw_fence.h | ||
mock_drm.c | ||
mock_drm.h | ||
mock_gem_device.c | ||
mock_gem_device.h | ||
mock_gtt.c | ||
mock_gtt.h | ||
mock_region.c | ||
mock_region.h | ||
mock_request.c | ||
mock_request.h | ||
mock_uncore.c | ||
mock_uncore.h | ||
scatterlist.c |