From nobody Wed Apr 29 08:09:57 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E1AC433EF for ; Mon, 13 Jun 2022 08:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240091AbiFMIg0 (ORCPT ); Mon, 13 Jun 2022 04:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239397AbiFMIgW (ORCPT ); Mon, 13 Jun 2022 04:36:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13A814D2E; Mon, 13 Jun 2022 01:36:15 -0700 (PDT) Date: Mon, 13 Jun 2022 08:36:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1655109374; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bzlzsjP48UtF0PJNcbhxAVOSOvbMnhjXg0V4T2/iJnY=; b=hshIlQXBMsgh6o7LyUzvoGdHiBJg6pjb1R8ukGA2DSKtaSUNZoilLFLDB+uxuB2WBC6EZL O2HVFfeUToPl8Yv7njTpvxsLZVX2pbA7hcvzsT4LrxM6+uY7nWzJmd5aC8zhHFjREuNbNE ftz6waA0HUZzH+lEGmBzL1fe++xMk+QaF8L8a5Q8GYKgsE/QTeN5QOgM6vxxQQuZZeNQoJ nHPEusBmsfafcYeoiUSwoaaCD/jAlRInQkytjBc0tWbj5pxfhWz41PAI/BjmpGlbfuBxyR v3egmrNty9aNlxR902DGv32/TAdWUXgRupPDjEYFPxC5W8fUgjRJuCYD1u9wVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1655109374; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bzlzsjP48UtF0PJNcbhxAVOSOvbMnhjXg0V4T2/iJnY=; b=Uy58VG7f+ASbnjEBvp3yH9W79QORrFNtCw2VGyuMXrA76yUkbp19CzAfbiwiy4fqs1Y3O3 jr1eLlJygPvZquCQ== From: "tip-bot2 for Sebastian Andrzej Siewior" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] locking/lockdep: Use sched_clock() for random numbers Cc: Sebastian Andrzej Siewior , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <165510937305.4207.6864911562240875202.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 4051a81774d6d8e28192742c26999d6f29bc0e68 Gitweb: https://git.kernel.org/tip/4051a81774d6d8e28192742c26999d6f2= 9bc0e68 Author: Sebastian Andrzej Siewior AuthorDate: Tue, 17 May 2022 11:16:14 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 13 Jun 2022 10:29:57 +02:00 locking/lockdep: Use sched_clock() for random numbers Since the rewrote of prandom_u32(), in the commit mentioned below, the function uses sleeping locks which extracing random numbers and filling the batch. This breaks lockdep on PREEMPT_RT because lock_pin_lock() disables interrupts while calling __lock_pin_lock(). This can't be moved earlier because the main user of the function (rq_pin_lock()) invokes that function after disabling interrupts in order to acquire the lock. The cookie does not require random numbers as its goal is to provide a random value in order to notice unexpected "unlock + lock" sites. Use sched_clock() to provide random numbers. Fixes: a0103f4d86f88 ("random32: use real rng for non-deterministic randomn= ess") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/YoNn3pTkm5+QzE5k@linutronix.de --- kernel/locking/lockdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 81e8728..f06b91c 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -5432,7 +5432,7 @@ static struct pin_cookie __lock_pin_lock(struct lockd= ep_map *lock) * be guessable and still allows some pin nesting in * our u32 pin_count. */ - cookie.val =3D 1 + (prandom_u32() >> 16); + cookie.val =3D 1 + (sched_clock() & 0xffff); hlock->pin_count +=3D cookie.val; return cookie; }