From nobody Fri Nov 13 18:49:52 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jR5sY0yDdz714gn for ; Fri, 13 Nov 2026 18:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jR5sX5Sjpz4TQW for ; Fri, 13 Nov 2026 18:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794595792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HjLAyZ2czd1rmIXtage4CeszpRYr21JLi6CGYlAwooo=; b=bmUP/OzVtkH7Zr0bqYcblEM1I+Rp1FSOCk2/gR0QAQJkXKQ7b8DaIVQ4c7F9+ZmCA/93/1 Daa7FDbIfiFvOSNVMaOyMMQfMKWBkKZRg5IfZsHmAq1ty54UKPelFTnVv0ioggFdbQZoHW 1uJKCk6xGO1uV5VVT+If+poX6EpFmx+/3PRZcLdjkpINuU40RQYTyK/VqQDMRda7Seyj9W XuYr/DNaiJniuBQi7yJYF+BoCqHx1E46fhgopfkfFQB+2jkkL10To+bJnDuLBppa8Ab2N+ LeUFAUePUVW+hkU70hiUJnvoySEDqxi9czT9r2MU0Ess1BH4UJvRAao8RaJhbw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794595792; b=ZhJIGySS8ZyRtt1BLsS2yoShTKwOsnOOTUyqMlIsYCRfsPp+7RC14n6hFquBC3P26FDUjU eftuX3DpfazZpwSrCHPHMC/+08yjjWY+Rh7kSphjKLcXdJq30HrehvrXVVZyqvPQ+WlgDz BGhCRzdqqiZ2hKirX7rBIJtbUWyy9K12FUq48mc+IKiAnxBFfYYZB0Ws7qiWtC0RJoTeN9 /RHwCZNeyn+FOSg6SYMJKNPBG8yqpj1PzmxXtSJtwHrLa+RmLikqeFkMHf9416SGbG0wro ICEaNshRYSfp67G9srNrPNWBpBayZNeN66SaykOlUbQdb7AZUnm9MdhvFE4nXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794595792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HjLAyZ2czd1rmIXtage4CeszpRYr21JLi6CGYlAwooo=; b=TF5+6aKRqd92OYCNuIiODSgsYCOutOpQ04xe/f432jm92/4vZ8z58bmAv30t9tFlwckjnU cJ2aPq4oupcSatvGgvUlalf/Cmcts8niVl14UH5DJ55ncy6HpFXRoeccmTbQl+sN9kv4iW gUJ6Y+g52mqG1OoTBbXFzD1bf/KjEApqu6OFNS/0SucSLTilph2lyUkHz0MsYIHv3gJiTk 1sF54AUcZmwqXRQkZkeyet6m1PCzxMpAA46xSDt/NvUD2q67U5rPzodO6aQb1Ozqwo2u6H X8P8vf+hQo5277EryTrwcSkjpb2TboqOg4BtJkFY3CAfjBNi9vD4+TzrHrdX0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jR5sX4yF5zncy for ; Fri, 13 Nov 2026 18:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1fe6c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Nov 2026 18:49:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: fde43820f31d - main - acpi: Tasks: Precisely report the maximum number of slots used List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fde43820f31dbcec64e41a1ffe3fe1b799e09d04 Auto-Submitted: auto-generated Date: Fri, 13 Nov 2026 18:49:52 +0000 Message-Id: <6af75bd0.1fe6c.39df3a7a@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=fde43820f31dbcec64e41a1ffe3fe1b799e09d04 commit fde43820f31dbcec64e41a1ffe3fe1b799e09d04 Author: Olivier Certner AuthorDate: 2026-10-02 08:11:31 +0000 Commit: Olivier Certner CommitDate: 2026-11-13 18:41:20 +0000 acpi: Tasks: Precisely report the maximum number of slots used To this end, store the actual number of busy slots instead of the index of the final slot selected (off by one), and fix races when updating 'acpi_tasks_hiwater'. The race is that it could happen that a first thread enqueued a task at a higher index than the current maximum, followed by a second one enqueuing at some even higher index, with the first thread updating 'acpi_tasks_hiwater' while the second was exactly after the 'if (i > acpi_tasks_hiwater)' but just before attempting the atomic_cmpset_int() that updates 'acpi_task_hiwater', which then would fail silently (the return value was ignored) leading to the real maximum not being recorded. Fix the race by simply testing the return value of atomic_cmpset_int() and retrying. Use an explicit atomic_load_int() for the guard (that compiles to a regular load, so this change is cosmetic). Note that the atomic_cmpset_int() loop can at most be executed a number of times equal to the reported 'acpi_tasks_hiwater', which appears to be low in practice (~#CPUS). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60375 --- sys/dev/acpica/Osd/OsdSchedule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index badb15dd009f..2684e13ff86a 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -155,7 +155,7 @@ static ACPI_STATUS 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, @@ -165,8 +165,11 @@ acpi_task_enqueue(int priority, ACPI_OSD_EXEC_CALLBACK Function, void *Context) 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 + 1 > hiwater) { + if (atomic_cmpset_int(&acpi_tasks_hiwater, hiwater, i + 1)) + break; + cpu_spinwait(); + } if (at == NULL) { printf("AcpiOsExecute: failed to enqueue task, consider increasing "