drm/sched: Avoid killing entity last used by parent on child SIGKILL
Subsystems (3)
PATCH 1/1 drm/sched: Avoid killing entity last used by parent on child SIGKILL
drm_sched_entity_flush should only kill the entity if the current process is the last user of the entity. The last_user is only set when adding new job, so entities that had no jobs submitted to them have NULL last_user and would always be killed.
Another issue is setting last_user to NULL from drm_sched_entity_flush, which causes subsequent calls to kill the entity.
--- drivers/gpu/drm/scheduler/sched_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/scheduler/sched_entity.c +2 -3
@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; + entity->last_user = current->group_leader;/* * It's perfectly valid to initialize an entity without having a valid * scheduler attached. It's just not valid to use the scheduler before it
@@ -278,7 +279,6 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; -struct task_struct *last_user;long ret = timeout;if (!entity->rq)
@@ -301,8 +301,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) }/* For killed process disable any more IBs enqueue right now */ - last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); -if ((!last_user || last_user == current->group_leader) && +if (entity->last_user == current->group_leader && (current->flags &PF_EXITING ) && (current->exit_code ==SIGKILL ))drm_sched_entity_kill (entity);
Signature · 1 line
2.43.0
Quoted 9 lines · David Rosca
drm_sched_entity_flushshould only kill the entity if the current process is the last user of the entity. Thelast_useris only set when adding new job, so entities that had no jobs submitted to them have NULLlast_userand would always be killed.
Another issue is settinglast_userto NULL fromdrm_sched_entity_flush, which causes subsequent calls to kill the entity.Signed-off-by David Rosca <[email protected]>Fixes 51564e9f06f0 ("drm/amdgpu: Avoid extra evict-restore process.")
Good catch, but in general please CC the relevant maintainers and mailing lists for scheduler patches.
Quoted 25 lines
--- drivers/gpu/drm/scheduler/sched_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; + entity->last_user = current->group_leader;/* * It's perfectly valid to initialize an entity without having a valid * scheduler attached. It's just not valid to use the scheduler before it @@ -278,7 +279,6 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; -struct task_struct *last_user;long ret = timeout;if (!entity->rq)
drivers/gpu/drm/scheduler/sched_entity.c long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) · line 304
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -301,8 +301,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) }/* For killed process disable any more IBs enqueue right now */ - last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); - if ((!last_user || last_user == current->group_leader) && + if (entity->last_user == current->group_leader &&
You still need the cmpxchg() here or otherwise drm_sched_entity_kill() would run multiple times.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0(current->flags & PF_EXITING) && (current->exit_code == SIGKILL))drm_sched_entity_kill (entity);
FYI
Quoted 54 lines · Christian König
Quoted 9 lines · David Rosca
drm_sched_entity_flushshould only kill the entity if the current process is the last user of the entity. Thelast_useris only set when adding new job, so entities that had no jobs submitted to them have NULLlast_userand would always be killed.
Another issue is settinglast_userto NULL fromdrm_sched_entity_flush, which causes subsequent calls to kill the entity.Signed-off-by David Rosca <[email protected]>Fixes 51564e9f06f0 ("drm/amdgpu: Avoid extra evict-restore process.")Good catch, but in general please CC the relevant maintainers and mailing lists for scheduler patches.
Quoted 25 lines
--- drivers/gpu/drm/scheduler/sched_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; + entity->last_user = current->group_leader;/* * It's perfectly valid to initialize an entity without having a valid * scheduler attached. It's just not valid to use the scheduler before it @@ -278,7 +279,6 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; -struct task_struct *last_user;long ret = timeout;if (!entity->rq)drivers/gpu/drm/scheduler/sched_entity.c long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) · line 304
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -301,8 +301,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) }/* For killed process disable any more IBs enqueue right now */ - last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); - if ((!last_user || last_user == current->group_leader) && + if (entity->last_user == current->group_leader &&You still need the
cmpxchg()here or otherwisedrm_sched_entity_kill()would run multiple times.Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0(current->flags & PF_EXITING) && (current->exit_code == SIGKILL))drm_sched_entity_kill (entity);
David any objections that I take this patch and make the necessary modifications?
People are pinging me about the problem.
Regards,
Christian.
Quoted 58 lines · Christian König
FYI
Quoted 54 lines · Christian König
Quoted 9 lines · David Rosca
drm_sched_entity_flushshould only kill the entity if the current process is the last user of the entity. Thelast_useris only set when adding new job, so entities that had no jobs submitted to them have NULLlast_userand would always be killed.
Another issue is settinglast_userto NULL fromdrm_sched_entity_flush, which causes subsequent calls to kill the entity.Signed-off-by David Rosca <[email protected]>Fixes 51564e9f06f0 ("drm/amdgpu: Avoid extra evict-restore process.")Good catch, but in general please CC the relevant maintainers and mailing lists for scheduler patches.
Quoted 25 lines
--- drivers/gpu/drm/scheduler/sched_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; + entity->last_user = current->group_leader;/* * It's perfectly valid to initialize an entity without having a valid * scheduler attached. It's just not valid to use the scheduler before it @@ -278,7 +279,6 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; -struct task_struct *last_user;long ret = timeout;if (!entity->rq)drivers/gpu/drm/scheduler/sched_entity.c long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) · line 304
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -301,8 +301,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) }/* For killed process disable any more IBs enqueue right now */ - last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); - if ((!last_user || last_user == current->group_leader) && + if (entity->last_user == current->group_leader &&You still need the
cmpxchg()here or otherwisedrm_sched_entity_kill()would run multiple times.Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0(current->flags & PF_EXITING) && (current->exit_code == SIGKILL))drm_sched_entity_kill (entity);
Quoted 1 line · Christian König
David any objections that I take this patch and make the necessary modifications?
Sure, please go ahead.
Thanks,
David
Quoted 61 lines
People are pinging me about the problem.
Regards,
Christian.Quoted 54 lines · Christian König
FYI
Quoted 51 lines · Christian König
Quoted 9 lines · David Rosca
drm_sched_entity_flushshould only kill the entity if the current process is the last user of the entity. Thelast_useris only set when adding new job, so entities that had no jobs submitted to them have NULLlast_userand would always be killed.
Another issue is settinglast_userto NULL fromdrm_sched_entity_flush, which causes subsequent calls to kill the entity.Signed-off-by David Rosca <[email protected]>Fixes 51564e9f06f0 ("drm/amdgpu: Avoid extra evict-restore process.")Good catch, but in general please CC the relevant maintainers and mailing lists for scheduler patches.
Quoted 25 lines
--- drivers/gpu/drm/scheduler/sched_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/scheduler/sched_entity.c +1
-1@@ -70,6 +70,7 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, entity->guilty = guilty; entity->num_sched_list = num_sched_list; entity->priority = priority; + entity->last_user = current->group_leader;/* * It's perfectly valid to initialize an entity without having a valid * scheduler attached. It's just not valid to use the scheduler before it @@ -278,7 +279,6 @@ static void drm_sched_entity_kill(struct drm_sched_entity *entity)long drm_sched_entity_flush (struct drm_sched_entity *entity,long timeout) {struct drm_gpu_scheduler *sched; -struct task_struct *last_user;long ret = timeout;if (!entity->rq)drivers/gpu/drm/scheduler/sched_entity.c long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) · line 304
Quoted 6 lines
drivers/gpu/drm/scheduler/sched_entity.c +1
-2@@ -301,8 +301,7 @@ long drm_sched_entity_flush(struct drm_sched_entity *entity, long timeout) }/* For killed process disable any more IBs enqueue right now */ - last_user =cmpxchg (&entity->last_user, current->group_leader,NULL ); - if ((!last_user || last_user == current->group_leader) && + if (entity->last_user == current->group_leader &&You still need the
cmpxchg()here or otherwisedrm_sched_entity_kill()would run multiple times.Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/scheduler/sched_entity.c +0
-0(current->flags & PF_EXITING) && (current->exit_code == SIGKILL))drm_sched_entity_kill (entity);