From nobody Mon Feb 9 18:45:02 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1568039573; cv=none; d=zoho.com; s=zohoarc; b=EDHdQfFKZhozxrsPW8k8e7LqiREiwbWvB4paj2CQiUZ1YxC3Vi7LWFgTc59wBJQyjs9I7S95U3QSG61rUBXD+439T+LvXz0ReXgmjaH9UIlmDhxlLQG9Aqmvz1+el4GVzbByiRKN5w9YSonb7cpsOxyZR6XlCEsu5XaZCvErT4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568039573; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=p+jDm1jLxZeUWgVcHp0Qkfa4L3lz8eWtfyRbN4zlAuU=; b=hvn5K9sg7cgjnKtW6Asu1lh3svDx0UOFOhhOdnRjcdTWml837NnlhGDQzh0GrYjTlTGJbP+YpZtjoL9+6t+Qt/+TWux44VB5FzMqTU0SRL60MZjxPS8GeMQvu00r/gNfZxRAuLtiNb8n7S9sR7zdLAq07s/sPJq1+0QgV4U13U4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568039573134404.8422368910291; Mon, 9 Sep 2019 07:32:53 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7Khr-0001Tx-Rr; Mon, 09 Sep 2019 14:31:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7Khp-0001SS-Ro for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 14:31:49 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 88c2a4ca-d30e-11e9-b299-bc764e2007e4; Mon, 09 Sep 2019 14:31:41 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0A9B1B671; Mon, 9 Sep 2019 14:31:38 +0000 (UTC) X-Inumbo-ID: 88c2a4ca-d30e-11e9-b299-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 16:31:34 +0200 Message-Id: <20190909143134.15379-6-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909143134.15379-1-jgross@suse.com> References: <20190909143134.15379-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v4 5/5] xen: add function name to lock profiling data 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A spinlock defined via DEFINE_SPINLOCK() as a static variable local to a function shows up in lock profiling just with its local variable name. This results in multiple locks just named "lock". In order to be able to distinguish those locks in the lock profiling output add the function name to struct lock_profile and initialize it with __PRETTY_FUNCTION__ (__func__ or __FUNCTION__ are not usable outside of functions with some compilers). Signed-off-by: Juergen Gross --- xen/common/spinlock.c | 16 +++++++++++++--- xen/include/xen/spinlock.h | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c index f40a6b5cb2..cb1c65c5e2 100644 --- a/xen/common/spinlock.c +++ b/xen/common/spinlock.c @@ -345,6 +345,7 @@ static s_time_t lock_profile_start; static struct lock_profile_anc *lock_profile_ancs; static struct lock_profile_qhead lock_profile_glb_q; static spinlock_t lock_profile_lock =3D SPIN_LOCK_UNLOCKED; +static const char *lock_profile_nofunc =3D __PRETTY_FUNCTION__; =20 static void spinlock_profile_iterate(lock_profile_subfunc *sub, void *par) { @@ -368,8 +369,10 @@ static void spinlock_profile_print_elem(struct lock_pr= ofile *data, printk("%s ", type); if ( idx !=3D LOCKPROF_IDX_NONE ) printk("%d ", idx); - printk("%s: addr=3D%p, lockval=3D%08x, ", data->name, lock, - lock->tickets.head_tail); + printk("%s", data->name); + if ( data->func && strcmp(data->func, lock_profile_nofunc) ) + printk("@%s", data->func); + printk(": addr=3D%p, lockval=3D%08x, ", lock, lock->tickets.head_tail); if ( lock->debug.cpu =3D=3D SPINLOCK_NO_CPU ) printk("not locked\n"); else @@ -424,7 +427,14 @@ static void spinlock_profile_ucopy_elem(struct lock_pr= ofile *data, =20 if ( p->pc->nr_elem < p->pc->max_elem ) { - safe_strcpy(elem.name, data->name); + if ( data->func && strcmp(data->func, lock_profile_nofunc) ) + { + snprintf(elem.name, sizeof(elem.name), "%s@%s", data->name, + data->func); + elem.name[sizeof(elem.name) - 1] =3D 0; + } + else + safe_strcpy(elem.name, data->name); safe_strcpy(elem.type, type); elem.idx =3D idx; elem.lock_cnt =3D data->lock_cnt; diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h index eafa522d79..9cbd222b0d 100644 --- a/xen/include/xen/spinlock.h +++ b/xen/include/xen/spinlock.h @@ -77,6 +77,7 @@ struct spinlock; struct lock_profile { struct lock_profile *next; /* forward link */ char *name; /* lock name */ + const char *func; /* function name */ struct spinlock *lock; /* the lock itself */ u64 lock_cnt; /* # of complete locking ops */ u64 block_cnt; /* # of complete wait for lock */ @@ -91,7 +92,8 @@ struct lock_profile_qhead { int32_t idx; /* index for printout */ }; =20 -#define _LOCK_PROFILE(name) { 0, #name, &name, 0, 0, 0, 0, 0 } +#define _LOCK_PROFILE(name) { 0, #name, __PRETTY_FUNCTION__, &name, = \ + 0, 0, 0, 0, 0 } #define _LOCK_PROFILE_PTR(name) = \ static struct lock_profile * const __lock_profile_##name = \ __used_section(".lockprofile.data") =3D = \ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel