summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Qiang <liqiang01@kylinos.cn>2026-07-15 09:58:24 +0800
committerGabriele Monaco <gmonaco@redhat.com>2026-07-23 13:38:23 +0200
commitb255fc56f4e85fb34a491be9aa31bece3f4f3958 (patch)
tree0a4e25858c0dc90df128b00eb48eab923e25794e
parent2a8cd68cc0ba9930ee966ef07d6e1a6a4b0e5b0f (diff)
downloadlinux-next-b255fc56f4e85fb34a491be9aa31bece3f4f3958.tar.gz
linux-next-b255fc56f4e85fb34a491be9aa31bece3f4f3958.zip
rv: Simplify task monitor slot management
The slot array already tracks allocation and task_monitor_count duplicates that state. On an invalid second release, the old code warns but still decrements the counter, corrupting later allocations. Use the slot array as the sole source of truth. Return after warning about an unused slot, and return -EBUSY when no slot is free. Reviewed-by: Gabriele Monaco <gmonaco@redhat.com> Signed-off-by: Li Qiang <liqiang01@kylinos.cn> Link: https://lore.kernel.org/r/20260715015825.1413822-1-liqiang01@kylinos.cn Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
-rw-r--r--kernel/trace/rv/rv.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
index ee4e68102f17..187d87d5991c 100644
--- a/kernel/trace/rv/rv.c
+++ b/kernel/trace/rv/rv.c
@@ -164,7 +164,6 @@ struct dentry *get_monitors_root(void)
*/
LIST_HEAD(rv_monitors_list);
-static int task_monitor_count;
static bool task_monitor_slots[CONFIG_RV_PER_TASK_MONITORS];
int rv_get_task_monitor_slot(void)
@@ -173,21 +172,14 @@ int rv_get_task_monitor_slot(void)
lockdep_assert_held(&rv_interface_lock);
- if (task_monitor_count == CONFIG_RV_PER_TASK_MONITORS)
- return -EBUSY;
-
- task_monitor_count++;
-
for (i = 0; i < CONFIG_RV_PER_TASK_MONITORS; i++) {
- if (task_monitor_slots[i] == false) {
+ if (!task_monitor_slots[i]) {
task_monitor_slots[i] = true;
return i;
}
}
- WARN_ONCE(1, "RV task_monitor_count and slots are out of sync\n");
-
- return -EINVAL;
+ return -EBUSY;
}
void rv_put_task_monitor_slot(int slot)
@@ -199,10 +191,10 @@ void rv_put_task_monitor_slot(int slot)
return;
}
- WARN_ONCE(!task_monitor_slots[slot], "RV releasing unused task_monitor_slots: %d\n",
- slot);
+ if (WARN_ONCE(!task_monitor_slots[slot],
+ "RV releasing unused task monitor slot: %d\n", slot))
+ return;
- task_monitor_count--;
task_monitor_slots[slot] = false;
}