From patchwork Sun Oct 8 14:57:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tianyi Liu X-Patchwork-Id: 149758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1403419vqo; Sun, 8 Oct 2023 07:58:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqOmiA6mZTK+ak2UndkaHbd5gG+WCN3PUcnceNmM6kwQj0hUMsVlC8ljyHK76jEV+0mhXU X-Received: by 2002:a17:90a:414d:b0:271:9e59:df28 with SMTP id m13-20020a17090a414d00b002719e59df28mr11562124pjg.29.1696777110808; Sun, 08 Oct 2023 07:58:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696777110; cv=pass; d=google.com; s=arc-20160816; b=V8NwmpDOQa3qgPwehG2QXGoibBoPZswg7BzF7s5M92sjgwfvlIn8NU4pe6FVHfMEvh oSPs44IabQyUNB5xO+XbVtELetbLox9Irc4U0kfrTBt2iVurOEp8kmjeH83iKUnh5ZYT XFitST87X9sQkTHsXaAKWfsKkNX0JW8ypAAIvvZdun20rPmVAgemmQIjHpYGsW6eTlAU vazQtH7ippKua0sxUBpIIaxKo9xKQkAUVnFR8r6yJy2xrvVi5i1SZCOwuiv8gmEeOZPI 9yqblRBEhlWMwSGHwljs30ZsnOojqWeVqyJzGz+fSp2AHy5qB5HbOB3hLzcXmUvc5qo6 KPAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I/lFtn/nLc2LrnucpQ3epHICG2GV9+ahNS6ImpVxMfc=; fh=F5FYRTUV4xCU93BuG+U5i7IE8Bv2SgSTNGSJMbfAlmQ=; b=mnCKJnKKhhkGhiHIfjHH9vGvQ6Zy/sUHlzb9onLenn9/RSdb7erqyLe3udaUsM+Q3f oi77kJxvQWjqXE6ZC+h985OXxCEkP1i3g0lqC/A7towN4Fd7hmuA8Rv0n4dt3ly26/Wf sIVPfen8C0EU+H1caf55Tht5OB1VQgUbOVv7CeucaQv9pmsZhsVwEOG2ddOFXOFUZ+de OqDliypDs6soZDuhmebhdVLqNCZrDiq1QsCDFrhWi0OHVvE1eSj2ooma4G/OKnfhCVG3 zx3vCrJRWzQ0UklZtGrcOhXxf1NGDnFl+bk+Zzb1H7UEArKMcrC5qRmwCUXxL0Xow1BN fEQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=FKhXYTsr; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id kx5-20020a17090b228500b002766354b7b2si7768163pjb.153.2023.10.08.07.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 07:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=FKhXYTsr; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DDE2A8026830; Sun, 8 Oct 2023 07:58:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344866AbjJHO6R (ORCPT + 18 others); Sun, 8 Oct 2023 10:58:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbjJHO6P (ORCPT ); Sun, 8 Oct 2023 10:58:15 -0400 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2159.outbound.protection.outlook.com [40.92.63.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FD6A4; Sun, 8 Oct 2023 07:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYHA7nfuRuhvLMy72MpWJ4mK3Jm0xZBoL4TvC3AZpUGkObu3MqIGpPAdNq6CRxINikHisMUbFuSjGEW38COSqRnkdr0BS1DGvEQ9QHfyr/27lCyP6i6gPKQCOluAdUv1ijgPUhEDqzJLAC9iKs1IDbr2WB3w8TnEsncomocLtFx6xqk/qr1o+fQK5rVVpDVRLH/96fyWeprLL0SJ3+tT9CwDGbCS/lUcdfEAfR/vWTU+poS2FW3bG7UUM+j+xYxfelQ8Pgdnj2uWlolyIOXOqLALv9jxTtvHsmiwl++kzpAkfHeTjwFAW3ihnqKl6P9flpSLpTT5fbWlYXEbut82pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I/lFtn/nLc2LrnucpQ3epHICG2GV9+ahNS6ImpVxMfc=; b=TkGgw0cIwiupQksITQIn8jAh0E54fPLFY/XgrbEEwAiUI20Z6gsXfFk7YK+4wEdrVZL72hlU/UR232OEju1DszJGkUVQmkunHFUzz7KkntaX8a5aoUEO7zqby4cLCxW+HXdRO7Pad/Gvn0M+4ZuYe8LCLJhk+YC+Q6U6Eyaif01HL7FGbG2fsohqqdku4QU/1SLpVNOudvIvZgyIfhyZACRmNICa/tpfk7Rkgl72RDr4aJxRXNEuCWpwDQb73ydN6FaOPweVXebbg3OZCKHk+wXt0raryqspNrob9XxJxEfXA0nd/9/FmjLgXLq+Pw5NZiLUg4DDTgfLYnbGR2cpxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I/lFtn/nLc2LrnucpQ3epHICG2GV9+ahNS6ImpVxMfc=; b=FKhXYTsr2zTk/gvEePAaOzVmVfxlx3K2gXV4OWq4nlAeFmALWbAbOAA+tZ04CR1hcUeHcLj2mdGbmmqAreDA2dE+618R5jU2bbzf+QoxyJWx/66qtESsEu4rOyaKQFhwq/GXSqOHTkLpRHGQmVn4rD1N9hxla2jYhKfWdfHh2pUqVRoeydGjQnsEiQXYu2dP+RIP+P6c1wlRX5GU0442yW46ciOBVvrk1u7BRUW2swZmARqXG8E6k88WTItcfFuvjUyTkaXmxX/SSdLtB3nV3WJxiLTGxZgH0tNiWTISUgmt/o11x+nVcftwMJxEEYfgtu9MQcOdZRBR+HAMAu127Q== Received: from SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:ac::13) by SYYP282MB1101.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:bf::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Sun, 8 Oct 2023 14:58:06 +0000 Received: from SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM ([fe80::e39e:17fc:36d8:1ea8]) by SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM ([fe80::e39e:17fc:36d8:1ea8%3]) with mapi id 15.20.6838.040; Sun, 8 Oct 2023 14:58:06 +0000 From: Tianyi Liu To: seanjc@google.com, pbonzini@redhat.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, Tianyi Liu Subject: [PATCH v2 5/5] perf tools: Support PERF_CONTEXT_GUEST_* flags Date: Sun, 8 Oct 2023 22:57:29 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-TMN: [brT8iFehEOwCNXRw/nHup347yUJJMi8XhYPK+wacExEAGNvB18G62w==] X-ClientProxiedBy: SG2PR06CA0235.apcprd06.prod.outlook.com (2603:1096:4:ac::19) To SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:ac::13) X-Microsoft-Original-Message-ID: <20231008145729.7886-1-i.pear@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY4P282MB1084:EE_|SYYP282MB1101:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c550b0c-fb1d-492c-ce93-08dbc80efa0a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KHeHlcHDe59T0Nksh3RMSTCkhCHOh9vZsPg/95V2XqN0q2P2+7r29qRIwKl/SpRRUHFpxFWeQA2OWsl3JMvr98XswCt7ZZkNa0XhTUQ0576IDW9Op3WoUzC1o/mJyyyK0W/deJGGZPVKkVhCwNjrOqE3jGe6gSyG8LX2bDNDTjs0QzFexZvY5uR1Lkbm+Wsh6edF8mdkMeLkoCKC5X6ApUHQWFRB1KAr07rKdcQhVsZA8Kgah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cgE7liaK06uWaV8Uh3lGQOfQF6sqFi7f/1y7ecTALLew/HFHuEufTjA0X5DitkzNY5EugXM3DGYIhJrl67F9f4w0yy+rzctiJlsjhR8JOrjp3YAqBlIdj0lu9YgmD0zP8UP4XUwJ8kOZ4P6tV+/SOBvos71IsCoc5BBBtp47OkJZlrTlD3eSn5BGmrUlo1iKY4uPvpBtt+taQfQqHpvGPMVGPElPpKRnhs659Ua7G06vzhgzfA4ziHq1UIO6/dIgyDuAf4mIglFR/e5vg4Zp1MwmPtfRzaDZlEH3reuXRct0sdxvdREyDmGtprQ8YFA6xeSuvw1GuH+uL+6x7nvgNly33F8TyuzOhQXJHWYBr+u0BLnwTK3drNG2NUf8VIWEmY1t/ZfYWI4GMmQgKEhK8RpH8aQu1bC5PnPDj2cXxlfkbv4H4H8h+Y269AjDIqW4dwmeF9p/0H18ww4F7DhumaM6X6lnDZT3+sGinTM6yBftC7QT0c9opy7MCMjqOTOBjRA859svMAQXHsL0bJa7vzN1GL38k25Cp9rDCTkRbWgcnJwCpry4uN9SLhXcryuOMX1h+vqDd9hDe5Ib1e6vpd+PN14ksHpSALXVjGLmUNrRnp3/cq1dBMb4dQD8yBYPSUKcM2EC49AWARdg7 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c550b0c-fb1d-492c-ce93-08dbc80efa0a X-MS-Exchange-CrossTenant-AuthSource: SY4P282MB1084.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2023 14:58:06.4846 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SYYP282MB1101 X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 08 Oct 2023 07:58:28 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779199755919469843 X-GMAIL-MSGID: 1779199755919469843 The `perf` util currently has a incomplete implementation for the following event flags, that events with these flags will be dropped or be identified as unknown types: `PERF_CONTEXT_GUEST_KERNEL` `PERF_CONTEXT_GUEST_USER` This patch makes `perf script`, `perf timechart` and `perf data` to correctly identify these flags. Signed-off-by: Tianyi Liu --- tools/perf/builtin-timechart.c | 6 ++++++ tools/perf/util/data-convert-json.c | 6 ++++++ tools/perf/util/machine.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 19d4542ea..6a368b6a3 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -536,6 +536,12 @@ static const char *cat_backtrace(union perf_event *event, case PERF_CONTEXT_USER: cpumode = PERF_RECORD_MISC_USER; break; + case PERF_CONTEXT_GUEST_KERNEL: + cpumode = PERF_RECORD_MISC_GUEST_KERNEL; + break; + case PERF_CONTEXT_GUEST_USER: + cpumode = PERF_RECORD_MISC_GUEST_USER; + break; default: pr_debug("invalid callchain context: " "%"PRId64"\n", (s64) ip); diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c index 5bb3c2ba9..62686f78d 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -205,6 +205,12 @@ static int process_sample_event(struct perf_tool *tool, case PERF_CONTEXT_USER: cpumode = PERF_RECORD_MISC_USER; break; + case PERF_CONTEXT_GUEST_KERNEL: + cpumode = PERF_RECORD_MISC_GUEST_KERNEL; + break; + case PERF_CONTEXT_GUEST_USER: + cpumode = PERF_RECORD_MISC_GUEST_USER; + break; default: pr_debug("invalid callchain context: %" PRId64 "\n", (s64) ip); diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 88f31b3a6..d88458c3b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2346,6 +2346,12 @@ static int add_callchain_ip(struct thread *thread, case PERF_CONTEXT_USER: *cpumode = PERF_RECORD_MISC_USER; break; + case PERF_CONTEXT_GUEST_KERNEL: + *cpumode = PERF_RECORD_MISC_GUEST_KERNEL; + break; + case PERF_CONTEXT_GUEST_USER: + *cpumode = PERF_RECORD_MISC_GUEST_USER; + break; default: pr_debug("invalid callchain context: " "%"PRId64"\n", (s64) ip);