From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EB6EC433E2 for ; Thu, 17 Sep 2020 10:12:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C34972087D for ; Thu, 17 Sep 2020 10:12:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DXqhBNLv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726662AbgIQKMh (ORCPT ); Thu, 17 Sep 2020 06:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgIQKM0 (ORCPT ); Thu, 17 Sep 2020 06:12:26 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6F2C06174A for ; Thu, 17 Sep 2020 03:12:26 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id l126so916029pfd.5 for ; Thu, 17 Sep 2020 03:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8I5syEFzYXSRk+uSOFJ1LBkGshbWMD1FtRIoI4eUqrM=; b=DXqhBNLvrOpzm/WiMVfuqadagjwe5PQxj3q+Pc1uBJ7yTs5Nxvlrdquq9Rrb8qx0Ls HJNVzPxgDFVtgC+bKF0qxLf/XY7ZpskadXW5ZwwzREuu7jCRyLWuHmDMkkr8WsvLBgE8 /09FRxVMfdEDkhO4Kq0qh0Q3tt9YH1bNupkzw5qg9f+ZTIFrwE0Xq6MeCPgYAluh8Jo4 lCrLLvu4IG4DoLxdrYRF+0STMGkujXZ8eclSSWWceNsoAl/bclMQ2DkhUesE2wd8lS8H el//wi1IO7DnDSrRAe3W0AB1Rq3mbljFQy9icPK+/wydY/WM3ZUfNjJqCIIHqM4ccnFv JLUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8I5syEFzYXSRk+uSOFJ1LBkGshbWMD1FtRIoI4eUqrM=; b=Qj45QLM2B82KQ22XWf2bebh1M+rnK1ZOI5bGPITOeZCNhFLe6UL+MhN1p+IXy+aZX+ y65zc/7lX3C8am5hqhiswzR6Vzj1G/TbjLXrsZlEqb+5nEFkVBZ3sXp0GoeyNVRH79dV s95WzEZqlrHiDk9VIX7xrNWyPaVkAIdbK8m8AzkYrrCFL8Vlbcir4rsYkc/ODdUsFwIm /rnCkH6sZQq3wc4g9DpWHQmZvnm77tgpIxciR6KKf8pl7pBiOYTCupGtGc5MW5O3mpuC 4XWqAGdAmoM7ll0Rv2UixJPVsSGObeYesyMhSlpKQSlT3jBGHVXQuSJShi86tL/4t1vI prWQ== X-Gm-Message-State: AOAM533+BvMbpUhPLG6kaY+C9HCOfSIJQ4hUx+HNyETXvJydJWvxZFW9 JROXVpBq51bHjhATPcv2Boe9Sw== X-Google-Smtp-Source: ABdhPJwVNfyNv6ekHlyUhzXzygE1It0dJ8XU3+DqczN/LPOjJ1tC5bAo3VVMJnlmrNkjmGjU4+4mNQ== X-Received: by 2002:a63:8ac8:: with SMTP id y191mr21800032pgd.159.1600337545751; Thu, 17 Sep 2020 03:12:25 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id d5sm22100002pfq.72.2020.09.17.03.12.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Sep 2020 03:12:25 -0700 (PDT) Date: Thu, 17 Sep 2020 18:12:19 +0800 From: Leo Yan To: Sergey Senozhatsky , Marc Zyngier Cc: Arnaldo Carvalho de Melo , Mark Rutland , Peter Zijlstra , Will Deacon , John Garry , Mathieu Poirier , Namhyung Kim , Suleiman Souhlal , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCHv3] perf kvm: add kvm-stat for arm64 Message-ID: <20200917101219.GD12548@leoy-ThinkPad-X240s> References: <20200917003645.689665-1-sergey.senozhatsky@gmail.com> <20200917100950.GC12548@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917100950.GC12548@leoy-ThinkPad-X240s> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Marc at this time, sorry for spamming. On Thu, Sep 17, 2020 at 06:09:50PM +0800, Leo Yan wrote: > [ + Marc ] > > On Thu, Sep 17, 2020 at 09:36:45AM +0900, Sergey Senozhatsky wrote: > > [...] > > > diff --git a/tools/perf/arch/arm64/util/kvm-stat.c b/tools/perf/arch/arm64/util/kvm-stat.c > > new file mode 100644 > > index 000000000000..32e58576f186 > > --- /dev/null > > +++ b/tools/perf/arch/arm64/util/kvm-stat.c > > @@ -0,0 +1,86 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include > > +#include > > +#include "../../util/evsel.h" > > +#include "../../util/kvm-stat.h" > > +#include "arm64_exception_types.h" > > +#include "debug.h" > > + > > +define_exit_reasons_table(arm64_exit_reasons, kvm_arm_exception_type); > > +define_exit_reasons_table(arm64_trap_exit_reasons, kvm_arm_exception_class); > > + > > +const char *kvm_trap_exit_reason = "esr_ec"; > > +const char *vcpu_id_str = "id"; > > On Arm64, ftrace tracepoint "kvm_entry" doesn't contain the field "id" > or field "vcpu_id", thus it always reads out the "id" is 0 and it is > recorded into Perf's structure vcpu_event_record::vcpu_id and assigned > to perf thread's private data "thread::private". > > With current code, it will not mess up different vcpus' samples because > now the samples are analyzed based on thread context, but since all > threads' "vcpu_id" is zero, thus all samples are accounted for > "vcpu_id=0" and cannot print out correct result with option "--vcpu": > > > $ perf kvm stat report --vcpu 4 > > Analyze events for all VMs, VCPU 4: > > VM-EXIT Samples Samples% Time% Min Time Max Time Avg time > > Total Samples:0, Total events handled time:0.00us. > > > This is an issue I observed, if we want to support option "--vcpu", > seems we need to change ftrace event for "kvm_entry", but this will > break ABI. > > Essentially, this issue is caused by different archs using different > format for ftrace event "kvm_entry", on x86 it contains feild > "vcpu_id" but arm64 only just records "vcpu_pc". > > @Marc, @Will, do you have any suggestion for this? Do you think it's > feasible to add a new field "vcpu_id" into the tracepoint "kvm_entry" > for Arm64's version? > > Thanks, > Leo