fix(scheduler-sim-diagnostics): bootstrap limit plugin in sim mode (bug-1825)
info limit was correctly implemented and tested but inert against a real replay: register_limit()'s only call site was normal-mode sched_register_ plugins(); sim mode's own plugin bootstrap (sim_bootstrap_picker()) never registered the limit plugin. The snapshot format already carries the original session's limit config (sim->core.config, a borrowed reference set by xce_sched_core_load_snapshot()) -- nothing needed to change in the recording/replay format. New sim_bootstrap_limit_plugin() (sim_limit.c, mirroring sim_picker.c's structure) registers the plugin via plugin_register_core() and seeds it via a new limit_seed_config(plugin, xce_sched_core_t* core, config) entry point, wired into sim_loop.c alongside the existing sim_bootstrap_picker() call. limit_new_plugin() extracted from register_limit() as a factory, mirroring builtin_fcfs_new_plugin()'s established pattern; register_limit() itself is behavior-preserving. First attempt set plugin->sched to a disguised xce_sched_sim_driver_t*, relying on it sharing xce_scheduler_t's first-member layout to reuse the existing config_hook path -- rejected on review: this repeats the exact cross-cast pattern that already corrupted memory once in this codebase (see core.h's xce_core_cache_clear_cb_t history). Fixed by making limit_seed_config() take xce_sched_core_t* as an honest parameter instead, with limit_update_config() (normal mode) and the new sim path both delegating to a shared limit_seed_config_impl() -- no cast, no aliasing risk, independently verified by two review rounds reading the actual struct layouts and call chains. Also added sim_limit.c to sched_sim_isolation_lib so Req 5 AC 17's controller-I/O-isolation check covers it (an initial gap, closed in the same remediation round). Two ripple waves of the same established link-stub pattern applied to the ~24 white-box test files that #include sim_loop.c. info limit now shows real configured-limit data against a genuine replay. Live usage will still correctly show "no active usage instance yet" until a separate, larger fix (logged as bug-1826) wires limit *matching* into the sim decision path -- deliberately out of this task's scope. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
2f1ffd1e4a
commit
487e7b9419
32 changed files with 1377 additions and 28 deletions
|
|
@ -111,6 +111,7 @@
|
|||
#include "../src/sim.c"
|
||||
#include "../src/sim_loop.c"
|
||||
#include "../src/sim_picker.c" /* bug-1567: sched_sim_driver_run() now calls sim_bootstrap_picker() (sim_loop.c-cap sibling) as an extern -- undefined reference at link time otherwise */
|
||||
#include "../src/sim_limit.c" /* bug-1825: sched_sim_driver_run() now also calls sim_bootstrap_limit_plugin() (sim_loop.c-cap sibling, sim_picker.c's own bug-1567 precedent) as an extern -- undefined reference at link time otherwise */
|
||||
#include "../src/sim_record.c"
|
||||
#include "../src/sim_verify.c"
|
||||
#include "../src/snapshot.c"
|
||||
|
|
@ -152,6 +153,41 @@ var limit_get_usage_instances(xce_sched_core_t* core)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* scheduler-sim-diagnostics spec, task 6 (bug-1825): sim_loop.c's
|
||||
* sched_sim_driver_run() now also calls sim_bootstrap_limit_plugin()
|
||||
* (sim_limit.c, pulled into this TU via the #include above), which in
|
||||
* turn calls limit_new_plugin() (plugins/limit.c, not part of this TU) --
|
||||
* identical link-satisfying stub rationale as limit_get_configured_
|
||||
* limits()/limit_get_usage_instances() immediately above. Returning NULL
|
||||
* here is also the behaviorally correct answer, not just a link
|
||||
* placeholder: sim_bootstrap_limit_plugin() already handles a NULL
|
||||
* limit_new_plugin() return gracefully (logs an ERROR, registers nothing,
|
||||
* returns) -- the exact same "out of memory" path sim_bootstrap_picker()
|
||||
* (sim_picker.c) takes for a NULL builtin_fcfs_new_plugin() -- so this
|
||||
* file's fixtures simply end up with no limit plugin registered, same
|
||||
* observable state as before this task. */
|
||||
xce_sched_plugin_t* limit_new_plugin(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* limit_seed_config() (plugins/limit.c, not part of this TU) -- bug-1825
|
||||
* remediation round 2's new honestly-typed config-seed entry point.
|
||||
* sim_bootstrap_limit_plugin() (sim_limit.c) only calls it after
|
||||
* plugin_register_core() has already succeeded against a real, non-NULL
|
||||
* limit_new_plugin() plugin -- unreachable in this file since the
|
||||
* limit_new_plugin() stub immediately above always returns NULL, but the
|
||||
* symbol must still resolve at link time. Same link-satisfying-stub
|
||||
* rationale as limit_new_plugin() immediately above. */
|
||||
int limit_seed_config(xce_sched_plugin_t* plugin, xce_sched_core_t* core,
|
||||
xce_conf4sched_t* config)
|
||||
{
|
||||
(void)plugin;
|
||||
(void)core;
|
||||
(void)config;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* resource-accounting.md's reconciliation (resource.c, not linked here --
|
||||
* this file only #includes core_events.c). core_events.c's
|
||||
* XCE_CORE_EVENT_JOB_RUSAGE handler calls this whenever job->accounts !=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue