From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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=n PREEMPT_RT kernels with CONFIG_DEBUG_LOCKING_API_SELFTESTS=y 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 expected, int lockclass_mask) { int saved_preempt_count = preempt_count(); #ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP int saved_mgd_count = current->migration_disabled; -#endif int saved_rcu_count = current->rcu_read_lock_nesting; #endif @@ -1471,10 +1469,8 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) preempt_count_set(saved_preempt_count); #ifdef CONFIG_PREEMPT_RT -#ifdef CONFIG_SMP while (current->migration_disabled > saved_mgd_count) migrate_enable(); -#endif while (current->rcu_read_lock_nesting > saved_rcu_count) rcu_read_unlock(); -- 2.39.5 (Apple Git-154)