-
Notifications
You must be signed in to change notification settings - Fork 349
scheduler: guard against subdivision underflow on domain clear #4088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scheduler: guard against subdivision underflow on domain clear #4088
Conversation
In some situations the domain clear routine might encounter a case, when the number of clients is decremented and 0, as such, a subsequent subdivision will result in an integer underflow. Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
| if (atomic_read(&sch->domain->num_clients)) { | ||
| count = atomic_sub(&sch->domain->num_clients, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if num_clients changes here between reading and subtracting. @lgirdwood @plbossart what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if num_clients changes here between reading and subtracting. @lgirdwood @plbossart what do you think ?
We hold the domain->lock during these checks so that should not happen.
BTW, we are kind of mess in this client/task management, I am working on refining them, please see the PR here: #4089
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, this is fine with the locks held.
keyonjie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice observation @slawblauciak , we are somewhat mess in this client/task management part, better to do a thorough cleanup here, please see my PR #4089.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find @slawblauciak !
|
@keyonjie @slawblauciak can we use this in TGL 12 and integrate this alongside the cleanup in v1.8 ? |
Yeah, the plan is to use it with TGL 12 for sure. Not certain about Keyon's change yet. |
|
@keyonjie lets clean up for v1.8 if things are messy today. |
sounds good. |
In some situations the domain clear routine might encounter
a case, when the number of clients is decremented and 0,
as such, a subsequent subdivision will result in an integer underflow.
Signed-off-by: Slawomir Blauciak slawomir.blauciak@linux.intel.com
Fixes #3950
Fixes #3949
Fixes #3947