Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177897045
D60373.1795541081.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D60373.1795541081.diff
View Options
diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c
--- a/sys/dev/acpica/Osd/OsdSchedule.c
+++ b/sys/dev/acpica/Osd/OsdSchedule.c
@@ -50,7 +50,7 @@
/*
* Allow the user to tune the maximum number of tasks we may enqueue.
*/
-static int acpi_max_tasks = ACPI_MAX_TASKS;
+static int acpi_max_tasks = -1;
SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks,
0, "Maximum acpi tasks");
@@ -94,6 +94,12 @@
static void
acpi_task_init(void *arg)
{
+ /*
+ * Static init value is -1. Override any negative value passed by the
+ * tunable. ACPI_MAX_TASKS depends on 'mp_ncpus'.
+ */
+ if (acpi_max_tasks < 0)
+ acpi_max_tasks = ACPI_MAX_TASKS;
acpi_tasks = malloc(sizeof(*acpi_tasks) * acpi_max_tasks, M_ACPITASK,
M_WAITOK | M_ZERO);
@@ -111,7 +117,12 @@
acpi_taskq = taskqueue_create_fast("acpi_task", M_NOWAIT,
&taskqueue_thread_enqueue, &acpi_taskq);
+
+ if (acpi_max_threads < 1)
+ acpi_max_threads = 1;
+
taskqueue_start_threads(&acpi_taskq, acpi_max_threads, PWAIT, "acpi_task");
+
if (acpi_task_count > 0) {
if (bootverbose)
printf("AcpiOsExecute: enqueue %d pending tasks\n",
@@ -145,7 +156,7 @@
acpi_task_enqueue(int priority, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
{
struct acpi_task_ctx *at;
- int i;
+ int hiwater, i;
for (at = NULL, i = 0; i < acpi_max_tasks; i++)
if (atomic_cmpset_int(&acpi_tasks[i].at_flag, ACPI_TASK_FREE,
@@ -155,12 +166,16 @@
break;
}
- if (i > acpi_tasks_hiwater)
- atomic_cmpset_int(&acpi_tasks_hiwater, acpi_tasks_hiwater, i);
+ while (hiwater = atomic_load_int(&acpi_tasks_hiwater), i > hiwater) {
+ if (atomic_cmpset_int(&acpi_tasks_hiwater, hiwater, i))
+ break;
+ cpu_spinwait();
+ }
if (at == NULL) {
- printf("AcpiOsExecute: failed to enqueue task, consider increasing "
- "the debug.acpi.max_tasks tunable\n");
+ printf("AcpiOsExecute: Failed to enqueue task, consider increasing "
+ "the 'debug.acpi.max_tasks' tunable\n"
+ "AcpiOsExecute: and reporting 'debug.acpi.tasks_hiwater'.\n");
return (AE_NO_MEMORY);
}
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -31,8 +31,6 @@
#ifdef _KERNEL
-#include "acpi_if.h"
-#include "bus_if.h"
#include <sys/_eventhandler.h>
#ifdef INTRNG
#include <sys/intr.h>
@@ -42,12 +40,17 @@
#include <sys/mutex.h>
#include <sys/power.h>
#include <sys/selinfo.h>
+#include <sys/smp.h> /* For 'mp_ncpus'. */
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <machine/bus.h>
#include <machine/resource.h>
+#include "acpi_if.h"
+#include "bus_if.h"
+
+
struct acpi_softc {
device_t acpi_dev;
struct cdev *acpi_dev_t;
@@ -561,7 +564,7 @@
/* Default maximum number of tasks to enqueue. */
#ifndef ACPI_MAX_TASKS
-#define ACPI_MAX_TASKS MAX(32, MAXCPU * 4)
+#define ACPI_MAX_TASKS (64 + mp_ncpus * 4)
#endif
/* Default number of task queue threads to start. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 24, 5:24 PM (15 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41959400
Default Alt Text
D60373.1795541081.diff (2 KB)
Attached To
Mode
D60373: acpi: Tasks: Ensure sane values for number of tasks and threads
Attached
Detach File
Event Timeline