From patchwork Wed Aug 7 14:31:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11082283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBC6614DB for ; Wed, 7 Aug 2019 14:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBCD1287D3 for ; Wed, 7 Aug 2019 14:32:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C025C28A92; Wed, 7 Aug 2019 14:32:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DBB728A63 for ; Wed, 7 Aug 2019 14:32:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvMyM-0000yl-NO; Wed, 07 Aug 2019 14:31:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvMyK-0000y3-TR for xen-devel@lists.xenproject.org; Wed, 07 Aug 2019 14:31:24 +0000 X-Inumbo-ID: 07cd737a-b920-11e9-912d-ef6d3c680eca Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 07cd737a-b920-11e9-912d-ef6d3c680eca; Wed, 07 Aug 2019 14:31:23 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E8971B035; Wed, 7 Aug 2019 14:31:22 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 7 Aug 2019 16:31:18 +0200 Message-Id: <20190807143119.8360-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190807143119.8360-1-jgross@suse.com> References: <20190807143119.8360-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 3/4] xen: print lock profile info in panic() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Print the lock profile data when the system crashes and add some more information for each lock data (lock address, cpu holding the lock). This is especially beneficial for watchdog triggered crashes in case of deadlocks. In order to have the cpu holding the lock available let the LOCK_PROFILE config option select SPINLOCK_DEBUG. As printing the lock profile data will make use of locking, too, we need to disable spinlock debugging before calling spinlock_profile_printall() from panic(). While at it remove a superfluous #ifdef CONFIG_LOCK_PROFILE. Signed-off-by: Juergen Gross --- xen/Kconfig.debug | 1 + xen/common/spinlock.c | 11 +++++++---- xen/drivers/char/console.c | 4 +++- xen/include/xen/spinlock.h | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 5db3e7ec25..a7387f1630 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -53,6 +53,7 @@ config SPINLOCK_DEBUG config LOCK_PROFILE bool "Lock Profiling" + select SPINLOCK_DEBUG ---help--- Lock profiling allows you to see how often locks are taken and blocked. You can use serial console to print (and reset) using 'l' and 'L' diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index 16356ec9b7..5730076581 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -362,10 +362,13 @@ static void spinlock_profile_iterate(lock_profile_subfunc *sub, void *par) static void spinlock_profile_print_elem(struct lock_profile *data, int32_t type, int32_t idx, void *par) { - if ( type == LOCKPROF_TYPE_GLOBAL ) - printk("%s %s:\n", lock_profile_ancs[type].name, data->name); - else - printk("%s %d %s:\n", lock_profile_ancs[type].name, idx, data->name); + struct spinlock *lock = data->lock; + + printk("%s ", lock_profile_ancs[type].name); + if ( type != LOCKPROF_TYPE_GLOBAL ) + printk("%d ", idx); + printk("%s: addr=%p, lockval=%04x, cpu=%d\n", data->name, lock, + lock->tickets.head_tail, lock->debug.cpu); printk(" lock:%12"PRId64"(%08X:%08X), block:%12"PRId64"(%08X:%08X)\n", data->lock_cnt, (u32)(data->time_hold >> 32), (u32)data->time_hold, data->block_cnt, (u32)(data->time_block >> 32), diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 1680d078db..404d28a725 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1167,7 +1167,9 @@ void panic(const char *fmt, ...) unsigned long flags; static DEFINE_SPINLOCK(lock); static char buf[128]; - + + spin_debug_disable(); + spinlock_profile_printall('\0'); debugtrace_dump(); /* Protects buf[] and ensure multi-line message prints atomically. */ diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h index e3458f10dd..26891445fe 100644 --- a/xen/include/xen/spinlock.h +++ b/xen/include/xen/spinlock.h @@ -130,6 +130,7 @@ struct lock_profile_qhead { }; #define spin_lock_init_prof(s, l) spin_lock_init(&((s)->l)) #define lock_profile_register_struct(type, ptr, idx, print) #define lock_profile_deregister_struct(type, ptr) +#define spinlock_profile_printall(key) #endif