Commit a30e4ec1 authored by Chris Wilson's avatar Chris Wilson Committed by Joonas Lahtinen

drm/i915/gt: Fix termination condition for freeing all buffer objects

A last minute change, that unfortunately broke CI so badly it declared
SUCCESS, was to refactor the debug free all buffer pool code to reuse
the normal worker, inverted the termination condition so that it instead
of discarding the nodes, they were all declared young enough and
eligible for reuse.

Fixes: 06b73c2d ("drm/i915/gt: Delay taking the spinlock for grabbing from the buffer pool")
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200729110756.2344-1-chris@chris-wilson.co.ukSigned-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
[Joonas: Updating Fixes: link after rebasing and reordering into drm-intel-gt-next]
Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
parent 62b1522c
...@@ -38,8 +38,7 @@ static void node_free(struct intel_gt_buffer_pool_node *node) ...@@ -38,8 +38,7 @@ static void node_free(struct intel_gt_buffer_pool_node *node)
kfree_rcu(node, rcu); kfree_rcu(node, rcu);
} }
static bool static bool pool_free_older_than(struct intel_gt_buffer_pool *pool, long keep)
pool_free_older_than(struct intel_gt_buffer_pool *pool, unsigned long old)
{ {
struct intel_gt_buffer_pool_node *node, *stale = NULL; struct intel_gt_buffer_pool_node *node, *stale = NULL;
bool active = false; bool active = false;
...@@ -57,8 +56,12 @@ pool_free_older_than(struct intel_gt_buffer_pool *pool, unsigned long old) ...@@ -57,8 +56,12 @@ pool_free_older_than(struct intel_gt_buffer_pool *pool, unsigned long old)
/* Most recent at head; oldest at tail */ /* Most recent at head; oldest at tail */
list_for_each_prev(pos, list) { list_for_each_prev(pos, list) {
unsigned long age;
node = list_entry(pos, typeof(*node), link); node = list_entry(pos, typeof(*node), link);
if (time_before(node->age, old))
age = READ_ONCE(node->age);
if (!age || jiffies - age < keep)
break; break;
/* Check we are the first to claim this node */ /* Check we are the first to claim this node */
...@@ -90,7 +93,7 @@ static void pool_free_work(struct work_struct *wrk) ...@@ -90,7 +93,7 @@ static void pool_free_work(struct work_struct *wrk)
struct intel_gt_buffer_pool *pool = struct intel_gt_buffer_pool *pool =
container_of(wrk, typeof(*pool), work.work); container_of(wrk, typeof(*pool), work.work);
if (pool_free_older_than(pool, jiffies - HZ)) if (pool_free_older_than(pool, HZ))
schedule_delayed_work(&pool->work, schedule_delayed_work(&pool->work,
round_jiffies_up_relative(HZ)); round_jiffies_up_relative(HZ));
} }
...@@ -230,7 +233,7 @@ void intel_gt_flush_buffer_pool(struct intel_gt *gt) ...@@ -230,7 +233,7 @@ void intel_gt_flush_buffer_pool(struct intel_gt *gt)
struct intel_gt_buffer_pool *pool = &gt->buffer_pool; struct intel_gt_buffer_pool *pool = &gt->buffer_pool;
do { do {
while (pool_free_older_than(pool, jiffies + 1)) while (pool_free_older_than(pool, 0))
; ;
} while (cancel_delayed_work_sync(&pool->work)); } while (cancel_delayed_work_sync(&pool->work));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment