git: f4abec175b2a - main - acpi: Tasks: Count task slots used during boot separately
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Nov 2026 12:16:44 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=f4abec175b2a63d361d50c39338902f581f4af0d
commit f4abec175b2a63d361d50c39338902f581f4af0d
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-10-08 12:55:47 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-11-25 12:15:49 +0000
acpi: Tasks: Count task slots used during boot separately
During boot, tasks can be enqueued by drivers before the scheduler is up
and the ACPI taskqueue threads running. Such tasks pile up in the task
queue until they can actually be processed. This makes the number
reported by the 'debug.acpi.tasks_hiwater' sysctl(8) knob less useful,
as if it is representative of the maximum amount of storage needed, it
does not allow to understand the degree of task concurrency at run-time,
which itself can be useful to size the queue and/or the number of
processing threads.
Create a separate counter for tasks queued at boot, and update it
instead of the already existing one before the taskqueue starts being
processed. Export it via the new 'debug.acpi.boot_tasks_nb' sysctl(8)
knob. The existing counter is now updated only after this phase.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61546
---
sys/dev/acpica/Osd/OsdSchedule.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c
index 2684e13ff86a..11b5e5a4915a 100644
--- a/sys/dev/acpica/Osd/OsdSchedule.c
+++ b/sys/dev/acpica/Osd/OsdSchedule.c
@@ -57,9 +57,14 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks,
/*
* Track and report the system's demand for task slots.
*/
-static int acpi_tasks_hiwater;
+static int acpi_boot_tasks_nb;
+SYSCTL_INT(_debug_acpi, OID_AUTO, boot_tasks_nb, CTLFLAG_RD,
+ &acpi_boot_tasks_nb, 0,
+ "Amount of ACPI event tasks queued at boot before processing starts.");
+static int acpi_tasks_high_water;
SYSCTL_INT(_debug_acpi, OID_AUTO, tasks_hiwater, CTLFLAG_RD,
- &acpi_tasks_hiwater, 1, "Peak demand for ACPI event task slots.");
+ &acpi_tasks_high_water, 0,
+ "Peak demand for ACPI event task slots (after boot).");
/*
* Allow the user to tune the number of task threads we start. It seems
@@ -155,9 +160,11 @@ static ACPI_STATUS
acpi_task_enqueue(int priority, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
{
struct acpi_task_ctx *at;
- int hiwater, i;
+ int *high_water_p;
+ int high_water, i;
- for (at = NULL, i = 0; i < acpi_max_tasks; i++)
+ at = NULL;
+ for (i = 0; i < acpi_max_tasks; i++)
if (atomic_cmpset_int(&acpi_tasks[i].at_flag, ACPI_TASK_FREE,
ACPI_TASK_USED)) {
at = &acpi_tasks[i];
@@ -165,8 +172,11 @@ acpi_task_enqueue(int priority, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
break;
}
- while (hiwater = atomic_load_int(&acpi_tasks_hiwater), i + 1 > hiwater) {
- if (atomic_cmpset_int(&acpi_tasks_hiwater, hiwater, i + 1))
+ /* Update the appropriate high water mark. */
+ high_water_p = acpi_taskq_started ? &acpi_tasks_high_water :
+ &acpi_boot_tasks_nb;
+ while (high_water = atomic_load_int(high_water_p), i + 1 > high_water) {
+ if (atomic_cmpset_int(high_water_p, high_water, i + 1))
break;
cpu_spinwait();
}