Skip to content
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

scx_layered: handle nr_to_free calculation #1073

Merged

Conversation

luigidematteis
Copy link
Contributor

The variable nr_to_free in scx_layered/src/main.rs is assigned an incorrect value due to a subtraction overflow, as reported in this issue #1072.

Ensure nr_to_free is correctly handled to prevent subtraction overflow, adding a check to set nr_to_free to 0 if nr_freed > nr_to_free.

@luigidematteis luigidematteis marked this pull request as ready for review December 8, 2024 09:01
nr_to_free = 0
} else {
nr_to_free -= nr_freed;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do nr_to_free.saturating_sub(nr_freed)?

@luigidematteis luigidematteis force-pushed the fix-cpus-freed-subtraction-overflow branch from d1a9ed3 to 19e57e3 Compare December 8, 2024 13:41
Ensure nr_to_free is correctly handled to prevent subtraction overflow.
Added a check to set nr_to_free to 0 if nr_freed > nr_to_free.

Resolves sched-ext#1072

Signed-off-by: Luigi De Matteis <ldematteis123@gmail.com>
@luigidematteis luigidematteis force-pushed the fix-cpus-freed-subtraction-overflow branch from 19e57e3 to b73e505 Compare December 8, 2024 13:44
@htejun htejun added this pull request to the merge queue Dec 8, 2024
Merged via the queue into sched-ext:main with commit d9c02dd Dec 8, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants