Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp525426lqh; Thu, 28 Mar 2024 08:37:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbdQeYmrDwg7O1DSAeJ6EiM44+VTciXri1v5+Lu3VDSs3toUEWJl34B2bijklH/9DrpFGRBHZQMkDjhlatZwdaAFdJy5TSUXRqiMQXKA== X-Google-Smtp-Source: AGHT+IGupZ7K5Oz54oDjPvKSzdJj+SUlY43SiCdIeZuYccMaLiMFPNnPtc2j4B0jdDamPqTxggKw X-Received: by 2002:a05:6a00:218d:b0:6e7:29dd:84db with SMTP id h13-20020a056a00218d00b006e729dd84dbmr4088970pfi.31.1711640265600; Thu, 28 Mar 2024 08:37:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711640265; cv=pass; d=google.com; s=arc-20160816; b=C9XkaCr+UIfXUqjnU7h45AznV/Rc/Nq2EQ9fBZQhfDW4kJA7DxSgDHO6opRsOc77GS NCUcXb7N62VA0gmsRXwxwRNaBR6fuFro5yFY/Cbt3Ue1GYBJbWubx+WO7wZQWPqS9aCx gZm4IoWD/PR81awSBbnFkJ28GuNfkhvWsiQxLUCb48kgWFg6rzr6aCNgd1S4A4DtAyOt PZ5zCakMQQ1sS5rFG26hlYE/1Hhnn0ycY3oyyHrvA3PSdxZWIjnuFS5mFNhrFTgYmHHK qR/0PuPcUmegjiAZ1Ve7uV5FI8boBypoYRuhEM1KUP8ZtxBLWB/h1Go4uuTJTp+pVbPI 9gLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=cbqvq+BA/vaA9/GEYHd73qogtaZufT5humKqhlfkAys=; fh=j+oeCbCo2UIsAdR11m1tPFlyOzyxMLteYy2QULeUNFs=; b=L50qHbO4r0WVom0K9cXWHXwJ43UvMf8grVyvZa279KFsrZqunii7jhDLKGdowjlTa6 CB79g0DqKFqflnSyuphl1ruXpvdfgqKQy6YfvKKkNkHRk9vr+Tpq4GTfCzfh8O1URV7w bmj4vqSxBW7aRDH67zsH2fLB6bPowYMJRNJAN0axjo6nrL852Q0HOTIqfXOLVWkpeX8Z xbpiJBugyLh/OYb/u4thvdV3A4N6X/OO7B1+CGs8wRViVl6ZpH32G3+bUor4QxmHTQD6 5ITtp4bWTlHcKzxWInJcsgInoyHO2PCqKiKimtUKidn7f5LQyTa0qMMjQ3VrbTT6KSm5 Cehg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-123158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123158-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m9-20020a62f209000000b006eabbaccba6si1671415pfh.164.2024.03.28.08.37.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 08:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-123158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123158-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 71944B2188D for ; Thu, 28 Mar 2024 15:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CFB612FB3E; Thu, 28 Mar 2024 15:37:25 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 960363DAC13; Thu, 28 Mar 2024 15:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711640244; cv=none; b=qk0NCfKT63/39eXJAslyUFDZ1pS1uCB9+AvzMeokNMpOHfdGW3PoA3B77glwjUgZjFzPi1Hmfn7SOKX5gueckl1jME231qRqABlbWK8JhC1GAY2jc0cd1W+745Dy9PlMboUU1I19XJ738tIuvurtfCrzhRPJ4jqFhYkyQ2CXTPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711640244; c=relaxed/simple; bh=M1/MI7ctmoanaJzMS8Vaa21avZdB8bKDRkpxkpFOS8Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=duoNiSJMi4Nd9lcUzIxdRVE/TJsg961wOyhOq7mmyWhSiEOyeMxslBhYxXUvP0avr54munlknbN2pdP2Upqiz5OtKNfVA16WVe/Lbx5UaqbNRF3kcEDqUXnFbQ7DrkpU8jG/EDl6CUhewvs0/X/Gs+Q+r/o3DgdUEEisoP8objw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE36FC433F1; Thu, 28 Mar 2024 15:37:20 +0000 (UTC) Date: Thu, 28 Mar 2024 11:40:04 -0400 From: Steven Rostedt To: Yi-De Wu Cc: Yingshiuan Pan , Ze-Yu Wang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Catalin Marinas , Wihl Deacon , "Masami Hiramatsu" , Mathieu Desnoyers , Richard Cochran , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , , , David Bradil , Trilok Soni , Jade Shih , Ivan Tseng , My Chuang , Shawn Hsiao , PeiLun Suei , Liju Chen , "Willix Yeh" , Kevenny Hsieh Subject: Re: [PATCH v8 19/20] virt: geniezone: Add tracing support for hyp call and vcpu exit_reason Message-ID: <20240328114004.5793230a@gandalf.local.home> In-Reply-To: <20231228105147.13752-20-yi-de.wu@mediatek.com> References: <20231228105147.13752-1-yi-de.wu@mediatek.com> <20231228105147.13752-20-yi-de.wu@mediatek.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 28 Dec 2023 18:51:46 +0800 Yi-De Wu wrote: > Add tracepoints for hypervisor calls and VCPU exit reasons in GenieZone > driver. It aids performance debugging by providing more information > about hypervisor operations and VCPU behavior. > > Command Usage: > echo geniezone:* >> /sys/kernel/tracing/set_event > echo 1 > /sys/kernel/tracing/tracing_on > echo 0 > /sys/kernel/tracing/tracing_on > cat /sys/kernel/tracing/trace > > For example: > crosvm_vcpu0-4838 [004] ..... 76053.536034: mtk_hypcall_enter: id=0xbb001005 > crosvm_vcpu0-4838 [004] ..... 76053.540039: mtk_hypcall_leave: id=0xbb001005 invalid=0 > crosvm_vcpu0-4838 [004] ..... 76053.540040: mtk_vcpu_exit: vcpu exit_reason=0x92920003 Cleaning out patchwork, I noticed this patch. You can make the above more informative by having it output: crosvm_vcpu0-4838 [004] ..... 76053.540040: mtk_vcpu_exit: vcpu exit_reason=IRQ > > This example tracks a hypervisor function call by an ID (`0xbb001005`) > from initiation to termination, which is supported (invalid=0). A vCPU > exit is triggered by an Interrupt Request (IRQ) (exit reason: 0x92920003). > > /* VM exit reason */ > enum { > GZVM_EXIT_UNKNOWN = 0x92920000, > GZVM_EXIT_MMIO = 0x92920001, > GZVM_EXIT_HYPERCALL = 0x92920002, > GZVM_EXIT_IRQ = 0x92920003, > GZVM_EXIT_EXCEPTION = 0x92920004, > GZVM_EXIT_DEBUG = 0x92920005, > GZVM_EXIT_FAIL_ENTRY = 0x92920006, > GZVM_EXIT_INTERNAL_ERROR = 0x92920007, > GZVM_EXIT_SYSTEM_EVENT = 0x92920008, > GZVM_EXIT_SHUTDOWN = 0x92920009, > GZVM_EXIT_GZ = 0x9292000a, > }; > > Signed-off-by: Liju-clr Chen > Signed-off-by: Yi-De Wu > --- > arch/arm64/geniezone/vm.c | 5 +++ > drivers/virt/geniezone/gzvm_vcpu.c | 3 ++ > include/trace/events/geniezone.h | 54 ++++++++++++++++++++++++++++++ > 3 files changed, 62 insertions(+) > create mode 100644 include/trace/events/geniezone.h > > diff --git a/arch/arm64/geniezone/vm.c b/arch/arm64/geniezone/vm.c > index a9d264bbb3b1..5667643251b5 100644 > --- a/arch/arm64/geniezone/vm.c > +++ b/arch/arm64/geniezone/vm.c > @@ -7,6 +7,8 @@ > #include > #include > > +#define CREATE_TRACE_POINTS > +#include > #include > #include > #include "gzvm_arch_common.h" > @@ -33,7 +35,10 @@ int gzvm_hypcall_wrapper(unsigned long a0, unsigned long a1, > unsigned long a6, unsigned long a7, > struct arm_smccc_res *res) > { > + trace_mtk_hypcall_enter(a0); > arm_smccc_hvc(a0, a1, a2, a3, a4, a5, a6, a7, res); > + trace_mtk_hypcall_leave(a0, (res->a0 != ERR_NOT_SUPPORTED) ? 0 : 1); > + > return gzvm_err_to_errno(res->a0); > } > > diff --git a/drivers/virt/geniezone/gzvm_vcpu.c b/drivers/virt/geniezone/gzvm_vcpu.c > index 86c690749277..138ec064596b 100644 > --- a/drivers/virt/geniezone/gzvm_vcpu.c > +++ b/drivers/virt/geniezone/gzvm_vcpu.c > @@ -10,6 +10,8 @@ > #include > #include > #include > + > +#include > #include > > /* maximum size needed for holding an integer */ > @@ -103,6 +105,7 @@ static long gzvm_vcpu_run(struct gzvm_vcpu *vcpu, void __user *argp) > > while (!need_userspace && !signal_pending(current)) { > gzvm_arch_vcpu_run(vcpu, &exit_reason); > + trace_mtk_vcpu_exit(exit_reason); > > switch (exit_reason) { > case GZVM_EXIT_MMIO: > diff --git a/include/trace/events/geniezone.h b/include/trace/events/geniezone.h > new file mode 100644 > index 000000000000..1fa44f9c4b3c > --- /dev/null > +++ b/include/trace/events/geniezone.h > @@ -0,0 +1,54 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (c) 2023 MediaTek Inc. > + */ > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM geniezone > + > +#define _TRACE_GENIEZONE_H > + > +#include #define GZVM_EXIT_REASONS \ EM(UNKNOWN) \ EM(MMIO) \ EM(HYPERCALL) \ EM(IRQ) \ EM(EXCEPTION) \ EM(DEBUG) \ EM(FAIL_ENTRY) \ EM(INTERNAL_ERROR) \ EM(SYSTEM_EVENT) \ EM(SHUTDOWN) \ EMe(GZ) #undef EM #undef EMe #define EM(a) TRACE_DEFINE_ENUM(GZVM_EXIT_##a); #define EMe(a) TRACE_DEFINE_ENUM(GZVM_EXIT_##a); GZVM_EXIT_REASONS #undef EM #undef EMe #define EM(a) { GZVM_EXIT_##a, #a }, #define EMe(a) { GZVM_EXIT_##a, #a } > + > +TRACE_EVENT(mtk_hypcall_enter, > + TP_PROTO(unsigned long id), > + > + TP_ARGS(id), > + > + TP_STRUCT__entry(__field(unsigned long, id)), > + > + TP_fast_assign(__entry->id = id;), > + > + TP_printk("id=0x%lx", __entry->id) > +); > + > +TRACE_EVENT(mtk_hypcall_leave, > + TP_PROTO(unsigned long id, unsigned long invalid), > + > + TP_ARGS(id, invalid), > + > + TP_STRUCT__entry(__field(unsigned long, id) > + __field(unsigned long, invalid) > + ), > + > + TP_fast_assign(__entry->id = id; > + __entry->invalid = invalid; > + ), > + > + TP_printk("id=0x%lx invalid=%lu", __entry->id, __entry->invalid) > +); > + > +TRACE_EVENT(mtk_vcpu_exit, > + TP_PROTO(unsigned long exit_reason), > + > + TP_ARGS(exit_reason), > + > + TP_STRUCT__entry(__field(unsigned long, exit_reason)), > + > + TP_fast_assign(__entry->exit_reason = exit_reason;), > + > + TP_printk("vcpu exit_reason=0x%lx", __entry->exit_reason) TP_printk("vcpu exit_reason=0x%lx", __print_symbolic(__entry->exit_reason, GZVM_EXIT_REASONS)) And instead of having the cryptic enum values printed, you will have human readable reasons. -- Steve > +); > + > +/* This part must be outside protection */ > +#include