Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1450927rwb; Fri, 19 Aug 2022 04:05:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Tyd7LqNXypT/Vcq6gWuI62/q5JSzqB/D1a7ZwSxPKIx5eIW4luOVW89ZGSM/0DM4+pvv3 X-Received: by 2002:a05:6402:530f:b0:43e:43d7:91ca with SMTP id eo15-20020a056402530f00b0043e43d791camr5780682edb.176.1660907121369; Fri, 19 Aug 2022 04:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660907121; cv=none; d=google.com; s=arc-20160816; b=P6mq8QJWMjyIfjLNR1XOaVp4HsfwxL9CMrasMLud6+5Ij8uY34yBUFoM2Ykhq0tYPt aRKecLeP0HlmcREhez6wDPY30cRPAjy1im922eE1OLXU0N3e04VDkPifGjeTEs0CTbSd Pogar9eDw4FccG4pQg7b35njwKeQA8E/iIWqX2gSQWohDIF5OcLMRAfWPGykoiIfGeup kXfTLykQl+2TkKf2K2Oy5fo2PfDwrN7mSy2NobusHXOC+aA2Eu5p/cVFUmonkUuGonSb u71LIxgiy6P5NUFz38oUicG7Hs6TrIBkXrbAygleAfFZsVPTA/Aw9LGSSazk/VID6PN9 wLkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LkOuWPriJ2vDP4Uo54AyQYARYOh594lLtG0oD4A5Duw=; b=qNfjb2mV7LKPtqmoy3gk9urZy0zbRalpZEPy+TAsb/xhMLNTLw0to6d0AX9uN6U9pd 9PS71sCiyhXHLFSDXcd0GXzb1UpUMZzOiyGV2QoKIcS2pVCzTNylsJvcsPFWR0R3k/b7 HoTwIRGBCArkRk1RQKWkaFbYSQHGuZONsDYfhV2JJoTY/st7qkGaM0wNWQ42/Mq1tKtv gUxWRE2jDoZ1Th88kIApAn254iW0CtkreZETzbM4UWOsFMZ0PS360oVIM5wnGX8MaUQB U+FfPPnfRiNp37KJu+QzrJP7vUrq949ufhaQxBK4CzjvyBEOOzlAWdzErsP/M6k3tAvy PYzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=OF3a15TR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a056402171200b0043d7a3c3cddsi2599496edu.408.2022.08.19.04.04.55; Fri, 19 Aug 2022 04:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=OF3a15TR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348454AbiHSLAE (ORCPT + 99 others); Fri, 19 Aug 2022 07:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348011AbiHSLAB (ORCPT ); Fri, 19 Aug 2022 07:00:01 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 859DCF4395 for ; Fri, 19 Aug 2022 03:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1660906799; x=1692442799; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=LkOuWPriJ2vDP4Uo54AyQYARYOh594lLtG0oD4A5Duw=; b=OF3a15TR2iN+StUcfGYG4V4MMODltytvfacG7E3Lcol43DvJ6DkuTqRO Y1PNSdiGtrZ+hfB7nqCYo3fUq8imhFEF3o8N5AM3+1rymLoT7L3QtnhRl 1x6/5MN3gzBXBDkeLeGWJ9bLG4eBaRIgLI1Tt4Kt4NB4PBOL2fqSQNH18 rmsLTqchp6cNulJ81GMhhSroLynV+VeGjYbcodAEOEMV6e22AEAviZ1HL odwjd0zlUXPHs6edU9x7rrfhGF9gEur1BsEMGCsA3nAIxcvz8iVotpvFh 0upCi3BPtXB2T2FtFvFnvvYIVUF2V4aynFPhYB12ZbVnWddaebFwsga4Q A==; Date: Fri, 19 Aug 2022 12:59:56 +0200 From: Vincent Whitchurch To: Boqun Feng CC: Peter Zijlstra , Ingo Molnar , Will Deacon , kernel , Waiman Long , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] lockdep: Panic on warning if panic_on_warn is set Message-ID: References: <20220818114259.2203505-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 18, 2022 at 11:49:17PM +0200, Boqun Feng wrote: > On Thu, Aug 18, 2022 at 01:42:58PM +0200, Vincent Whitchurch wrote: > > There does not seem to be any way to get the system to panic if a > > lockdep warning is emitted, since those warnings don't use the normal > > WARN() infrastructure. Panicking on any lockdep warning can be > > desirable when the kernel is being run in a controlled environment > > solely for the purpose of testing. Make lockdep respect panic_on_warn > > to allow this, similar to KASAN and others. > > > > I'm not completely against this, but could you explain why you want to > panic on lockdep warning? I assume you want to have a kdump so that you > can understand the lock bugs closely? But lockdep discovers lock issue > possiblity, so it's not an after-the-fact detector. In other words, when > lockdep warns, the deadlock cases don't happen in the meanwhile. And > also lockdep tries very hard to print useful information to locate the > issues. I'm not trying to obtain a kdump in this case. I test device drivers under UML[0] and I want to make the tests stop and fail immediately if the driver triggers any kind of problem which results in splats in the log. I achieve this using panic_on_warn, panic_on_taint, and oops=panic which result in a panic and an error exit code from UML. [0] https://lore.kernel.org/lkml/20220311162445.346685-1-vincent.whitchurch@axis.com/ For lockdep, without this patch, I would be forced to parse the logs after each test to determine if the test trigger a lockdep splat or not. > This patch add lockdep_panic() to a few places, and it's a pain for > maintaining. So why do you want to panic on lockdep warning? It's adding the call to a lot of places since there is no existing common function indicating the end of a lockdep warning. I can move the already duplicated dump_stack() calls into the new function too so that some code is removed. The "stack backtrace" could possible be consolidated too, but one of the call sites uses printk instead of pr_warn so I wasn't sure if it was OK to change that to a warn too.