Skip to content

Commit

Permalink
Fix underflow bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
yulistic committed Jun 19, 2024
1 parent 809fe1a commit 9719906
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion linux/mm/htmm_migrater.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static bool need_toptier_demotion(pg_data_t *pgdat, struct mem_cgroup *memcg, un
unsigned long fasttier_max_watermark, fasttier_min_watermark;
int target_nid = htmm_cxl_mode ? 1 : next_demotion_node(pgdat->node_id);
pg_data_t *target_pgdat;
long long nr_exceeded_signed;

if (target_nid == NUMA_NO_NODE)
return false;
Expand Down Expand Up @@ -171,7 +172,13 @@ static bool need_toptier_demotion(pg_data_t *pgdat, struct mem_cgroup *memcg, un
return false;
}

*nr_exceeded = nr_lru_pages + nr_need_promoted + fasttier_max_watermark - max_nr_pages;
// *nr_exceeded = nr_lru_pages + nr_need_promoted + fasttier_max_watermark - max_nr_pages;

// Prevent an underflow.
nr_exceeded_signed = (long long)nr_lru_pages + nr_need_promoted +
fasttier_max_watermark - max_nr_pages;
*nr_exceeded = nr_exceeded_signed < 0 ? 0 : nr_exceeded_signed;

return true;
}

Expand Down

0 comments on commit 9719906

Please sign in to comment.