Drop a spill request that reaches the handler after the resume it was asked before

This commit is contained in:
Kurt Himebauch committed 2026-12-05 04:34:25 -05:00
1 parent fbf1788647
commit c6333350ae
2 files changed
+18 -2

No files matched your search

+8 -1
View File
@@ -745,7 +745,7 @@ static int zr_resumed(void) {
// Runs in a process that shares the owner's memory, so it keeps running while every owner thread is stopped.
static void zr_helper(void) {
zr_sys(SYS_prctl, PR_SET_NAME, "zr-spill");
if (!zr_seize_all()) {
if (!zr_seize_all() || zr_resumed()) {
zr_detach_all();
return;
}
@@ -816,9 +816,16 @@ static void zr_request(int worker) {
int mode = zr_mode(&want);
if (mode < 0) return;
if (mode == 4) {
// A request that reaches this after the resume it was asked before has nothing left to do: the
// controller no longer waits for it, and holding the process now would stop it after the resume.
#if defined(__aarch64__)
zr_baseline = zr_request_arg;
if (zr_resumed()) return;
#endif
zr_ack(-1, ".ack.");
#if defined(__aarch64__)
if (worker && zr_spill()) return;
if (zr_resumed()) return;
#endif
zr_visits = worker ? ZR_FAILED : ZR_INLINE_CHUNKS;
zr_walk(1, 1, 0, 0);
+10 -1
View File
@@ -179,9 +179,11 @@ int main(int argc, char **argv) {
return 5;
}
}
int stale = argc > 3 && !strcmp(argv[3], "stale");
if (stale) put(".resume", "1"); // resumed already: the request below comes too late
put(".hold", "4 0");
kill(child, SIGURG);
long spilled = wait_for(".ack.", child, 20000);
long spilled = wait_for(".ack.", child, stale ? 2000 : 20000);
long after = rss_kb(child);
shared->quiet = 0;
long frozen_at = shared->progress;
@@ -259,6 +261,13 @@ class ZramSpillPreloadTest(unittest.TestCase):
self.assertGreater(r["resumed"], 0)
self.assertEqual(r["errors"], 0)
def test_a_request_that_arrives_after_the_resume_is_dropped(self):
r = self.run_spill("stale")
self.assertEqual(r["exit"], 0)
self.assertLess(r["spilled"], 0) # no answer: nothing was held or written
self.assertGreater(r["frozen"], 0) # it kept running throughout
self.assertEqual(r["errors"], 0)
def test_a_process_that_cannot_be_traced_falls_back_to_zram(self):
r = self.run_spill("undumpable")
self.assertEqual(r["exit"], 0)