Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2291775rwn; Fri, 16 Sep 2022 08:13:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72Lwf35FoJILd861X/hJRr/actuIn8SOyZj6IbBMDmJ089kuHQic6nGzdklrOq+107nguQ X-Received: by 2002:a05:6402:1446:b0:44e:ec98:3e11 with SMTP id d6-20020a056402144600b0044eec983e11mr4456828edx.90.1663341187881; Fri, 16 Sep 2022 08:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663341187; cv=none; d=google.com; s=arc-20160816; b=fwUObMmbwijbP1wh+v8aau3SIGXGgfMhfx9Ij06aT+EXjK3G00sfz+XyMCsvF+SMV3 EJDHx83LeUfBK19+yrowhJyL1WZHhZ1GLdBqPSaDVEzbQr54KUGYmQExt8BK0mTN0tWp QP2adIFAwdInXHk6+ZGJttFFgzkEua4mTnDXXfkMIzw2g77Yn/Ml0mLazPXOqpukHjO/ 86/WjI/te87kgZKWvK1gx1tGAg7v2QaHJV9TFmRzlgH5Mn39DbELdfZFgEIqgE2gyLtU TKC9aQsgI5TPhy24M7TR4Rpp+mPFx9AtLNM08T9SeMCRI1797MSWOiqWX672tULUZd1d AOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FGfkTbjbj4y5weWbQls4Bj+fqmdi3Ct4eOPhYuCk3vQ=; b=uj8HT05LMNNJSCdy8YxxcHLp60Zz4UHJdEDpODyTb+NgOR/afYxK6pwvJhLxg+b+Yq V/hu8P8e9K7swvDPNi3F+1g28CEdhdkEnaooCK0GRWmEUVqr7aNxEbs0DeyCOsSl4c4w tBEo10kpmyZwY6j+svXXhAKC3QnAg6+qaymmdhnfAvh+vdHCzVgpS1n0y3WYpu6ZYbXC Wo6Simvb+S/rFws9dD80yf1KQ1azHCaovLOuqTOdcmOm9h2QKsuQeSVzF0/akPwTMqwJ 0So8Nv05L9MsMlNXkqnksRWMIOSpa1k3GgeGIfbD1Lo+NwgEYFMxNf390X+LtSP6Q5es DGYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AbI1xZMO; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a05640217cb00b0043d1d2bda9bsi2204718edy.92.2022.09.16.08.12.41; Fri, 16 Sep 2022 08:13:07 -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 header.i=@redhat.com header.s=mimecast20190719 header.b=AbI1xZMO; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbiIPOvc (ORCPT + 99 others); Fri, 16 Sep 2022 10:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbiIPOvX (ORCPT ); Fri, 16 Sep 2022 10:51:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B309ABF2A for ; Fri, 16 Sep 2022 07:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663339881; h=from:from: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=FGfkTbjbj4y5weWbQls4Bj+fqmdi3Ct4eOPhYuCk3vQ=; b=AbI1xZMOZq9pwygrBSBpCHxskxQd+gPrEOKvzanQsEiXhQ/tw8A3G6dE01LZMenqPv27Hs bnTWJHm3YlTPnVM7aez8x+UHveazy2+LylHB6ZAx5g3JLUkg69uMFPPygTuIKEHpBMVw/j PvosH1aYFDcXb347bp0Ivg0oPX2oZK0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-U-7YQjNvOnej_pdIg_YMNQ-1; Fri, 16 Sep 2022 10:51:18 -0400 X-MC-Unique: U-7YQjNvOnej_pdIg_YMNQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C442D1C0759E; Fri, 16 Sep 2022 14:51:16 +0000 (UTC) Received: from [10.22.17.61] (unknown [10.22.17.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id E166F580458; Fri, 16 Sep 2022 14:51:14 +0000 (UTC) Message-ID: <3e027453-fda4-3891-3ec3-5623f1525e56@redhat.com> Date: Fri, 16 Sep 2022 10:51:14 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH (repost)] locking/lockdep: add debug_show_all_lock_holders() Content-Language: en-US To: Tetsuo Handa , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng Cc: Thomas Gleixner , Shaokun Zhang , Sebastian Andrzej Siewior , Petr Mladek , Andrew Morton , Ben Dooks , Rasmus Villemoes , Luis Chamberlain , Xiaoming Ni , John Ogness , LKML References: From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE 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 9/16/22 10:15, Tetsuo Handa wrote: > Currently, check_hung_uninterruptible_tasks() reports details of locks > held in the system. Also, lockdep_print_held_locks() does not report > details of locks held by a thread if that thread is in TASK_RUNNING state. > Several years of experience of debugging without vmcore tells me that > these limitations have been a barrier for understanding what went wrong > in syzbot's "INFO: task hung in" reports. > > I initially thought that the cause of "INFO: task hung in" reports is > due to over-stressing. But I understood that over-stressing is unlikely. > I now consider that there likely is a deadlock/livelock bug where lockdep > cannot report as a deadlock when "INFO: task hung in" is reported. > > A typical case is that thread-1 is waiting for something to happen (e.g. > wait_event_*()) with a lock held. When thread-2 tries to hold that lock > using e.g. mutex_lock(), check_hung_uninterruptible_tasks() reports that > thread-2 is hung and thread-1 is holding a lock which thread-2 is trying > to hold. But currently check_hung_uninterruptible_tasks() cannot report > the exact location of thread-1 which gives us an important hint for > understanding why thread-1 is holding that lock for so long period. > > When check_hung_uninterruptible_tasks() reports a thread waiting for a > lock, it is important to report backtrace of threads which already held > that lock. Therefore, allow check_hung_uninterruptible_tasks() to report > the exact location of threads which is holding any lock. I am not against this patch, but I do like to see you wrapping your code in a __debug_show_all_locks() wrapper, for instance, with flags and make debug_show_all_locks() uses the new wrapper to avoid code redundancy. > Signed-off-by: Tetsuo Handa > --- > This is repost of https://lkml.kernel.org/r/82af40cc-bf85-2b53-b8f9-dfc12e66a781@I-love.SAKURA.ne.jp . > I think there was no critical objection which blocks this change. > > I wish that lockdep continues tracking locks (i.e. debug_locks remains 1) > even after something went wrong, for recently I sometimes encounter problems > that disable lockdep during boot stage. > > It would be noisy to report possibility of e.g. circular locking dependency > every time due to keeping debug_locks enabled. But tracking locks even after > something went wrong will help debug_show_all_lock_holders() to survive > problems during boot stage. > > I'm not expecting lockdep to report the same problem forever. > Reporting possibility of each problem pattern (e.g. circular locking dependency) > up to once, by using cmpxchg() inside reporting functions that call printk(), > would be enough. > > I'm expecting lockdep to continue working without calling printk() even after > one of problem patterns (e.g. circular locking dependency) was printk()ed, so that > debug_show_all_locks()/debug_show_all_lock_holders() can call printk() when needed. > > Changing debug_locks behavior is a future patch. For now, this patch alone > will help debugging Greg's usb.git#usb-testing tree which is generating > many "INFO: task hung in" reports. Boqun is actually working on a modularization patch to make some lockdep checking still active even after a lockdep bug is reported. I think he will take into consideration about this request. Cheers, Longman