Skip to content

Commit

Permalink
memory-trim: Fix timestamp overflow warning right after reboot.
Browse files Browse the repository at this point in the history
If OVN is started less than 30 seconds after system boot, it logs:

  |memory_trim|WARN|Detected last active timestamp overflow

The 'now < trim_timeout_ms' is not for a timestamp overflow, but
for the later subtraction.  'now < last_active_ms' is enough to
check for the overflow.

Technically, we shouldn't need to check that now > trim_timeout_ms
before subtraction, because the result should be a signed integer,
but it's cleaner this way.

Fixes: 12ddb1c ("lflow-cache: Automatically trim cache when it becomes inactive.")
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Sep 22, 2023
1 parent 01252a2 commit 7606386
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/memory-trim.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ memory_trimmer_can_run(struct memory_trimmer *mt)
}

long long int now = time_msec();
if (now < mt->last_active_ms || now < mt->trim_timeout_ms) {
if (now < mt->last_active_ms) {
VLOG_WARN_RL(&rl, "Detected last active timestamp overflow");
mt->recently_active = false;
return true;
}

if (now - mt->trim_timeout_ms >= mt->last_active_ms) {
if (now > mt->trim_timeout_ms
&& now - mt->trim_timeout_ms >= mt->last_active_ms) {
VLOG_INFO_RL(&rl, "Detected inactivity "
"(last active %lld ms ago): trimming memory",
now - mt->last_active_ms);
Expand Down

0 comments on commit 7606386

Please sign in to comment.