Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp962881rdb; Tue, 19 Sep 2023 16:10:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtcoGRyZRa/J8cTtt/jKqQlD1KnQ5/wKfK4RD/oS7mhTFeJiotD1hANbasx+lUSm7w/LOG X-Received: by 2002:a05:6a00:1895:b0:68e:2d2d:56c1 with SMTP id x21-20020a056a00189500b0068e2d2d56c1mr1220445pfh.9.1695165038480; Tue, 19 Sep 2023 16:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695165038; cv=none; d=google.com; s=arc-20160816; b=KkOSboH1GIAf/1ZBWZWJcXmXOqjS9wgXAqbMHk7MAsAa4O/UnGwoarek7csZpjP5TL KT7EplrqS6wsachcNH+J3khCcBtoSvJSK5niQgMlmD8Lp8wc9z8uaZmZ9YCmmhJO9sYQ u4hvktRulIk6ddhqGwSQWQVq6HaUe/vXTp3GHE7eHyp4JoWclHRG+3LDzlq+OiSs+krn qhAN6hp2ZHULxl+NvMVG2tzs9vJ9CwDo4rrfPPtSA1MsCcjB25W2kbfwqL6Dx6YqDsMQ Gpnj3x0Ag1i+mPRoXjBqU3MgWkhSkKBgmpVWtC327x/8yaRDq81t+LVa1oZ4VEAQd62M kwlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=oTbjh+BCwK3ch0C9I9rGb2UB8TXtu3KoCP4n1cVIXrU=; fh=baLZk4VyAx6eqLoRrdDbCsrkF3EpnrHuPZYH860mNkA=; b=xFJgbrqD8F+n5n18uXNqtZ677LBeFe3yb0DWC8I+fA158PPThToWfzRuJ6xl6APer7 FG4ZWFMBer0phiDdr6U6eOA78DxKdPJaONAUWeeFBiqvLqix5wiWNnmhmyHq26k7p0Ve e8YD6TwD37Nw1Czz71ibdvHDcPoTg1C0dPN9T5LAXMSjymw0y3mSagZo5CgeJAPvB9qf SxWxfmLJY+Is4aEYqfg3nWuzXyWRIACYRUByT4IpMZPFLTA41/AS9Ozr3U/3nf5hBds4 RrBLeVPR1P6zpXewy8fgpmk0VHAdQo7KsBVX19AeCLJvinYnjojVabdbYRgsonPsZFVi 0w3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CWBMhviI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CPLhIrrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id cn7-20020a056a00340700b0068fac3509a9si10293943pfb.350.2023.09.19.16.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 16:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CWBMhviI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CPLhIrrf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7B09882AE904; Tue, 19 Sep 2023 16:10:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233742AbjISXKR (ORCPT + 99 others); Tue, 19 Sep 2023 19:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbjISXJ3 (ORCPT ); Tue, 19 Sep 2023 19:09:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56F93123 for ; Tue, 19 Sep 2023 16:09:21 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695164958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oTbjh+BCwK3ch0C9I9rGb2UB8TXtu3KoCP4n1cVIXrU=; b=CWBMhviIBeB0aywq9Iy69hMDQxMEDISIoCiLV53lxHkko2TxoIvVObviV3JzALZYuskOuF vLup+KdFFXXpr7hN459KkJ29SwtjuHMyrA3BSs7Ujrhd+abfz1H8ytLUEW+eJeFy6awq36 2ENhovyBKC3vJZR4jV+OPnArx2KmR4sNhdzPBp/bzSrqb6EUEFX7E1fy6JAcJJv1yzxeLc A+iqlTdzrdh2m2RlOUFHJJgR68AsOVJpbN1YFDrFAjrkmHPhF2YQSdDMPxIPBZuTUOpH5X DjXVN0Jjlht76MiEJGEcYGxW/h7BnLOThqX2RssAMAXnyydqbgMJK2dhSHOkCA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695164958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oTbjh+BCwK3ch0C9I9rGb2UB8TXtu3KoCP4n1cVIXrU=; b=CPLhIrrfnQOJB1t7QDK40++wEqAcYJmu2Ob8akLI6kcwcYqg0zr74n591slHOpJUudXLZ0 tBo8+S8PCFkJpEAA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: [PATCH printk v2 11/11] lockdep: Add atomic write enforcement for lockdep splats Date: Wed, 20 Sep 2023 01:14:56 +0206 Message-Id: <20230919230856.661435-12-john.ogness@linutronix.de> In-Reply-To: <20230919230856.661435-1-john.ogness@linutronix.de> References: <20230919230856.661435-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 16:10:32 -0700 (PDT) Invoke the atomic write enforcement functions for lockdep splats to ensure that the information gets out to the consoles. It is important to note that if there are any legacy consoles registered, they will be attempting to directly print from the printk-caller context, which may jeopardize the reliability of the atomic consoles. Optimally there should be no legacy consoles registered. Signed-off-by: John Ogness --- kernel/locking/lockdep.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index e85b5ad3e206..5310a94e3efd 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -3967,9 +3968,13 @@ static void print_usage_bug(struct task_struct *curr, struct held_lock *this, enum lock_usage_bit prev_bit, enum lock_usage_bit new_bit) { + enum nbcon_prio prev_prio; + if (!debug_locks_off() || debug_locks_silent) return; + prev_prio = nbcon_atomic_enter(NBCON_PRIO_EMERGENCY); + pr_warn("\n"); pr_warn("================================\n"); pr_warn("WARNING: inconsistent lock state\n"); @@ -3998,6 +4003,8 @@ print_usage_bug(struct task_struct *curr, struct held_lock *this, pr_warn("\nstack backtrace:\n"); dump_stack(); + + nbcon_atomic_exit(NBCON_PRIO_EMERGENCY, prev_prio); } /* -- 2.39.2