From nobody Tue Oct 20 16:47:21 2026 X-Original-To: dev-commits-src-main@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 4j8JHG1bHfz6vlqt for ; Tue, 20 Oct 2026 16:47:22 +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 4j8JHF6ypzz4YBT for ; Tue, 20 Oct 2026 16:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792514842; 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=phDLCxtOJkeB0h6j592+JkiC5F+G4cnyxbk2lJLoz5U=; b=XErl3K8YPx+SznhFuIItGSeGxy9drYAQDl7mvwO0/q8YndNBvAEvjILF8t9Q2J/nYusMov 9jVojmULufmk2voykD29WR7TQthCjQSmDsODUBPmP+4UYX/7pEqZzwJipxHQFaEN/YKAng iT2xmkc34Q3q+KWlsM+qT4t8rNxxgbwSUTb2lqSxfdwrzn+UTRBzBNotp9/l1shzEbVmo+ WZ0i2U3qsxASlq4TvE+9RehLEPhvnuoGtWdLVQ9lFXgRHLRP0RnLlVFjvZ0wHsIojwsQwd EAaXvoheMHHTyij0Xq2XBLnUHpxsempaxcYUSphsWjhMppd6ty1HA2o7FIU0TQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792514842; b=Yxq45kHwOGMTo7Q+87+7yH4FCwn6YhdcZ1oin0AvevQMJMe8L/iDoT/3nwL9IGFvJStdeV 68CNWAkhS4bBjBzoR9Wlkdx1zfu7paluaAxxNpQF73lurl7wvN1gTHFazeaysYWpvabkBS u0GPatUQweJMc2tlksW4NXPjO7XKF2aGbmoVL9u/tMPA/v50iElsFmvpiwGV37VcdPcCzF 6SGfqRkmSbwI7891GAmYrumttx//z8UM5XO796j2n5Uj/DTOECTE0jdJKCiOvuUeCSVlYF AMXXfYAp7U/RJQ8g+4NpPEnreWOU+u50QyV2n1phQCDzB08TXQFYqVV5QFlgjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792514842; 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=phDLCxtOJkeB0h6j592+JkiC5F+G4cnyxbk2lJLoz5U=; b=sbsysc0/Ojmh8pXvoKSc13+4vojAlfYFd7QeXuxwpJm5NrY/48iZ2PbksZAFr9OznUdovN aV6A1Hx1qtq6LxwiH6n2gDdSLrYIdA/vKiWQX56592Eq0b9Pv4vGXP4M3Bfx6hvajwTs+7 ULN2wFw21e2mkd704baAeY6X3T8sx/R53WTbzsE4dvJB5RmhoQVyyhTYnhkCigR3TNo8wo 23HeVhmLeb4hM9fcYu28H61fQM4D+naMiGc6CxvU5Zkb6GA5bxDbCGYFy5Z+0KHrzC0LZt XsSbRBWOBmK8EWqbO//rSho/xqabkgs2oyxRIN0fLL0k/sCNJzV0jP/VzrwyOg== 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 4j8JHF6dJ7zG5d for ; Tue, 20 Oct 2026 16:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 20676 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 20 Oct 2026 16:47:21 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 3a0e2ca3eecd - main - x86: ipi_bitmap_handler(): Account for IPIs correctly on COUNT_IPIS List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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: 3a0e2ca3eecd3176fa7dd139e59913a67c858ac9 Auto-Submitted: auto-generated Date: Tue, 20 Oct 2026 16:47:21 +0000 Message-Id: <6ad79b19.20676.3c695cf2@gitrepo.freebsd.org> The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=3a0e2ca3eecd3176fa7dd139e59913a67c858ac9 commit 3a0e2ca3eecd3176fa7dd139e59913a67c858ac9 Author: Olivier Certner AuthorDate: 2026-10-13 14:46:26 +0000 Commit: Olivier Certner CommitDate: 2026-10-20 16:46:13 +0000 x86: ipi_bitmap_handler(): Account for IPIs correctly on COUNT_IPIS A preemption could occur before the updates to the initial CPU's IPI counters, leading to a potential non-atomic updates of these counters from another CPU. Reviewed by: kib Fixes: ff326a187907 ("x86: Restore the critical section (...)") MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60862 --- sys/x86/x86/mp_x86.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 8fdeff859561..abdc18feb5f8 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -1347,14 +1347,21 @@ ipi_bitmap_handler(struct trapframe *frame) td->td_intr_nesting_level++; oldframe = td->td_intr_frame; td->td_intr_frame = frame; + +#ifdef COUNT_IPIS + if (ipi_bitmap & (1 << IPI_AST)) { + (*ipi_ast_counts[cpu])++; + if (ipi_bitmap & (1 << IPI_HARDCLOCK)) { + (*ipi_hardclock_counts[cpu])++; + if (ipi_bitmap & (1 << IPI_PREEMPT)) + (*ipi_preempt_counts[cpu])++; +#endif + #if defined(STACK) || defined(DDB) if (ipi_bitmap & (1 << IPI_TRACE)) stack_capture_intr(); #endif if (ipi_bitmap & (1 << IPI_HARDCLOCK)) { -#ifdef COUNT_IPIS - (*ipi_hardclock_counts[cpu])++; -#endif /* * Enter a critical section so that hardclockintr() can execute * entirely without preemption (as it calls code that can enter @@ -1371,9 +1378,6 @@ ipi_bitmap_handler(struct trapframe *frame) critical_exit(); } if (ipi_bitmap & (1 << IPI_AST)) { -#ifdef COUNT_IPIS - (*ipi_ast_counts[cpu])++; -#endif /* Nothing to do for AST */ } /* @@ -1382,13 +1386,8 @@ ipi_bitmap_handler(struct trapframe *frame) * IPIs are processed in due course (in particular, hardclockintr()), it * has to be called last. */ - if (ipi_bitmap & (1 << IPI_PREEMPT)) { -#ifdef COUNT_IPIS - (*ipi_preempt_counts[cpu])++; -#endif - if (do_preempt) - sched_preempt(td); - } + if (ipi_bitmap & (1 << IPI_PREEMPT) && do_preempt) + sched_preempt(td); td->td_intr_frame = oldframe; td->td_intr_nesting_level--; }