Fixed job object API for handling 0 cpu limit#549
Open
shrjadhav-msft wants to merge 3 commits intomasterfrom
Open
Fixed job object API for handling 0 cpu limit#549shrjadhav-msft wants to merge 3 commits intomasterfrom
shrjadhav-msft wants to merge 3 commits intomasterfrom
Conversation
Contributor
Author
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jebrando
reviewed
Mar 11, 2026
| /*Codes_SRS_JOB_OBJECT_HELPER_88_041: [ During reconfiguration, if percent_cpu is 0 and the job_object_singleton_state.percent_cpu is non-zero, job_object_helper_set_job_limits_to_current_process shall fail and return NULL. ]*/ | ||
| (percent_cpu == 0 && job_object_singleton_state.percent_cpu != 0) || | ||
| /*Codes_SRS_JOB_OBJECT_HELPER_88_046: [ During reconfiguration, if percent_physical_memory is 0 and the job_object_singleton_state.percent_memory is non-zero, job_object_helper_set_job_limits_to_current_process shall fail and return NULL. ]*/ | ||
| (percent_physical_memory == 0 && job_object_singleton_state.percent_memory != 0)) |
Contributor
There was a problem hiding this comment.
I don't believe that percent_cpu & percent_physical_memory can not be zero due to the above check on line 323. check not needed here. #ByDesign
Contributor
There was a problem hiding this comment.
Actually looking closer at this code, I see the that both can't be zero, but one can be zero. So this check is valid.
Contributor
jebrando
reviewed
Mar 11, 2026
| { | ||
| /*Codes_SRS_JOB_OBJECT_HELPER_88_032: [ If there are any failures, internal_job_object_helper_create shall fail and return a non-zero value. ]*/ | ||
| failed = true; | ||
| } |
Contributor
There was a problem hiding this comment.
Probably need to log a failure here to let someone know that the failure in internal_job_object_helper_set_cpu_limit came from this function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the regression in my last commit (reconfiguration of job object PR: #542)
While working with MrBot to reconfigure CPU/memory limits for already created job object, we come across a case where what if user set it to 0 during reconfiguration, the AI confidently guided me toward an implementation that called SetInformationJobObject with JobObjectCpuRateControlInformation using ControlFlags = 0 and CpuRate = 0 to "disable" the CPU rate control. It generated test PS1 scripts to validate that this works, and I trusted those scripts..
So, the previous commit allowed both percent_cpu and percent_physical_memory to be 0 (i.e., "disable both limits"), and also allowed reconfiguring from a non-zero value to 0. Neither of these actually works against the real Windows API. When set to 0, windows API return Invalid Args error.
This PR reverts back that change to disable the limits when value is 0, and again bring back the behavior where we accept limits when they are non-zero.