-
Notifications
You must be signed in to change notification settings - Fork 199
mitosis: bugfixes #2904
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
Merged
Merged
mitosis: bugfixes #2904
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
93d5d5b
Add defensive check for zero weight in vtime calculation
likewhatevs 5e50cb0
Initialize cell vtime_now on allocation
likewhatevs 199eae8
Use atomic operations for BPF-to-Rust communication
likewhatevs ada3169
Replace panic-prone expect with recoverable error handling
likewhatevs 067e590
Guard against log10(0) in formatting code
likewhatevs d9c355f
Add bounds check before indexing percpu map vector
likewhatevs cdc5cb1
Fix cgroup lifecycle and cell discovery races
likewhatevs 67be89c
mitosis: Add a test and cleanup script
likewhatevs 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
Some comments aren't visible on the classic Files Changed page.
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,105 @@ | ||
| #!/bin/bash | ||
| # Cleanup all test cgroups created by test scripts | ||
|
|
||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| NC='\033[0m' | ||
|
|
||
| if [ "$EUID" -ne 0 ]; then | ||
| echo -e "${RED}Must run as root${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -e "${YELLOW}========================================${NC}" | ||
| echo -e "${YELLOW}Cleaning up all test cgroups${NC}" | ||
| echo -e "${YELLOW}========================================${NC}\n" | ||
|
|
||
| # Find all test-related cgroups with pattern matching | ||
| TEST_PATTERNS=( | ||
| "test_mitosis*" | ||
| "test_cell*" | ||
| "test_simple*" | ||
| "test_brutal*" | ||
| "test_absolute*" | ||
| "test_working*" | ||
| "test_reuse*" | ||
| "test_verify*" | ||
| "test_cycle*" | ||
| "test_16*" | ||
| "test_15*" | ||
| "test_*" | ||
| "scx_mitosis_test*" | ||
| ) | ||
|
|
||
| CLEANED=0 | ||
| FAILED=0 | ||
|
|
||
| # First pass: Find all matching cgroups at root level | ||
| ALL_TEST_CGROUPS=() | ||
| for pattern in "${TEST_PATTERNS[@]}"; do | ||
| shopt -s nullglob # Make glob return nothing if no matches | ||
| for cg in /sys/fs/cgroup/${pattern}; do | ||
| if [ -d "$cg" ]; then | ||
| ALL_TEST_CGROUPS+=("$cg") | ||
| fi | ||
| done | ||
| shopt -u nullglob | ||
| done | ||
|
|
||
| # Remove duplicates and sort | ||
| UNIQUE_CGROUPS=($(printf '%s\n' "${ALL_TEST_CGROUPS[@]}" | sort -u)) | ||
|
|
||
| if [ ${#UNIQUE_CGROUPS[@]} -eq 0 ]; then | ||
| echo -e "${GREEN}No test cgroups found to clean up${NC}" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo -e "${YELLOW}Found ${#UNIQUE_CGROUPS[@]} test cgroups to clean up${NC}\n" | ||
|
|
||
| # Clean each cgroup | ||
| for test_root in "${UNIQUE_CGROUPS[@]}"; do | ||
| if [ ! -d "$test_root" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| echo -e "${YELLOW}Cleaning $(basename $test_root)...${NC}" | ||
|
|
||
| # Find all child cgroups, deepest first | ||
| if [ -d "$test_root" ]; then | ||
| find "$test_root" -mindepth 1 -type d 2>/dev/null | sort -r | while read -r cg; do | ||
| # Kill all processes in the cgroup | ||
| if [ -f "$cg/cgroup.procs" ]; then | ||
| cat "$cg/cgroup.procs" 2>/dev/null | xargs -r kill -9 2>/dev/null || true | ||
| fi | ||
| sleep 0.05 | ||
| # Remove the cgroup | ||
| rmdir "$cg" 2>/dev/null || true | ||
| done | ||
| fi | ||
|
|
||
| # Remove the root test cgroup | ||
| if [ -f "$test_root/cgroup.procs" ]; then | ||
| cat "$test_root/cgroup.procs" 2>/dev/null | xargs -r kill -9 2>/dev/null || true | ||
| fi | ||
| sleep 0.1 | ||
| rmdir "$test_root" 2>/dev/null || true | ||
|
|
||
| if [ -d "$test_root" ]; then | ||
| echo -e "${RED} ✗ Failed to remove $(basename $test_root)${NC}" | ||
| FAILED=$((FAILED + 1)) | ||
| else | ||
| echo -e "${GREEN} ✓ Removed $(basename $test_root)${NC}" | ||
| CLEANED=$((CLEANED + 1)) | ||
| fi | ||
| done | ||
|
|
||
| echo -e "\n${YELLOW}========================================${NC}" | ||
| echo -e "${GREEN}Cleaned: $CLEANED cgroups${NC}" | ||
| if [ $FAILED -gt 0 ]; then | ||
| echo -e "${RED}Failed: $FAILED cgroups${NC}" | ||
| echo -e "${YELLOW}Try running the cleanup again if some cgroups are still active${NC}" | ||
| else | ||
| echo -e "${GREEN}All test cgroups removed successfully!${NC}" | ||
| fi | ||
| echo -e "${YELLOW}========================================${NC}" |
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.
Uh oh!
There was an error while loading. Please reload this page.