Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1194825lqp; Sun, 14 Apr 2024 20:17:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsY/hiPDpHG6TXHgd9t/utwTMtjpUg6jSqljis0Nu9ttgq6H3Ym3PsIA8C7/x9aIdIOvcMx9F79QcMgQkQtQ2Zw23kY1OJH0h9EpU41Q== X-Google-Smtp-Source: AGHT+IGp3tCADuB4PKM05MwJ5D72vXVVbrep24JzGFM08oF9cd+cMII4KT+EOA7Y82fOoEI/g7SK X-Received: by 2002:a17:907:94c1:b0:a51:e5c7:55b7 with SMTP id dn1-20020a17090794c100b00a51e5c755b7mr5964912ejc.47.1713151032717; Sun, 14 Apr 2024 20:17:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713151032; cv=pass; d=google.com; s=arc-20160816; b=MZDr7w6048v7NG+E7IL6Cdav1+x7k03Lkp/qxoeShUCEPIPVCVGULYQllfIgJ8CfkQ Ahk6bhbFb8ENwVgTjqqGlOy6yQoDUK2yvABR8sqRCaLvhCHm8BSAu5Av2CVLZGCLW0je S23Xvu3kzvXTuc0qnreE3ZBAQlE7CAhYzhXrTHNDWsQvj4+8sRlmM0ztqVcei+jEGKaP NvhdwIGM+WcK37JAKzKYVM0sWPcSytXlJLWyTH2q6GtdIhmOkB8EIMNDumllhyWrtAka 9aPifE8/ZoWRx7KVlLGAFgtXDIM5ZfVhdTcMoGHB45yRqUqZAQBZ2h4Uve3DaAaz8eDR VW5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=f9yXce6TlWFnKqfhkCeIoFU1VSkxTRX1aPfSUFjhOg8=; fh=Rj4Hx4F7rlwv+flBVOusEWYVFqahWKOYkfP4cm4SOTM=; b=eUj0cE/hIFSqmL0xFjyo+9+mHcmA6bjUeCBS/0Qm+k/UhYtkT1fD4FiaUsOTXEkNpN T02rQd/o7IMr3Px5W1IYa/6HEGCkJRAok/wiCp5BHb1alvtfvhkfZTH900+Pu2oJLUt6 S/0rdYoDSvL0LJg/Wj9WfvEo9RyLqvkwuRFrEUs8axSUgcIei/wU2CXm0b3CGjBs5EaK HFE1zB+P0m16W3/aKgmpUC7oKdAOrR3WwUUpsFtSARMgyIHcKsSfG+PMCSXvezqs3JNp F1XB5nG4Vq1pB/adno2YAxnHj+iMYkOQNUbEwe6wPkdK+5W+OftstWZVc0Q48FsaiDhi uf1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=eswincomputing.com); spf=pass (google.com: domain of linux-kernel+bounces-144513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144513-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ef14-20020a17090697ce00b00a47b173a6d7si4067532ejb.526.2024.04.14.20.17.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 20:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=eswincomputing.com); spf=pass (google.com: domain of linux-kernel+bounces-144513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144513-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 70AE21F21943 for ; Mon, 15 Apr 2024 03:17:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45CA02374E; Mon, 15 Apr 2024 03:16:26 +0000 (UTC) Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [20.231.56.155]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B34CAEEBB; Mon, 15 Apr 2024 03:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=20.231.56.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713150985; cv=none; b=lZKwxTN3jkU2bQoSrC8QhvJqOkl+jcgIWQGz++ST/d+oZ5PPOHDJRsgn4XE37x2V+l1Jc0Y6Q2eX35N3bBt2Q9YqqzrMcvu4IIU0cPvsvRMLI+ZHgYh5f3iPBHn95jXQ76ZnCWcMmK9qOenHA5D83MPbRy34zl2ZaOpLcW+Xi7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713150985; c=relaxed/simple; bh=/aLNjVt2cJ4Sxo+dh24rqmQryJZ2CWGjqzB4e0mzWWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=iwwZsVwM86ott0cVY/P00kpBH3ZiNchxuC0hVyogjrRTZ7btwlJCQhbWqSSHZ/qulEoTLzcEkFj10h8iw2zLncQLgMeb7F8bcdZove41s/wvPu8oTQOz7jD9rQxd/iAdt+ikyl6R2laY7tjiW4aY8JRnsUJJ6O4Q7f6s6x/sku0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com; spf=pass smtp.mailfrom=eswincomputing.com; arc=none smtp.client-ip=20.231.56.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eswincomputing.com Received: from localhost.localdomain (unknown [10.12.130.31]) by app1 (Coremail) with SMTP id TAJkCgCnSOV3mxxmR4gGAA--.51722S5; Mon, 15 Apr 2024 11:14:02 +0800 (CST) From: Shenlin Liang To: anup@brainfault.org, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org Cc: Shenlin Liang Subject: [PATCH v2 1/2] RISCV: KVM: add tracepoints for entry and exit events Date: Mon, 15 Apr 2024 03:11:30 +0000 Message-Id: <20240415031131.23443-2-liangshenlin@eswincomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240415031131.23443-1-liangshenlin@eswincomputing.com> References: <20240415031131.23443-1-liangshenlin@eswincomputing.com> X-CM-TRANSID:TAJkCgCnSOV3mxxmR4gGAA--.51722S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXFW3CFWUur13Ar17tFW7XFb_yoW5AFW8pF nrurn5W3y8JrW2k3yfZw1vgr4YvrZY9r42qr9rXrW5Ar4vyr1DJr4vgrWUtr98AryF934f XF9YyFyDCw15Zw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPv14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY02Avz4vE-syl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjfUecTQUUUUU X-CM-SenderInfo: xold0whvkh0z1lq6v25zlqu0xpsx3x1qjou0bp/ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Like other architectures, RISCV KVM also needs to add these event tracepoints to count the number of times kvm guest entry/exit. Signed-off-by: Shenlin Liang --- arch/riscv/kvm/trace.h | 67 ++++++++++++++++++++++++++++++++++++++++++ arch/riscv/kvm/vcpu.c | 7 +++++ 2 files changed, 74 insertions(+) create mode 100644 arch/riscv/kvm/trace.h diff --git a/arch/riscv/kvm/trace.h b/arch/riscv/kvm/trace.h new file mode 100644 index 000000000000..3d54175d805c --- /dev/null +++ b/arch/riscv/kvm/trace.h @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Tracepoints for RISC-V KVM + * + * Copyright 2024 Beijing ESWIN Computing Technology Co., Ltd. + * + */ +#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_KVM_H + +#include + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM kvm + +TRACE_EVENT(kvm_entry, + TP_PROTO(struct kvm_vcpu *vcpu), + TP_ARGS(vcpu), + + TP_STRUCT__entry( + __field(unsigned long, pc) + ), + + TP_fast_assign( + __entry->pc = vcpu->arch.guest_context.sepc; + ), + + TP_printk("PC: 0x016%lx", __entry->pc) +); + +TRACE_EVENT(kvm_exit, + TP_PROTO(struct kvm_cpu_trap *trap), + TP_ARGS(trap), + + TP_STRUCT__entry( + __field(unsigned long, sepc) + __field(unsigned long, scause) + __field(unsigned long, stval) + __field(unsigned long, htval) + __field(unsigned long, htinst) + ), + + TP_fast_assign( + __entry->sepc = trap->sepc; + __entry->scause = trap->scause; + __entry->stval = trap->stval; + __entry->htval = trap->htval; + __entry->htinst = trap->htinst; + ), + + TP_printk("SEPC:0x%lx, SCAUSE:0x%lx, STVAL:0x%lx, HTVAL:0x%lx, HTINST:0x%lx", + __entry->sepc, + __entry->scause, + __entry->stval, + __entry->htval, + __entry->htinst) +); + +#endif /* _TRACE_RSICV_KVM_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE trace + +/* This part must be outside protection */ +#include diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index b5ca9f2e98ac..f4e27004ceb8 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -21,6 +21,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include "trace.h" + const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), STATS_DESC_COUNTER(VCPU, ecall_exit_stat), @@ -782,6 +785,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) */ kvm_riscv_local_tlb_sanitize(vcpu); + trace_kvm_entry(vcpu); + guest_timing_enter_irqoff(); kvm_riscv_vcpu_enter_exit(vcpu); @@ -820,6 +825,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) local_irq_enable(); + trace_kvm_exit(&trap); + preempt_enable(); kvm_vcpu_srcu_read_lock(vcpu); -- 2.37.2