Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp312319lqb; Tue, 16 Apr 2024 17:25:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVd4uhuQV7JGv9bd+sm+MU2cf5aJwDgGpwKAFKuZISLb5p1X6tZcVWHc1qdIDmonFmVe7NclX1EIChrNM7nGDqHQL4xxgwbOxNLly/bPg== X-Google-Smtp-Source: AGHT+IFMDQiOATcObbrYVlqziSsdKZcTgAGFBTG+YpihWCde5smm4qrI+0t9P359z6G4M+/s/+KL X-Received: by 2002:ae9:e90b:0:b0:78d:5b09:2a3 with SMTP id x11-20020ae9e90b000000b0078d5b0902a3mr15552730qkf.46.1713313525612; Tue, 16 Apr 2024 17:25:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713313525; cv=pass; d=google.com; s=arc-20160816; b=QpkU1s7it+kFNNu4n0sgRZ1YBheOTQeqNkekke8G4AnFRE4lCLrdhMNx5m0dSHDrzD y/dByb8lGWpLMaJgoMLjHmKlvC82s6PBfUX+j5k15VnPe4Cr3OfqNfrn7M3XKcg5h7xL aW7UWmPWgUTmADt9qbrTRvrd9uEcbjpCMm3bHzA8mx24xNUHDFx+WTtUKe79C045WJH8 jyfiKEN5iI7rYboXYcWKG+DVOkW980jCTDblRdpHBZioD5OyMRmRxa2aOy7bkUDDQL0y xyLYrKH4Adwz/vxGBIzMbVovwMiLd1jgJYPm5e1FwWpWi/n/en8RUDVBFj4Zlg4PhA4m q6EQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=yUu9r75IkkkPMJX8JtgPk9s/mlLbxcj8MCkbLeGGpmg=; fh=N6IeZjZllYtLx0jJZ2c5V98LwPOaJ/cahKdLX76OhsM=; b=zSR3MNlWEbYQOenOztUTKSjNaaVAohi/SL/Gn4Azc/HYjvfvRO0jBmwtYSX5MBcN/i I5g6hHdQPsk7UuEObPa3JhguCBdXXd6bn7HGVf21jO0JjGlBYr9SpY5JrmsD9PYm6di7 Dy15e0vnr5VAkNHfWNfpmHRO0K0hdBfxx8POc8ULdyaRCUQ964XK0lUN4rsBSSDpRPVX 3uCn6V914Daswu0Vy6zojpUmA2OKUzk4396/TwU18k+eLF/nQC5faZ6bAa7PVSVEDIl7 DNCor7wFfOGk0Tr2cNQuYXmOxahvyDqZINZRxRz9DKI8sPHc9DfUU8KiBKTsB5SZwawt w94Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cM+T9akk; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-147800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147800-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h17-20020a05620a21d100b0078d63d359f9si13584294qka.575.2024.04.16.17.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 17:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=cM+T9akk; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-147800-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147800-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 498E91C22450 for ; Wed, 17 Apr 2024 00:25:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD967186A; Wed, 17 Apr 2024 00:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="cM+T9akk" Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14E57801 for ; Wed, 17 Apr 2024 00:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713313511; cv=none; b=khDhdQQ0mqlsasJarQwU9dQ8mWc80vGpKtpYFcGkoHdVhDpUjpWIAZKmUMufxYhXFIY5TohqFPlUXL7qkc5v4z7cv96VF9P6Ih8j8YXYbwG9R6h7Jwdtl/GYTIi8BTg4vsKiVFnQsJpmuONWPxXiHfYy8tX5MxdqY+yFhZf1TeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713313511; c=relaxed/simple; bh=Rh0Xk5SOWgUhEYkDCx1Ih3fJwkSpqZ2vOp0lA0MHWwE=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=jdsVdnRhsY0zdldcFmfYblDIvIkML2S7yD1GldYjlQtTmsmOLBPPOY3aLEVDL0UhjwocDrTubZgQy10SCdNOnyfJq22IXg3PkC3VLZe/rBueEnVGPa9wPsTVrQo6XdyPnIAD51x64S6a8JR5HNcWPuquZcv7xt5I0BP6LS+Hg3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=cM+T9akk; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ecf406551aso4101906b3a.2 for ; Tue, 16 Apr 2024 17:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713313508; x=1713918308; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yUu9r75IkkkPMJX8JtgPk9s/mlLbxcj8MCkbLeGGpmg=; b=cM+T9akkTLdGr6P4CwMEaI3wC+DwudHkkTorB3cYyEiDSFhKdzlvEssT0MKCFKICwP 9x9zDEvZI3Ev6H7LuMrjUWy1hDPvy23g5At85VPXB0POcWsIcEFI8tryJk9XBmPj79+M XeasO3QSNwGz6YJ8F1Dgso6oNugWGBJcSmEWbgt4cX/GaakCDiGQBkmtMe12QifUo+9h JKCQxEIVZ4KHlfktVHpNx/i8etcZQfrkCbhhaFZEfdGJf218/usTZ1p+oxtupw9dUvpv fs3GO4JdnRxSTXnL/aK+0b/6IyQowCMTlHTPp9wyOOsU+GAu+lGR2fCml5IAnCy9yIpx VXVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713313508; x=1713918308; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yUu9r75IkkkPMJX8JtgPk9s/mlLbxcj8MCkbLeGGpmg=; b=OgY8dklXBR4YBmA2ypje8FY+pnomttvuoizR2k+E3iMu1FSwvnTRledFX9LZo0jGSB l/JDHzYSxUEfxU14ppX84wlf/TQ5M//xON9RpIii0mJtPbr9tAp42kvB7xxVLa5o+jXw qeaatvwM3wmPhUr1l1XhzPUm39lQJKBwtsvRRvW2lsD/7bcf5e4Hp8FTSAikjp2RgMOb JcJA0od+KXePKxuWtEvMKRacL4tu5VKcav27cQCJ3kD5d0LseTP3vEy7OQpll3k8FH29 gNSwpWqPeF4L7diSZIBBWlYBzYaPxCllQbA9zFrWKTVfJmbG/tUQaFU9OtZVKPhFHc4Y Ahyg== X-Forwarded-Encrypted: i=1; AJvYcCVIr38UD/wsCtLBEGBIs8M0cxA6RI1g/5SNqA5TUJUnaH/Vr4mmji806Z6+o9ShjdW+v82poySHnBVxOVOk0xujYhEC4nMVVSlJeyXz X-Gm-Message-State: AOJu0YxexlN+0JCJ1UMdpDkCpJehFhZMfThEykqb39YEJu09+0EieZcj 44k3VLl+rcrtnVkLX7WkaYa+Wsvj9AMnqykbw0Ju1qwK++2X2PTQk65K4+8FwNM= X-Received: by 2002:a05:6a20:d492:b0:1a9:cd84:2f31 with SMTP id im18-20020a056a20d49200b001a9cd842f31mr13414753pzb.58.1713313508368; Tue, 16 Apr 2024 17:25:08 -0700 (PDT) Received: from [172.16.0.69] (c-67-188-2-18.hsd1.ca.comcast.net. [67.188.2.18]) by smtp.gmail.com with ESMTPSA id f12-20020a170902684c00b001e3d2314f3csm10574125pln.141.2024.04.16.17.25.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Apr 2024 17:25:08 -0700 (PDT) Message-ID: Date: Tue, 16 Apr 2024 17:25:06 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/2] perf kvm: Add kvm stat support on riscv Content-Language: en-US To: Shenlin Liang , 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 References: <20240415031131.23443-1-liangshenlin@eswincomputing.com> From: Atish Patra In-Reply-To: <20240415031131.23443-1-liangshenlin@eswincomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/14/24 20:11, Shenlin Liang wrote: > Changes from v1->v2: > - Rebased on Linux 6.9-rc3. > > 'perf kvm stat report/record' generates a statistical analysis of KVM > events and can be used to analyze guest exit reasons. This patch tries > to add stat support on riscv. > > Map the return value of trace_kvm_exit() to the specific cause of the > exception, and export it to userspace. > > It records on two available KVM tracepoints for riscv: "kvm:kvm_entry" > and "kvm:kvm_exit", and reports statistical data which includes events > handles time, samples, and so on. > > Simple tests go below: > > # ./perf kvm record -e "kvm:kvm_entry" -e "kvm:kvm_exit" > Lowering default frequency rate from 4000 to 2500. > Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate. > [ perf record: Woken up 18 times to write data ] > [ perf record: Captured and wrote 5.433 MB perf.data.guest (62519 samples) > I want to test these patches but couldn't build a perf for RISC-V with libtraceevent enabled. It fails with pkg-config dependencies when I tried to build it (both via buildroot and directly from kernel source). > # ./perf kvm report > 31K kvm:kvm_entry > 31K kvm:kvm_exit > > # ./perf kvm stat record -a > [ perf record: Woken up 3 times to write data ] > [ perf record: Captured and wrote 8.502 MB perf.data.guest (99338 samples) ] > > # ./perf kvm stat report --event=vmexit > Event name Samples Sample% Time (ns) Time% Max Time (ns) Min Time (ns) Mean Time (ns) > STORE_GUEST_PAGE_FAULT 26968 54.00% 2003031800 40.00% 3361400 27600 74274 > LOAD_GUEST_PAGE_FAULT 17645 35.00% 1153338100 23.00% 2513400 30800 65363 > VIRTUAL_INST_FAULT 1247 2.00% 340820800 6.00% 1190800 43300 273312 > INST_GUEST_PAGE_FAULT 1128 2.00% 340645800 6.00% 2123200 30200 301990 > SUPERVISOR_SYSCALL 1019 2.00% 245989900 4.00% 1851500 29300 241403 > LOAD_ACCESS 986 1.00% 671556200 13.00% 4180200 100700 681091 > INST_ACCESS 655 1.00% 170054800 3.00% 1808300 54600 259625 > HYPERVISOR_SYSCALL 21 0.00% 4276400 0.00% 716500 116000 203638 > > Shenlin Liang (2): > RISCV: KVM: add tracepoints for entry and exit events > perf kvm/riscv: Port perf kvm stat to RISC-V > > arch/riscv/kvm/trace.h | 67 ++++++++++++++++ > arch/riscv/kvm/vcpu.c | 7 ++ > tools/perf/arch/riscv/Makefile | 1 + > tools/perf/arch/riscv/util/Build | 1 + > tools/perf/arch/riscv/util/kvm-stat.c | 78 +++++++++++++++++++ > .../arch/riscv/util/riscv_exception_types.h | 41 ++++++++++ > 6 files changed, 195 insertions(+) > create mode 100644 arch/riscv/kvm/trace.h > create mode 100644 tools/perf/arch/riscv/util/kvm-stat.c > create mode 100644 tools/perf/arch/riscv/util/riscv_exception_types.h >