From ce1b1d6ec42552e30ff9cdfd12d48ab61fa2425e Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 15 Mar 2021 13:46:14 +0200 Subject: [PATCH] logalloc: background reclaim: fix shares not updated by periodic timer adjust_shares() thinks it needs to do nothing if the main loop is running, but in reality it can only avoid waking the main loop; it still needs to adjust the shares unconditionally. Otherwise, the background reclaim shares can get locked into a low value. Fix by splitting the conditional into two. --- utils/logalloc.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/logalloc.cc b/utils/logalloc.cc index af16328d39..0ae0acf0e9 100644 --- a/utils/logalloc.cc +++ b/utils/logalloc.cc @@ -409,9 +409,11 @@ private: llogger.debug("background_reclaimer::main_loop: exit"); } void adjust_shares() { - if (_main_loop_wait && have_work()) { + if (have_work()) { _sg.set_shares(1 + (1000 * (free_memory_threshold - memory::stats().free_memory())) / free_memory_threshold); - main_loop_wake(); + if (_main_loop_wait) { + main_loop_wake(); + } } } public: