Skip to content

mrs: make quarantine overhead tunable #2376

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
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

brooksdavis
Copy link
Member

@brooksdavis brooksdavis commented Mar 20, 2025

Replace QUARANTINE_RATIO with a fraction set by QUARANTINE_NUMERATOR and QUARANTINE_DENOMINATOR.

@brooksdavis brooksdavis requested review from nwf and markjdb March 20, 2025 23:25
If defined at compile time, QUARANTINE_HIGHWATER limited the size of the
quarantine to QUARANTINE_HIGHWATER bytes.  Given the vast range of
working set sizes this isn't particularly useful except perhaps to set
it to 0.  The environment variable _RUNTIME_REVOCATION_EVERY_FREE_ENABLE
and associated sysctl now serves this purpose.
Use of this macro was removed with store-side revocation support.

Fixes:		62e9115 mrs: remove store-side support")
This allow more granularity including allowing quarantine to exceed 1/2
the size of the heap.

Replace QUARANTINE_RATIO with QUARANTINE_NUMERATOR and
QUARANTINE_DENOMINATOR.  The quarantine is flushed when:

                                    QUARANTINE_NUMERATOR
<quarantine_size> >= <heap size> * ----------------------
                                   QUARANTINE_DENOMINATOR

The default values are QUARANTINE_NUMERATOR=1 and
QUARANTINE_DENOMINATOR=4 respectively giving the same
behavior as the previous default QUARANTINE_RATIO=4.
@brooksdavis brooksdavis force-pushed the mrs-tunable-quarantine branch from a34be82 to b3f3df4 Compare March 24, 2025 18:41
Copy link
Member

@nwf nwf left a comment

Choose a reason for hiding this comment

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

LGTM

The environmental variables _RUNTIME_QUARANTINE_NUMERATOR and
_RUNTIME_QUARANTINE_DENOMINATOR can now override compiled defaults for
QUARANTINE_NUMERATOR and QUARANTINE_DENOMINATOR.
@brooksdavis brooksdavis force-pushed the mrs-tunable-quarantine branch from b3f3df4 to 28227a2 Compare March 26, 2025 17:34
@@ -1316,6 +1321,33 @@ mrs_init_impl_locked(void)
exit(7);
}

if (!issetugid()) {
char *envstr, *end;
if ((envstr = getenv(MALLOC_QUARANTINE_DENOMINATOR_ENV)) !=
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW we have secure_getenv() in libc now, effectively a helper for if (!issetugid()) { var = getenv(...); ... }.

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.

3 participants