From nobody Sun May 24 18:42:23 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51B8231F9B7 for ; Sat, 23 May 2026 18:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779562291; cv=none; b=WOHLQTfLChZyTGsz0eKXByH9AwgurMdgxfAHkzdpwR2bawlMdAbQNsBx2o2sDFovUzScDyWk93XCJxLyCu3JrKkciS0sjcaVYYEeEV7uo18gMD6qhFmxYehGe/dRICykRdQkrZEVx5S/5l32uSvf6RDbj82Id4u8vqowhl1GxyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779562291; c=relaxed/simple; bh=fGCYrQZITn15AymVpsL71gc4FDPxP7yav1XJig/tNYQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N1wr792Lh8Cz/DVPcXM6SkvirCnRZmWVC8AtHwo9Rt8YbIXj8kmi9GpZJQejLhUoR/4Z22Cu/5pVd6cdKkX3ad9VVY7tBlof91BH6EvQCU9JWwmoe4Luxmom54VYW3Yu/NBPn50zxhMKcGUEn27QTi7oRrZmf2cEv7Tw7aR91i0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Elag47vu; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Elag47vu" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43d7645adbdso5551650f8f.1 for ; Sat, 23 May 2026 11:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779562289; x=1780167089; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f3KwK4OQz2Wqts/nc3+z0lkaqjN2Z4kU8MCbBSAoxhA=; b=Elag47vuMEzZrmKgPK+ql0yol6FnPgxApgTRveYoCUQMnvMhFRU3eNYzAMIuoCOu0c 1YxbaqGD1eyXgeILo3ou3pnmPCs/b0raGD5ic5GUWjQ0W2Z7GCsU+MPWcr9BZC7mjKGC ftEVLR+FynfObJBN7YfOZPnwpujkFGn9SE1P7gQQQ1X0MdFWj0LGVmNwg41dFDnwgItr cU2wx5fj2M9zqeSpaawRS6puw6BAN1Mf06wjD9hsXpSpk1AFm7XV7eCGpmF5lzX09Y0C bOXduNCRnPI3DTbYm1Gz84B5BbnvtbJJxek+FVNwYAIeEzSVxE67WOS9tqcX1piLlFO2 yUuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779562289; x=1780167089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f3KwK4OQz2Wqts/nc3+z0lkaqjN2Z4kU8MCbBSAoxhA=; b=RYQFJbeGt3zsGPKtklzzrmPDQ2WvJ+3iBmkEglP9G+8xKTbCUUzKCXd4QTZoJt7wHE 2ZoSpJi/otLB7VvfwucL33RMCMC7jEevfyex+gTQLMpJ/ZoRJdbN5Sn/vfTbxnnNCXuT Tt0MCtEIASDO4PljXRIo90Y+SnJwjh2gUbS+yWh/iwYc1yETtDHbdc+H5AHZ73N/ZmjI py3KI1crIL+xEvyZNhA6Ib279NrKNqx6RwTg31rp3RYd98kY6dHeOSvRd8GcTcYatJb6 PVi4/ERB/UZN8zMwzRefSEOjtNgREen6IMGB1FScA+Ci6oUZTDjzWY6paEgk247n7csD UuTw== X-Forwarded-Encrypted: i=1; AFNElJ+ai4C7ZmkoYQ/UGAdLXWH/gBNI0KrRHN2lXOFKqoTBR4FB7CfRiPFGlOunyua0sDvsR0itKt8//LFLWyQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyCQ9tBEtgsjOcPUlI3ntvAC7fLgXEcdJrv0Fc5UPSGRrnyJegc aVTkTTJQYTw82dQdEywylCYGsSVzyDCIVq2QkwjkArCqJ+cXmv17IArr X-Gm-Gg: Acq92OEfW5Hbp2qyG2vm5G0W+4Z5eedXWTlnB1P+P7Fulqz4KS23xQEX8zH61yAsNQZ zSDli3AJeRV0tXXJtlln9JAzE3u+orrrHgd5VzgavDUfrw11zSzHncQxO5XoBrYfjWQe0f44iyX Sn0DVs1TKoDIIhqJsBu/u01VVbtkMRGXuuUKxrYjTSEQI5xjbPaUr2tYEUeM2aPwltEnywQRIJG QF54tf/iuvUOMvschvcEXtvYj7a+9m2Fq57goTgM2jvOGQ+XlGacdtoaC2ooDC/rCCPr+e7f25X D/dyw8g3fcAyA5LZynPbyGnZtQTSZbPchCFDfbNjL8t0m/l1hZlu788ORQhEPwKhmAlRJJkTI2K 7ePcie17BxAaAAgO/Ov/MLNTlHQOvhQsECbWhGd4d6G101nVkmSHyS8AeV/aXltB6byLOfjIbxC kCJ8RuBJDaUTQwmuj+Akt1cSdFTgab3kUIvLH+LXa1Xo0C6K3vCH8axjhe13ZMePaEr2YCSkCT9 WDusdeafAwwXbEZ6KCnBGntgQGs104sR8UdCv0pk3Ul4L5Xk9g7fV+n0KWUHdRCfIFuya/gcxSY Y3hhitMjuYJhV7QorA61lTdXVTkMzrI= X-Received: by 2002:a05:6000:430b:b0:45e:8526:7dd1 with SMTP id ffacd0b85a97d-45eb39e1f12mr13354310f8f.22.1779562288627; Sat, 23 May 2026 11:51:28 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-a9c7-6b01-94ec-c77c-d65e-8d56.310.pool.telefonica.de. [2a02:3100:a9c7:6b01:94ec:c77c:d65e:8d56]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f6ffsm14058366f8f.1.2026.05.23.11.51.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 23 May 2026 11:51:28 -0700 (PDT) From: Karl Mehltretter To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Karl Mehltretter Subject: [PATCH 1/2] lockdep/selftests: Restore migrate_disable() state on PREEMPT_RT Date: Sat, 23 May 2026 20:51:22 +0200 Message-Id: <20260523185123.17482-2-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260523185123.17482-1-kmehltretter@gmail.com> References: <20260523185123.17482-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The lockdep selftests deliberately run unbalanced locking patterns. dotest() restores the task state they leave behind before running the next testcase. On PREEMPT_RT, spin_lock() uses migrate_disable() instead of disabling preemption. dotest() cleans up the resulting migration-disabled state, but that cleanup is still guarded by CONFIG_SMP. That used to match the scheduler data model, where migration_disabled was also CONFIG_SMP-only. The commit referenced below made SMP scheduler state unconditional, so CONFIG_SMP=3Dn PREEMPT_RT kernels with CONFIG_DEBUG_LOCKING_API_SELFTESTS=3Dy report success from the selftests and then trip over stale current->migration_disabled state: releasing a pinned lock bad: scheduling from the idle thread! Kernel panic - not syncing: Fatal exception Save and restore current->migration_disabled for every PREEMPT_RT build. Fixes: cac5cefbade9 ("sched/smp: Make SMP unconditional") Assisted-by: Codex:gpt-5 Signed-off-by: Karl Mehltretter --- lib/locking-selftest.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index d939403331b5..34554e26d477 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -1431,9 +1431,7 @@ static void dotest(void (*testcase_fn)(void), int exp= ected, int lockclass_mask) { int saved_preempt_count =3D preempt_count(); #ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP int saved_mgd_count =3D current->migration_disabled; -#endif int saved_rcu_count =3D current->rcu_read_lock_nesting; #endif =20 @@ -1471,10 +1469,8 @@ static void dotest(void (*testcase_fn)(void), int ex= pected, int lockclass_mask) preempt_count_set(saved_preempt_count); =20 #ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP while (current->migration_disabled > saved_mgd_count) migrate_enable(); -#endif =20 while (current->rcu_read_lock_nesting > saved_rcu_count) rcu_read_unlock(); --=20 2.39.5 (Apple Git-154) From nobody Sun May 24 18:42:23 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9C837FF5C for ; Sat, 23 May 2026 18:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779562293; cv=none; b=j1Uv7MCLtd/qGYgF4nTztKbbqEuyW1aZVJ71Uq++uHeiQl042zCvzCSVcKcsbA2kwNl/i/8v/KbPKuNnaZWXXkPPvhrROujZXZ47k08QelIGZEE9w0zAqmeYb208ej7c5UYpBFeTy6rolriV4GX32Z7UE2aBr8LoRN8S+tHDijU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779562293; c=relaxed/simple; bh=JEkNE3Lz6tOZdCtt9tbH/hfLjFXUU5qnknFzHKrT17Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lG8U8y1Y92JxULAw802l9yrJ/7LUC6q2TLgRuQrWAP8r5Qqz6qRqEteVIbixlSHkdvUzSbAM9cWMgMzGqMZ+2A0RpMIRgbmIGW+Tk0sETwWms2pTdGBGkwR5W8SUFz5IO95qOQSmHMju4zVFI9vvfxTUbg4CZK6hn4OxliSYvJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ri6mJmpz; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ri6mJmpz" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so15683985e9.0 for ; Sat, 23 May 2026 11:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779562290; x=1780167090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ft4nNrAXI8vhYmPV6zzABvor6jykXPGjask3Bth/uk=; b=Ri6mJmpzqOE8Lw0C1x1h+MAjd9Wzvnw8NN7N8cxJtxsHL75pqjFRIHHH6ywuTyVC0O gsqkoQZE+h/DOSvvmVc3ZYmgggvdnq+neeLrWuGXwY4onAgSGbFl+VNjG0eo6Bb8mUr1 1HlhH9UNn1skvQjo7awlbhAUZcZN3aacHqOprUg4QcsKuyvDTENi5Wq/TRJx1+gkNMRy KjhNwnUTqA0dE2kJR9B4m4F5ZpGyACGpZFgKWe7VJgkDguS/g8KjpglDFlbWBFiCuW/s bjExCrR0VXrpMyj4hRMiQtpBOtYHQi9lSM6EdRGGsWKVOInCppJa8J09W/fZOwHua4fS 36Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779562290; x=1780167090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6ft4nNrAXI8vhYmPV6zzABvor6jykXPGjask3Bth/uk=; b=SCR3OuX37zODdm8dLz90GTO+Jo0CDn1CdnE2MMSK0Fc+0VaqFTGoMFwYUU2qT8Ox9z b4wEP8HrKU6F4Vg5iBCshRH3U3EZsp/prFRqyY/DObcfG0TPD0eMVubDVT3dM5V6S7EZ DWPAcKxoyYnbLYBMtIvH5Kv9uziT+Ix5yexC1/cBu9SRsLS5dHc5/cQIyEd0n+SFt+3F n3lk084m1c/AiqcjAqSlZw7pOz8XDu1bj+ACfNnya+fDXGWzJNebQirywrnieT+Tw77+ jJmwI4wEbVTS/ekjE/gls46o4ZtPtznbwW/HNZJbKlhT63wSeV/3z42AqVcgJgyJ/YlB DsVg== X-Forwarded-Encrypted: i=1; AFNElJ9a8JuUNLA1fvPkyOUbn/1nhnH1lKkFzJJUtD06ByhKySbMPQTQOKI/OJE8M/1P7pMpheXT0xOvMaAfZ4o=@vger.kernel.org X-Gm-Message-State: AOJu0Yxwma+kJhu1s0XGPc3a5ejvfxUkudvT26mPe5fwZC8uwI5dlzs0 RW18DQq3XGLD9ylnL4W6urS8Uwc7UfMhHuT9IA/Y9TrbU2DsDYmJbZqV X-Gm-Gg: Acq92OHOcX8VX2C81cdX8ID5P78erfJ7ilvB4UWSNCe1pcFkTyF+XOwBmXTagjAjf5C 09+alwzK5fVw0vBo8H7jpZUfmxP05ldNBvYNM3gu+vH0vIfH057wFrOSjoHDL9BfcLIPNpON0ND ViiIuI7t2ol1En9amnDKYy9gz1VWjvP+JvVT0mOW5nnuTfQvl5pLkg4byPOsgWUgzun4koX5uV1 5xi1+ThoDgZJp3kkCO0Dcp4NKxCCWfhyIzXy4fdWOfckKNZi6xeVk3YqTsIzMclU2V5bsblbY72 5r7omJfKkIL1oLHB4+lNc3V5ydIWzavNoUrC8N5CH9hdUSpvnXpPckcsBE4YB+8a11+XJ+/7W7d hGFl2y7DYMPEFRF5rT4d77KiXFgQ6Ed7ogzDyJR7x7rhbK8ErtIBrEyHna6F2MfQiouONHxy/mh TmWYWtNyJ8V1QwXxOOaZfpNgobUIg+56pVkrXgxtWVZWLbEkqf4VWDzQ+aGdTHsFKNfo0+yaJwO jwt9gqYy2oaL/GrfFe4PDSHAZJJrNG6IceWLpM4BNms87aqzxBnnK1l2N2C1qiRO5VpztCyaImB A6EVoJ5tPZhYi1KrsfKaeyD7hQ60Z04asB+R1S4wbw== X-Received: by 2002:a05:600c:4510:b0:490:3d2e:b67d with SMTP id 5b1f17b1804b1-490428eb9aamr126341515e9.30.1779562289734; Sat, 23 May 2026 11:51:29 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-a9c7-6b01-94ec-c77c-d65e-8d56.310.pool.telefonica.de. [2a02:3100:a9c7:6b01:94ec:c77c:d65e:8d56]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6c9f6ffsm14058366f8f.1.2026.05.23.11.51.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 23 May 2026 11:51:29 -0700 (PDT) From: Karl Mehltretter To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Karl Mehltretter Subject: [PATCH 2/2] lockdep/selftests: Restore sched_rt_mutex state on PREEMPT_RT Date: Sat, 23 May 2026 20:51:23 +0200 Message-Id: <20260523185123.17482-3-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260523185123.17482-1-kmehltretter@gmail.com> References: <20260523185123.17482-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The WW-mutex selftests deliberately exercise failing lock paths. On PREEMPT_RT, some of those paths enter the RT-mutex scheduler helpers. The change referenced by the Fixes tag made those helpers track RT-mutex scheduling state in current->sched_rt_mutex. The bit is normally cleared by the matching post-schedule helper, but some WW-mutex selftests disable the runtime debug_locks flag before that happens. With debug_locks cleared, lockdep_assert() does not evaluate the expression that clears the bit, leaving stale state for the next testcase. With CONFIG_PREEMPT_RT=3Dy and CONFIG_DEBUG_LOCKING_API_SELFTESTS=3Dy, that stale state produces warnings such as: WARNING: kernel/sched/core.c:7557 at rt_mutex_pre_schedule+0x26/0x2d RIP: 0010:rt_mutex_pre_schedule+0x26/0x2d Save and restore current->sched_rt_mutex around each testcase, matching the existing PREEMPT_RT cleanup for task-local migration and RCU state. Fixes: d14f9e930b90 ("locking/rtmutex: Use rt_mutex specific scheduler help= ers") Assisted-by: Codex:gpt-5 Signed-off-by: Karl Mehltretter --- lib/locking-selftest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 34554e26d477..e7c3ccb23b58 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -1433,6 +1433,7 @@ static void dotest(void (*testcase_fn)(void), int exp= ected, int lockclass_mask) #ifdef CONFIG_PREEMPT_RT int saved_mgd_count =3D current->migration_disabled; int saved_rcu_count =3D current->rcu_read_lock_nesting; + int saved_sched_rt_mutex =3D current->sched_rt_mutex; #endif =20 WARN_ON(irqs_disabled()); @@ -1469,6 +1470,8 @@ static void dotest(void (*testcase_fn)(void), int exp= ected, int lockclass_mask) preempt_count_set(saved_preempt_count); =20 #ifdef CONFIG_PREEMPT_RT + current->sched_rt_mutex =3D saved_sched_rt_mutex; + while (current->migration_disabled > saved_mgd_count) migrate_enable(); =20 --=20 2.39.5 (Apple Git-154)