From nobody Thu Jan 29 18:12:32 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 4f26gN6sXVz6PfJL for ; Thu, 29 Jan 2026 18:12:32 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f26gN4CTJz3ZD4 for ; Thu, 29 Jan 2026 18:12:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769710352; 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=qlQK+mQGextYNcRpLFKjuTcj+mtH7mERyB69jUmiGfY=; b=ljo3J9oRJPDKaPX5sb2ZpsRFwpRdJdC2Rw+BVqlXwDF9x+kQkMk98VXAhPNL21G9W+YuyP Xt1F7kcFSXbMq1JIb5qk+o30bJ2sf0w5jwKaYk8ISjP0UPMGIUOSQMSdyTPm88hVU1ceHs KesA4+ROgcREvMSxB5F/uNQ6A2zE29n45bZoLVd8M8iLHyhLRegKuVIam+zYcZ8nXj4wkl nEwceXc4c035lyS78pjkwHk0mYmwL2n0Ca95jI9kQztVuNIfUx8Y75o6C4o98poLzfWvXq tIt7M0yIDsHb05ycsoBXXwC7WXAQ0umd7y0lezIrH64O0ZKE6a1Vc5Hmho9q8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769710352; a=rsa-sha256; cv=none; b=Btu5BLabxdBpVD+KmP9fNNl32Aqvue9Z6cq6N/OOlwgaHgD3XzuhU9Q3qF2eNKQjjdZHmY 6oBnyvdB7/hPOZAC4FCBM4j3ru8rqb8m7ZdcPEMhnv4tv8XT28w+TLLjBvMpjl0m9siHl5 5CwSpvqaf5GrkTepNfFuABUcjuwUVrp6aWb9i57g4A9ZbnddD9SQLQycLbufGmM8+Y8YoN KvuPf3ShOfKl2CwyU2V4/uTA7KHYIUAhkZERU8c8mYg04GLXvopTg3uifnH7NU6aey7z4G CxoYa6pnE0HndPm5767eNVwv2irBxTIAOQXCtsH1EGv7Co0nyWFGj3IKp/hvkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769710352; 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=qlQK+mQGextYNcRpLFKjuTcj+mtH7mERyB69jUmiGfY=; b=mU9xiFXCQDO+4BjbAMzSeZcSN30xP0uUfHY3UFdPtZ6ShHicmlGuGQH8k8U6OBFewL3M7M ejGJ655cO+zsFV2i22HTY455IaV65s9Y3V0IkRHIeUG9rowAhUQLjxVM9igXkXuuu0E1Nd pCCY1PHHzGN7mUBYSXb+UYc5uf9TSOplerSrNJ6b8XK6vlflEbwCLN8567rk4ucWFCZomg J7gCuJ2Bz1nmHtqYoNuNwtKVCLjXhuttxF6LF0sVVwva55SoC0TJ7DYBdR3t5Auy9QbXHY LO1a0rKBgxcss7wV/eyQ5cHz6Yr2Rp4BqphVbMWGuMkfq3lP6uOAvaa4hVUk2Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f26gN3N8Qzq49 for ; Thu, 29 Jan 2026 18:12:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 46df4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Jan 2026 18:12:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 377c053a43f3 - main - cpu_switch(): unconditionally wait on the blocked mutex transient List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 377c053a43f347588ce6800627adb634f87f8cf9 Auto-Submitted: auto-generated Date: Thu, 29 Jan 2026 18:12:32 +0000 Message-Id: <697ba310.46df4.f30fa78@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=377c053a43f347588ce6800627adb634f87f8cf9 commit 377c053a43f347588ce6800627adb634f87f8cf9 Author: Konstantin Belousov AuthorDate: 2026-01-22 12:57:24 +0000 Commit: Konstantin Belousov CommitDate: 2026-01-29 18:11:56 +0000 cpu_switch(): unconditionally wait on the blocked mutex transient It is nop for 4BSD. Reviewed by: olce Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54831 --- sys/amd64/amd64/cpu_switch.S | 5 ----- sys/arm/arm/swtch-v6.S | 7 +------ sys/arm64/arm64/swtch.S | 3 +-- sys/i386/i386/swtch.S | 31 +++++++++++++------------------ sys/powerpc/powerpc/swtch32.S | 3 +-- sys/powerpc/powerpc/swtch64.S | 3 +-- sys/riscv/riscv/swtch.S | 3 +-- 7 files changed, 18 insertions(+), 37 deletions(-) diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S index d7e954f573b0..17ff8005e3cd 100644 --- a/sys/amd64/amd64/cpu_switch.S +++ b/sys/amd64/amd64/cpu_switch.S @@ -35,7 +35,6 @@ #include #include "assym.inc" -#include "opt_sched.h" /*****************************************************************************/ /* Scheduling */ @@ -136,13 +135,11 @@ ctx_switch_fpusave_done: movq %r15,TD_LOCK(%r13) /* Release the old thread */ sw1: leaq TD_MD_PCB(%r12),%r8 -#if defined(SCHED_ULE) movq $blocked_lock, %rdx movq TD_LOCK(%r12),%rcx cmpq %rcx, %rdx je sw1wait sw1cont: -#endif /* * At this point, we've switched address spaces and are ready * to load up the rest of the next context. @@ -492,7 +489,6 @@ ENTRY(resumectx) END(resumectx) /* Wait for the new thread to become unblocked */ -#if defined(SCHED_ULE) sw1wait: 1: pause @@ -500,4 +496,3 @@ sw1wait: cmpq %rcx, %rdx je 1b jmp sw1cont -#endif diff --git a/sys/arm/arm/swtch-v6.S b/sys/arm/arm/swtch-v6.S index 97d863b6d4de..98c8e5c41ec5 100644 --- a/sys/arm/arm/swtch-v6.S +++ b/sys/arm/arm/swtch-v6.S @@ -79,7 +79,6 @@ */ #include "assym.inc" -#include "opt_sched.h" #include #include @@ -432,11 +431,7 @@ sw1: * r11 = newtd */ -#if defined(SMP) && defined(SCHED_ULE) - /* - * 386 and amd64 do the blocked lock test only for SMP and SCHED_ULE - * QQQ: What does it mean in reality and why is it done? - */ +#if defined(SMP) ldr r6, =blocked_lock 1: ldr r3, [r11, #TD_LOCK] /* atomic write regular read */ diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index a461fded929c..b3bf88135e57 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -31,7 +31,6 @@ #include "assym.inc" #include "opt_kstack_pages.h" -#include "opt_sched.h" #include @@ -197,7 +196,7 @@ ENTRY(cpu_switch) * Release the old thread. */ stlr x2, [x0, #TD_LOCK] -#if defined(SCHED_ULE) && defined(SMP) +#if defined(SMP) /* Spin if TD_LOCK points to a blocked_lock */ ldr x2, =_C_LABEL(blocked_lock) 1: diff --git a/sys/i386/i386/swtch.S b/sys/i386/i386/swtch.S index 5c2e078b5446..cb03c847fbc9 100644 --- a/sys/i386/i386/swtch.S +++ b/sys/i386/i386/swtch.S @@ -30,27 +30,11 @@ * SUCH DAMAGE. */ -#include "opt_sched.h" - #include #include "assym.inc" -#if defined(SMP) && defined(SCHED_ULE) -#define SETOP xchgl #define BLOCK_SPIN(reg) \ - movl $blocked_lock,%eax ; \ - 100: ; \ - lock ; \ - cmpxchgl %eax,TD_LOCK(reg) ; \ - jne 101f ; \ - pause ; \ - jmp 100b ; \ - 101: -#else -#define SETOP movl -#define BLOCK_SPIN(reg) -#endif /*****************************************************************************/ /* Scheduling */ @@ -162,7 +146,7 @@ ENTRY(cpu_switch) /* Switchout td_lock */ movl %esi,%eax movl PCPU(CPUID),%esi - SETOP %eax,TD_LOCK(%edi) + xchgl %eax,TD_LOCK(%edi) /* Release bit from old pmap->pm_active */ movl PCPU(CURPMAP), %ebx @@ -181,7 +165,18 @@ ENTRY(cpu_switch) #endif btsl %esi, PM_ACTIVE(%ebx) /* set new */ sw1: - BLOCK_SPIN(%ecx) +#ifdef SMP + movl $blocked_lock,%eax +100: + + lock + cmpxchgl %eax,TD_LOCK(reg) + jne 101f + pause + jmp 100b +101: +#endif + /* * At this point, we have managed thread locks and are ready * to load up the rest of the next context. diff --git a/sys/powerpc/powerpc/swtch32.S b/sys/powerpc/powerpc/swtch32.S index 7fc0641722aa..262e7035bb29 100644 --- a/sys/powerpc/powerpc/swtch32.S +++ b/sys/powerpc/powerpc/swtch32.S @@ -56,7 +56,6 @@ */ #include "assym.inc" -#include "opt_sched.h" #include @@ -125,7 +124,7 @@ ENTRY(cpu_switch) sync /* Make sure all of that finished */ cpu_switchin: -#if defined(SMP) && defined(SCHED_ULE) +#if defined(SMP) /* Wait for the new thread to become unblocked */ bl 1f 1: diff --git a/sys/powerpc/powerpc/swtch64.S b/sys/powerpc/powerpc/swtch64.S index ba37274d32bb..61af10aabaee 100644 --- a/sys/powerpc/powerpc/swtch64.S +++ b/sys/powerpc/powerpc/swtch64.S @@ -56,7 +56,6 @@ */ #include "assym.inc" -#include "opt_sched.h" #include @@ -187,7 +186,7 @@ save_tar: sync /* Make sure all of that finished */ cpu_switchin: -#if defined(SMP) && defined(SCHED_ULE) +#if defined(SMP) /* Wait for the new thread to become unblocked */ addis %r6,%r2,TOC_REF(blocked_lock)@ha ld %r6,TOC_REF(blocked_lock)@l(%r6) diff --git a/sys/riscv/riscv/swtch.S b/sys/riscv/riscv/swtch.S index cfd19a2d76d6..fc9b493744b8 100644 --- a/sys/riscv/riscv/swtch.S +++ b/sys/riscv/riscv/swtch.S @@ -33,7 +33,6 @@ */ #include "assym.inc" -#include "opt_sched.h" #include #include @@ -315,7 +314,7 @@ ENTRY(cpu_switch) /* Release the old thread */ sd s2, TD_LOCK(s0) -#if defined(SCHED_ULE) && defined(SMP) +#if defined(SMP) /* Spin if TD_LOCK points to a blocked_lock */ la s2, _C_LABEL(blocked_lock) 1: