Skip to content
Merged

Rust #393

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
379297b
Try rust
ShawnZhong Sep 21, 2026
6659a66
Refactor build process: replace make.py with kstep.sh, add build and …
ShawnZhong Sep 21, 2026
da735ac
Enhance CI workflow and installation scripts for Rust support
ShawnZhong Sep 21, 2026
d957834
Refactor CI workflow: rename cache steps and remove redundant rust job
ShawnZhong Sep 21, 2026
95b40ac
Enhance build and checkout processes: update build commands, improve …
ShawnZhong Sep 21, 2026
1c18ddd
Refactor kSTEP project structure and enhance host-side functionality
ShawnZhong Sep 21, 2026
83e53a2
Refactor kstep CLI structure and update build process
ShawnZhong Sep 21, 2026
875a9ac
Update documentation in main.rs for clarity on fuzzer binary
ShawnZhong Sep 21, 2026
513126d
Refactor kstep build and run processes
ShawnZhong Sep 21, 2026
8dd0d67
Remove kstep-fuzzer implementation and Cargo configuration; add kstep…
ShawnZhong Sep 21, 2026
f918a07
Update
ShawnZhong Sep 21, 2026
5f1b597
Fix chunk iteration in decode function and improve kernel build proce…
ShawnZhong Sep 21, 2026
60a7f38
Enhance coverage map handling in session: filter out zero coverage ad…
ShawnZhong Sep 21, 2026
a6b9dc2
feat: Add WASM support and visualization commands
ShawnZhong Sep 21, 2026
39164a6
refactor: Update data types in shared memory structures and improve H…
ShawnZhong Sep 21, 2026
d0c6e2e
feat: Replace install_deps.sh with setup.sh for dependency installation
ShawnZhong Sep 21, 2026
b13efa1
fix: update error context for deployment failure in viz module
ShawnZhong Sep 21, 2026
39e70f2
docs: update README and comments for clarity on bug builds and kernel…
ShawnZhong Sep 21, 2026
68901f0
Update
ShawnZhong Sep 21, 2026
3fd08f5
Update
ShawnZhong Sep 21, 2026
d577b84
Update
ShawnZhong Sep 21, 2026
d6a3eec
Update
ShawnZhong Sep 21, 2026
38eea87
fix: improve panic message for unsupported CPU capacity settings
ShawnZhong Sep 21, 2026
b1186aa
feat: enhance task creation command to support cgroup specification
ShawnZhong Sep 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/actions/build-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ runs:

- if: steps.cache.outputs.cache-hit != 'true'
shell: bash
# `clean --all` drops the kbuild objects before caching; the image and Module.symvers survive it
# `make clean` drops the kbuild objects before caching; .config, Module.symvers and the generated headers survive it, which is all the kmod build needs
run: |
./checkout.py ${{ inputs.version }} --tar
./make.py --build ${{ inputs.version }} linux ${{ inputs.cov == 'true' && '--config linux/config.kstep.cov' || '' }}
./make.py --build ${{ inputs.version }} clean --all
./kstep.sh checkout ${{ inputs.version }}
./kstep.sh build ${{ inputs.version }} --linux ${{ inputs.cov == 'true' && '--config linux/config.kstep.cov' || '' }}
make -C build/${{ inputs.version }}/linux clean
67 changes: 40 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,33 @@ env:

jobs:
deps:
name: Cache deps (${{ matrix.arm && 'aarch64' || 'x86_64' }})
name: Deps (${{ matrix.arm && 'aarch64' || 'x86_64' }})
strategy:
matrix:
arm: [false, true]
runs-on: ${{ matrix.arm && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- uses: actions/checkout@v6
- name: Cache deps

- name: Cache apt packages
uses: ./.github/actions/apt-deps
with:
packages: ${{ matrix.arm && env.PACKAGES_AARCH64 || env.PACKAGES_X86_64 }}

# target/ and the registry, shared with the test jobs (same key), saved only here
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
shared-key: kstep
- name: Build Rust
run: cargo build --workspace --release --locked
- name: Format
run: cargo fmt --all --check
- name: Lint
run: cargo clippy --workspace --all-targets --release --locked -- -D warnings
- name: Test
run: cargo test --workspace --release --locked

test:
needs: deps
name: ${{ matrix.fuzz && 'Fuzz' || 'Run' }} ${{ matrix.version }} (${{ matrix.arm && 'aarch64' || 'x86_64' }})
Expand All @@ -44,6 +59,13 @@ jobs:
runs-on: ${{ matrix.arm && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
with:
shared-key: kstep
save-if: false

- name: Build kstep CLI
run: cargo build --release --locked -p kstep

- name: Install deps
uses: ./.github/actions/apt-deps
Expand All @@ -58,35 +80,26 @@ jobs:
cov: ${{ matrix.fuzz }}

- name: Build kSTEP
run: ./make.py --build ${{ matrix.version }} kstep
run: ./kstep.sh build ${{ matrix.version }}

# GitHub's x86_64 runners have nested virtualisation, but /dev/kvm is root-only; the arm
# runners have no /dev/kvm, and QEMU falls back to TCG
- name: Enable KVM
run: '[ -e /dev/kvm ] && sudo chmod 666 /dev/kvm || true'

- name: "[Run] Execute driver"
- name: "[Run] A cli session"
if: ${{ ! matrix.fuzz }}
timeout-minutes: 1
run: ./run.py --build ${{ matrix.version }}
timeout-minutes: 2
run: printf 'create 2\ntick 5\npolicy-rt 1 fifo 50\ntick 5\n' | ./kstep.sh run ${{ matrix.version }}

- name: "[Run] Show driver output"
- name: "[Run] Show the driver's records"
if: ${{ ! matrix.fuzz }}
run: cat results/latest/kstep.jsonl

# - name: "[Fuzz] Execute workers"
# if: ${{ matrix.fuzz }}
# timeout-minutes: 5
# run: |
# ./fuzz.py \
# --build ${{ matrix.version }} \
# --workers 1 \
# --steps 10 \
# --ci_mode

# - name: "[Fuzz] Show fresh-mode log"
# if: ${{ matrix.fuzz }}
# run: cat results/fuzz/fresh/worker.debug.log

# - name: "[Fuzz] Show replay-mode log"
# if: ${{ matrix.fuzz }}
# run: cat results/fuzz/replay/worker.debug.log
- name: Show the kernel log
if: ${{ failure() }}
run: cat results/latest/kernel.log

# - name: "[Fuzz] Show mutation-mode log"
# if: ${{ matrix.fuzz }}
# run: cat results/fuzz/mutation/worker.debug.log
- name: "[Fuzz] Build the fuzzer"
if: ${{ matrix.fuzz }}
run: cargo build --release --locked -p kstep-fuzz
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__
.cache

# Build artifacts
build/
fuzzer/target
fuzzer/out
/build/
/fuzz

# Rust
/target
10 changes: 5 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To reproduce a bug fixed in commit `[hash]`, follow these steps:

#### Planning Stage
- Check out the Linux source code just before the fix: `./checkout.py [hash]~1 [name]_buggy --git`.
- Check out the Linux source code just before the fix: `./kstep.sh checkout [hash]~1 [name]_buggy --git`.
- Read the commit message and patch carefully: `git -C build/master show -U32 [hash]`.
- Carefully analyze the changes introduced in the patch, focusing on modifications in `build/master/kernel/sched`. Trace the call chain that leads to the bug, ensuring you understand the purpose of each function and how they interact. Clearly identify the conditions and system state required to trigger the bug.
- If the commit message contains links, carefully review the content of ALL links as they may provide the additional information about the bug (especially the reproduction conditions). For LKML links (e.g., `lore.kernel.org`, `lkml.kernel.org`, `patch.msgid.link`), extract the email ID and retrieve the message with:
Expand All @@ -18,20 +18,20 @@ To reproduce a bug fixed in commit `[hash]`, follow these steps:
- Try not to directly manipulate internal scheduler state.
- Add detailed logging in your driver for all relevant fields to aid debugging. If necessary, add kernel-side logging with `printk()`.
- Build and execute the driver on the buggy kernel with:
`./checkout.py [hash]~1 [name]_buggy --git && ./make.py --build [name]_buggy linux && ./run.py [driver_name] --build [name]_buggy`
`./kstep.sh checkout [hash]~1 [name]_buggy --git && ./kstep.sh run [name]_buggy [driver_name]`
- Determine whether the bug is reproduced by examining the output logs:
`cat data/logs/latest.log`
`cat results/latest/kernel.log` and `results/latest/kstep.jsonl`
- If you do not observe the bug, refine your implementation and repeat the process.
- After confirming that your driver triggers the bug, rerun the same driver on the fixed kernel:
`./checkout.py [hash] [name]_fixed --git && ./make.py --build [name]_fixed linux && ./run.py [driver_name] --build [name]_fixed`
`./kstep.sh checkout [hash] [name]_fixed --git && ./kstep.sh run [name]_fixed [driver_name]`
- Review the logs to ensure the bug no longer occurs. In rare cases where the issue persists despite the fix, provide clear documentation and report your findings.

#### Refinement Stage

- If you manually altered internal scheduler state to trigger the bug during the triggering stage, refine your driver to reproduce the bug using only public kernel APIs or kSTEP interfaces (`kmod/driver.h`). If needed, consider extending kSTEP to provide the required functionality.
- Make sure that the driver is deterministic, and produce the same trace on the same kernel. If not, investigate the root cause of the non-determinism.
- After confirming your driver can trigger the bug, clearly demonstrate its impact through externally observable behavior, such as changes in task scheduling, rather than relying solely on kernel-internal state.
- Once complete, add your driver to BUGS_EXTRA in `reproduce.py` to enable automated testing.
- Once complete, add an entry for your driver to `bugs.yaml` (with `extra: true`) to enable automated testing.

## Coding Style

Expand Down
Loading