diff --git a/core/device/aql.cpp b/core/device/aql.cpp index dba45d63..8357ba5a 100644 --- a/core/device/aql.cpp +++ b/core/device/aql.cpp @@ -958,7 +958,11 @@ void stuck_watch() { std::this_thread::sleep_for(std::chrono::seconds(1)); const int64_t ms = stuck_ms(); const int64_t limit = rad::dev_stuck_exit_ms.load(std::memory_order_relaxed); - if (limit > 0 && ms >= limit) { + /* The load phase is exempt (device.h): a verdict standing before the first engine + * finished bringup is a slow load, not a hang, and killing on it trades a patient + * start for a crash loop. The dumps and the log line still fire -- an operator + * watching a stuck load sees the queue state exactly as before. */ + if (limit > 0 && ms >= limit && rad::dev_engine_ready.load(std::memory_order_acquire)) { dump_queues("the device"); fatal("the device has advanced nothing for %lld s (the queue dumps above name the " "packets it is stuck on); exiting so a restart can bring the server back", @@ -1008,11 +1012,21 @@ struct Stall { g_stuck_progress.store(p, std::memory_order_relaxed); g_stuck_at.store(steady_ns() - (uint64_t)kStallMs * 1000000u, std::memory_order_release); dump_queues(where); - RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the " - "packet named above -- a hung kernel, or a queue the driver evicted and could " - "not restore (amdgpu cwsr_enable=0 is one cause). The process exits once this " - "has stood for scheduler.stuck-exit (%lld s; 0 never)", kStallMs / 1000, - (long long)(rad::dev_stuck_exit_ms.load(std::memory_order_relaxed) / 1000)); + /* The verdict says what the verdict will DO (L-02's rule: never a silent difference): + * before the first engine finished bringup the exit is not armed -- a stall standing + * during a load is a slow load (device.h's dev_engine_ready). */ + if (rad::dev_engine_ready.load(std::memory_order_acquire)) + RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the " + "packet named above -- a hung kernel, or a queue the driver evicted and could " + "not restore (amdgpu cwsr_enable=0 is one cause). The process exits once this " + "has stood for scheduler.stuck-exit (%lld s; 0 never)", kStallMs / 1000, + (long long)(rad::dev_stuck_exit_ms.load(std::memory_order_relaxed) / 1000)); + else + RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the " + "packet named above -- a hung kernel, or a queue the driver evicted and could " + "not restore (amdgpu cwsr_enable=0 is one cause). The engine is still in " + "bringup, so scheduler.stuck-exit is not armed yet: this verdict is reported, " + "not fatal, until the first engine has finished loading", kStallMs / 1000); if (!g_stuck_watch.exchange(true, std::memory_order_acq_rel)) std::thread(stuck_watch).detach(); return; diff --git a/core/device/device.h b/core/device/device.h index 0d9f9108..5634025a 100644 --- a/core/device/device.h +++ b/core/device/device.h @@ -454,6 +454,13 @@ int64_t dev_stuck_ms(); * reported hangs stood for hours, and a stall that clears does so within seconds. */ extern std::atomic dev_stuck_exit_ms; +/* Whether at least one engine has finished bringup. The stuck-exit watchdog reads it: a stall + * verdict standing DURING load is a slow load -- a cold start faulting a mapped tier from disk + * advances none of the counters the verdict watches, and that is legitimate work, not a hang. + * A watchdog that fires there turns one patient start into a supervisor's crash loop. Nothing + * disarms: the phase the flag exempts is only the engine's first. */ +extern std::atomic dev_engine_ready; + /* Longest run of dispatches a played tape leaves unordered. Of any kTapeOverlapRun + 1 * consecutive packets on a queue one carries the barrier bit, so a launched packet still proves * that everything more than that many packets earlier has completed. Argument slots and tape diff --git a/core/device/dispatch.cpp b/core/device/dispatch.cpp index 396e4de0..3ec5bd48 100644 --- a/core/device/dispatch.cpp +++ b/core/device/dispatch.cpp @@ -875,6 +875,7 @@ std::string dev_pci_address(int device) { return dev_string(64, [&](char* b, int n) { return dev()->pci_address(device, b, n); }); } std::atomic dev_stuck_exit_ms{60000}; +std::atomic dev_engine_ready{false}; int64_t dev_stuck_ms() { const auto f = dev()->stuck_ms; return f ? f() : 0; diff --git a/core/engine_bringup.cpp b/core/engine_bringup.cpp index 58f49200..5c8d6d19 100644 --- a/core/engine_bringup.cpp +++ b/core/engine_bringup.cpp @@ -5261,6 +5261,10 @@ int Engine::start() { * restore reads it again (refill_weights). */ if (file_) dev_page_refilled(base); } + /* Bringup done: everything this engine loads is loaded. From here the stuck-exit watchdog + * treats a device that advances nothing as a hang; before here it treats it as a slow load + * (device.h's dev_engine_ready). */ + dev_engine_ready.store(true, std::memory_order_release); return RAD_OK; }