fix: register halt_irq PM ops to poll sockets during cooperative scheduler idle#106
fix: register halt_irq PM ops to poll sockets during cooperative scheduler idle#106danbugs wants to merge 4 commits into
Conversation
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Hyperlight example builds to use a Unikraft branch that polls sockets during cooperative-scheduler idle (via halt_irq PM ops), and adds a regression test covering urllib.request.urlopen() without an explicit timeout (the path that previously hung due to lack of socket polling).
Changes:
- Point
examples/networking-pyandexamples/python-agent-driveratdanbugs/unikraft:fix/net-poll-sleep. - Add
urllib_get_no_timeout.pyand include it in the networking-py rootfs. - Extend CI (
test-examples.yml) to run the new networking test on both Linux and Windows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/python-agent-driver/kraft.yaml | Switch Unikraft source/version to the branch containing the halt_irq socket-polling fix. |
| examples/networking-py/kraft.yaml | Switch Unikraft source/version to the branch containing the halt_irq socket-polling fix. |
| examples/networking-py/urllib_get_no_timeout.py | New urllib GET test that omits timeout= to exercise the previously-hanging code path. |
| examples/networking-py/Dockerfile | Include the new test script in the example rootfs. |
| .github/workflows/test-examples.yml | Run the new networking test in CI on Linux and Windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| unikraft: | ||
| source: https://github.com/unikraft/unikraft.git | ||
| version: plat-hyperlight | ||
| source: https://github.com/danbugs/unikraft.git | ||
| version: fix/net-poll-sleep |
| unikraft: | ||
| source: https://github.com/unikraft/unikraft.git | ||
| version: plat-hyperlight | ||
| source: https://github.com/danbugs/unikraft.git | ||
| version: fix/net-poll-sleep |
| - example: networking-py | ||
| args: "--net -- /urllib_get_no_timeout.py" | ||
| expect: "SUCCESS: urllib GET \\(no timeout\\) worked!" |
There was a problem hiding this comment.
Linux Benchmarks
Details
| Benchmark suite | Current: 7bed20f | Previous: 682ad20 | Ratio |
|---|---|---|---|
hello_world (median) |
20 ms |
20 ms |
1 |
pandas (median) |
110 ms |
120 ms |
0.92 |
density (per VM) |
8 MB |
8 MB |
1 |
snapshot (disk) |
654 MiB |
653 MiB |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Windows Benchmarks
Details
| Benchmark suite | Current: 7bed20f | Previous: 682ad20 | Ratio |
|---|---|---|---|
hello_world (median) |
284 ms |
291 ms |
0.98 |
pandas (median) |
920 ms |
1024 ms |
0.90 |
density (per VM) |
7 MB |
7 MB |
1 |
snapshot (disk) |
661 MiB |
661 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Summary
networking-pyandpython-agent-driverkraft.yaml atdanbugs/unikraft:fix/net-poll-sleep, which registers ahalt_irqPM ops callback so the cooperative scheduler's idle thread polls sockets via__hl_sleepinstead of spinningurllib_get_no_timeout.pyCI test that exercisesurlopen()without an explicit timeout — the code path used by mxc that currently hangs on WindowsKey kernel changes (in
danbugs/unikraft:fix/net-poll-sleep)uk_lcpu_halt_irqfromplat/hyperlight/x86/lcpu.c(was shadowed bylib/uklcpu/lcpu.c)halt_irqPM ops inplat/hyperlight/shutdown.cthat callstime_block_until()— polls sockets via__hl_sleepfrom the scheduler's idle threaduk_boot_early_init()insetup.cso the native platform's HLT-based halt_irq doesn't overwrite itContext
When
urllib.request.urlopen()is called without an explicit timeout, Python never setsSO_RCVTIMEO/SO_SNDTIMEO. The cooperative scheduler's idle thread then callsuk_lcpu_halt_irq()which was a no-op spinwait — sockets were never polled, so the connection hung indefinitely. This fix makes the idle thread poll sockets, matching the behavior when timeouts are set.Test plan
urllib_get_no_timeout.pypasses on Linuxurllib_get_no_timeout.pypasses on Windows