fix(scheduler): percent-limit capacity reads maxmem/maxswap, not mem/swap (bug-1834)

update_limit_res_value() computed a percent-based limit's capacity from
the resource's own live, fluctuating value (e.g. "mem"), letting the
enforced cap drift with unrelated memory pressure instead of staying
pinned to a stable fraction of total capacity. instantiate_limit() now
resolves a static capacity-source resource once at instantiation time
(mem->maxmem, swap->maxswap, table-driven), stored on a new
xce_vres_t.percent_res field; a missing counterpart falls back to
today's behavior rather than failing instantiation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
Rongsong Shen 2026-09-20 13:18:05 +00:00
parent 7982f28557
commit ea76f4771f
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
8 changed files with 368 additions and 15 deletions

View file

@ -826,6 +826,15 @@ typedef struct {
typedef struct {
xce_resource_t* vres;
xce_resource_t* res;
/* bug-1834: resolved capacity-source resource for a percent-based
* limit on a dynamic/consumable resource (e.g. "mem" -> "maxmem",
* "swap" -> "maxswap") -- NULL when `res` itself already IS the right
* source (percent==0, or no static counterpart is registered/known).
* update_limit_res_value() (plugins/limit.c) reads this in preference
* to `res` so a percent limit's capacity is pinned to the resource's
* static total instead of drifting with its live, fluctuating value
* (see .kiro/steering/resource-accounting.md's "mem is not maxmem"). */
xce_resource_t* percent_res;
xce_limit_t* limit;
} xce_vres_t;