Skip to content

Commit a42375a

Browse files
committed
drm/i915: Release the active tracker tree upon idling
As soon as we detect that the active tracker is idle and we prepare to call the retire callback, release the storage for our tree of per-timeline nodes. We expect these to be infrequently used and quick to allocate, so there is little benefit in keeping the tree cached and we would prefer to return the pages back to the system in a timely fashion. This also means that when we finalize the struct as a whole, we know as the activity tracker must be idle, the tree has already been released. Indeed we can reduce i915_active_fini() just to the assertions that there is nothing to do. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190205130005.2807-3-chris@chris-wilson.co.uk
1 parent 64d6c50 commit a42375a

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

drivers/gpu/drm/i915/i915_active.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,29 @@ struct active_node {
1616
u64 timeline;
1717
};
1818

19+
static void
20+
__active_park(struct i915_active *ref)
21+
{
22+
struct active_node *it, *n;
23+
24+
rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) {
25+
GEM_BUG_ON(i915_gem_active_isset(&it->base));
26+
kfree(it);
27+
}
28+
ref->tree = RB_ROOT;
29+
}
30+
1931
static void
2032
__active_retire(struct i915_active *ref)
2133
{
2234
GEM_BUG_ON(!ref->count);
23-
if (!--ref->count)
24-
ref->retire(ref);
35+
if (--ref->count)
36+
return;
37+
38+
/* return the unused nodes to our slabcache */
39+
__active_park(ref);
40+
41+
ref->retire(ref);
2542
}
2643

2744
static void
@@ -210,18 +227,14 @@ int i915_request_await_active(struct i915_request *rq, struct i915_active *ref)
210227
return 0;
211228
}
212229

230+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
213231
void i915_active_fini(struct i915_active *ref)
214232
{
215-
struct active_node *it, *n;
216-
217233
GEM_BUG_ON(i915_gem_active_isset(&ref->last));
218-
219-
rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) {
220-
GEM_BUG_ON(i915_gem_active_isset(&it->base));
221-
kfree(it);
222-
}
223-
ref->tree = RB_ROOT;
234+
GEM_BUG_ON(!RB_EMPTY_ROOT(&ref->tree));
235+
GEM_BUG_ON(ref->count);
224236
}
237+
#endif
225238

226239
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
227240
#include "selftests/i915_active.c"

drivers/gpu/drm/i915/i915_active.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ i915_active_is_idle(const struct i915_active *ref)
6464
return !ref->count;
6565
}
6666

67+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
6768
void i915_active_fini(struct i915_active *ref);
69+
#else
70+
static inline void i915_active_fini(struct i915_active *ref) { }
71+
#endif
6872

6973
#endif /* _I915_ACTIVE_H_ */

0 commit comments

Comments
 (0)