mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
hwmon: revert the polling clamp; document long-interval -ENODATA behavior
Per independent review (cdaf3ee0), revert the v7 polling clamp: the established minimum-interval contract is preserved and hwmon_poll_ms is again honored up to 60000 ms. The 2 s served-age bound is unchanged and is never extended to bridge a long polling interval: with hwmon_poll_ms above the age bound, cached samples legitimately expire and reads return -ENODATA between eligible acquisitions. This is now documented in the served-age comment and in the module parameter description. Configuration regression tests updated: long intervals honor the requested minimum (no clamp, no re-poll inside the window) and expose -ENODATA once the cache expires, then refresh at the next eligible poll; intermediate intervals (1000 ms) return -ENODATA after expiry and recover on the next eligible read; the default interval keeps a healthy provider fresh without extra polls. 92/92 PASS.
This commit is contained in:
@ -29,23 +29,16 @@
|
||||
#include "hwmon_adapter.h"
|
||||
|
||||
#define NV_RS_HWMON_MAX_GPUS 32
|
||||
/* Maximum accepted active poll interval. It is chosen so that the
|
||||
* active served-age bound below can never expire a healthy provider's
|
||||
* reading between two polls: 2 * NV_RS_HWMON_POLL_MAX_MS + 1000 ms is
|
||||
* the uncapped active age formula, and the 2000 ms cap dominates only
|
||||
* for intervals above this maximum. Larger configured intervals are
|
||||
* clamped here (not refused), so operators keep functioning polling
|
||||
* and never see artificial no-data gaps from their own interval. */
|
||||
#define NV_RS_HWMON_POLL_MAX_MS 500u
|
||||
#define NV_RS_HWMON_POLL_MAX_MS 60000u
|
||||
/* Served-age bounds. Both are below the 2.5 s acquisition window the
|
||||
* owner's thermal controller accepts (its stale threshold), so a
|
||||
* successful hwmon read can satisfy the controller's freshness
|
||||
* contract. */
|
||||
* contract. The bounds are never extended to bridge a long polling
|
||||
* interval: a configured hwmon_poll_ms above the active bound
|
||||
* legitimately returns -ENODATA between eligible acquisitions rather
|
||||
* than serving stale data. */
|
||||
#define NV_RS_HWMON_MIRROR_MAX_AGE_MS 2000u
|
||||
#define NV_RS_HWMON_ACTIVE_MAX_AGE_MS 2000u
|
||||
static_assert(NV_RS_HWMON_ACTIVE_MAX_AGE_MS >=
|
||||
2u * NV_RS_HWMON_POLL_MAX_MS + 1000u,
|
||||
"accepted poll intervals must stay fresh under the served-age bound");
|
||||
#define NV_RS_HWMON_LIVE_MASK \
|
||||
(NV_RS_HWMON_VALID_TEMP | NV_RS_HWMON_VALID_POWER | \
|
||||
NV_RS_HWMON_VALID_VOLT | NV_RS_HWMON_VALID_GPC_CLK | \
|
||||
@ -86,7 +79,7 @@ static_assert(sizeof(struct nv_rs_hwmon_sample) == 56,
|
||||
static unsigned int hwmon_poll_ms = 500;
|
||||
module_param(hwmon_poll_ms, uint, 0644);
|
||||
MODULE_PARM_DESC(hwmon_poll_ms,
|
||||
"Minimum interval (ms) between active GSP-RM hwmon polls on sysfs read (default 500, 0 = passive mirror only; values above 500 ms are clamped so the 2 s served-age bound never expires a healthy provider's reading between polls)");
|
||||
"Minimum interval (ms) between active GSP-RM hwmon polls on sysfs read (default 500, 0 = passive mirror only; intervals above the 2 s served-age bound can return -ENODATA between polls once cached samples expire - freshness is never extended to bridge the gap)");
|
||||
|
||||
extern void nv_rs_rmapi_node_lock(void);
|
||||
extern void nv_rs_rmapi_node_unlock(void);
|
||||
|
||||
@ -444,16 +444,37 @@ static void test_static_limits_arrive_via_successful_polls(void)
|
||||
nv_rs_hwmon_unregister_dev(&mock_dev);
|
||||
}
|
||||
|
||||
static void test_oversized_poll_interval_is_clamped(void)
|
||||
static void test_long_poll_interval_honors_request_and_exposes_expiry(void)
|
||||
{
|
||||
reset_slot();
|
||||
mock_set_hwmon_poll_ms(60000);
|
||||
CHECK(nv_rs_hwmon_register_dev(&mock_dev, 18) == 0, "register");
|
||||
mock_jiffies += 61000;
|
||||
CHECK(read_temp() == 40000, "baseline acquisition after the cold-start window");
|
||||
CHECK(mock_poll_calls == 1, "one poll");
|
||||
mock_jiffies += 3000;
|
||||
CHECK(read_temp() == -ENODATA, "expired cache reports -ENODATA inside a long window");
|
||||
CHECK(mock_poll_calls == 1, "requested minimum interval is honored, not clamped");
|
||||
mock_jiffies += 58000;
|
||||
CHECK(read_temp() == 40000, "next eligible poll refreshes");
|
||||
CHECK(mock_poll_calls == 2, "poll advanced after the configured window");
|
||||
nv_rs_hwmon_unregister_dev(&mock_dev);
|
||||
mock_set_hwmon_poll_ms(500);
|
||||
}
|
||||
|
||||
static void test_intermediate_poll_interval_returns_enodata_then_recovers(void)
|
||||
{
|
||||
reset_slot();
|
||||
mock_set_hwmon_poll_ms(1000);
|
||||
CHECK(nv_rs_hwmon_register_dev(&mock_dev, 19) == 0, "register");
|
||||
mock_jiffies += 1000;
|
||||
CHECK(read_temp() == 40000, "baseline");
|
||||
mock_jiffies += 2500;
|
||||
CHECK(read_temp() == 40000, "clamped interval still polls and stays fresh");
|
||||
CHECK(mock_poll_calls == 2, "clamped rate-limit window advanced the poll");
|
||||
CHECK(read_temp() == 40000, "acquisition");
|
||||
mock_jiffies += 500;
|
||||
CHECK(read_temp() == 40000, "fresh inside the interval and the age bound");
|
||||
CHECK(mock_poll_calls == 1, "no poll inside the requested window");
|
||||
mock_jiffies += 2000;
|
||||
CHECK(read_temp() == 40000, "expiry triggers a poll at the next eligible read");
|
||||
CHECK(mock_poll_calls == 2, "poll advanced exactly once");
|
||||
nv_rs_hwmon_unregister_dev(&mock_dev);
|
||||
mock_set_hwmon_poll_ms(500);
|
||||
}
|
||||
@ -494,7 +515,8 @@ int main(void)
|
||||
test_non_temp_mirror_does_not_block_poll_temperature();
|
||||
test_poll_stale_temp_does_not_overwrite_newer_mirror_temp();
|
||||
test_static_limits_arrive_via_successful_polls();
|
||||
test_oversized_poll_interval_is_clamped();
|
||||
test_long_poll_interval_honors_request_and_exposes_expiry();
|
||||
test_intermediate_poll_interval_returns_enodata_then_recovers();
|
||||
test_default_interval_never_starves_a_healthy_provider();
|
||||
printf("%s\n", failures ? "FAILED" : "ALL PASSED");
|
||||
return failures ? 1 : 0;
|
||||
|
||||
Reference in New Issue
Block a user