Repository navigation
fix(pd): raise the RLIMIT_MEMLOCK soft limit to the hard limit at server start #3725
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
Open
Jasen2201
wants to merge
1
commit into
main
Choose a base branch
from
Jasen/raise-memlock-soft-limit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # SPDX-License-Identifier: MIT | ||
| # Copyright (C) 2024-2026, Advanced Micro Devices, Inc. All rights reserved. | ||
|
|
||
| import resource | ||
|
|
||
| import pytest | ||
|
|
||
| from atom.utils import raise_memlock_limit | ||
|
|
||
|
|
||
| def _limits(monkeypatch, soft, hard): | ||
| calls = [] | ||
| monkeypatch.setattr(resource, "getrlimit", lambda kind: (soft, hard)) | ||
| monkeypatch.setattr( | ||
| resource, "setrlimit", lambda kind, lim: calls.append((kind, lim)) | ||
| ) | ||
| return calls | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("hard", [resource.RLIM_INFINITY, 64 << 30]) | ||
| def test_the_soft_limit_rises_to_the_hard_limit(monkeypatch, hard): | ||
| calls = _limits(monkeypatch, 8 << 20, hard) | ||
|
|
||
| raise_memlock_limit() | ||
|
|
||
| assert calls == [(resource.RLIMIT_MEMLOCK, (hard, hard))] | ||
|
|
||
|
|
||
| def test_a_soft_limit_already_at_the_hard_limit_is_left_alone(monkeypatch): | ||
| calls = _limits(monkeypatch, resource.RLIM_INFINITY, resource.RLIM_INFINITY) | ||
|
|
||
| raise_memlock_limit() | ||
|
|
||
| assert calls == [] | ||
|
|
||
|
|
||
| def test_a_refused_raise_only_warns(monkeypatch, caplog): | ||
| monkeypatch.setattr(resource, "getrlimit", lambda kind: (8 << 20, 64 << 30)) | ||
|
|
||
| def refuse(kind, lim): | ||
| raise OSError("refused") | ||
|
|
||
| monkeypatch.setattr(resource, "setrlimit", refuse) | ||
|
|
||
| raise_memlock_limit() | ||
|
|
||
| assert "Failed to raise RLIMIT_MEMLOCK" in caplog.text |
Oops, something went wrong.
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.
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.
this raise is process-wide, so engram mlock2 also flips from refused to granted now. intended? if so please note it in docs..