From patchwork Sat Nov 5 07:23:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13032958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52502C4332F for ; Sat, 5 Nov 2022 07:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zQ00r4/mISVBs1xB/zVW9S9NL2bzkKEV0ueETTPZUKQ=; b=xLRyKTj22AsezL il8gJXUj8v4w/Cmk0pfrWZAfiWIZPJWV+k7kVhr8CAy8AS9fHpTtaRA2MeaYxqyXp7ev4cdaY61a0 Dc7/BGo768i83w/GkfprovisBbaA8PiT/kUODrlfnapdPlknvuIx13YhOjeRvCmPP7Mag6mNZOWRH mdXna74PUQGUPRdn4IvQOhEhHfMmYQC/f70g5M8SrgrpUN/narjzqsFdAmsrg7rTWTI6ybBL8TAnw zsFSRLo3SHSL9LrXnXJWvXO57LO6hi2dCarMEGcXFl9bCQ49XQW/qzJBqRMM9Nskj/pAXGT7mgNXo yUqKrKHXVqBl7mmp7sjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orDWn-005zac-T4; Sat, 05 Nov 2022 07:23:42 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1orDWk-005za7-Eb for linux-arm-kernel@lists.infradead.org; Sat, 05 Nov 2022 07:23:40 +0000 Received: by mail-pj1-x1029.google.com with SMTP id gw22so6344523pjb.3 for ; Sat, 05 Nov 2022 00:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LgggK8hkZgVH++8BD/dM0aO2tMGo/D//b9l3kVhUdaM=; b=U/x0+UrK6WD6QwysmwpCA6LmD53P1GxIR19amIkClJs1U+DHkp7esj810/Xw7URgnY 6NZVQQh5o9g8yaYpc02GHR8JOzUihaJcqSDdOE4cbtwJ85fzUguLvM3x7ZP842rNUC4G IOH+V7ahbW783oQ8t1L6kNWapP1kP/J2F7tFsu6XQqecGj3cX7fYSRayd64pTmcy8HAn d6cI4eeNhbX20o3Zwkz6bJbo5zvNtLkTeCPbaESHSN2yBcXQQxv6d5gjfmS+2xwxXfSZ fv3McoM3OjyE9c0uf4tT/4mLzwamPM6YxCUj/eClgwuZOznnXV4mUenapD7gr/s648tl fm7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LgggK8hkZgVH++8BD/dM0aO2tMGo/D//b9l3kVhUdaM=; b=Pp+C974yxrHlOC0ir7V3Ol1Ht4ONm7PrDdRh/qq0n9gm6DLLZPD1f3MkufHeQrUV5y tSJ3qwc/JPZNvVWijA1O/Hz7tP24fy0LP4aRnMlgULwGgxBhSZsi9LnO/p5Z4QUFFTgb Y2U9E+RsEbvMvWBx1h6kQFYd/NYO1kdX5YUVR5LaD0jdKUciEOwhZSE60g3v/ytOpHqv f4PMV0M194CFxUyDDF+SEYez/OQN9+4k7bMVkPhadzV6GOF/tGxl4erxC5LccLDUAcD8 rHOHoqBIL3QfDNC+dIccj7GRIhnYdBx1vCXC59F8i17RR0ATZ97h14KOMhR+PPchuP7Z zZ3w== X-Gm-Message-State: ACrzQf3goxNeoifKTQvAsBZuyxA30NaGTop62ukJOZEUkxAPxzAmOgkW pnygD68asOqi8Ofhb4j5XUt9Pw== X-Google-Smtp-Source: AMsMyM44ZOypFpAKOh/gnh0gedsNVpBtxc3XmEVYmQYriCbTJfC96MuNcATWjqEewuhMoI5TXce8Dw== X-Received: by 2002:a17:902:e745:b0:187:2033:1832 with SMTP id p5-20020a170902e74500b0018720331832mr31176766plf.119.1667633016062; Sat, 05 Nov 2022 00:23:36 -0700 (PDT) Received: from leoy-huangpu.lan (211-75-219-201.hinet-ip.hinet.net. [211.75.219.201]) by smtp.gmail.com with ESMTPSA id w27-20020aa79a1b000000b00562ef28aac6sm698138pfj.185.2022.11.05.00.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 00:23:35 -0700 (PDT) From: Leo Yan To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon , Arnaldo Carvalho de Melo , John Garry , James Clark , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 0/3] KVM: arm64: Support tracing virtual CPU ID Date: Sat, 5 Nov 2022 07:23:08 +0000 Message-Id: <20221105072311.8214-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221105_002338_513316_A2FD40EE X-CRM114-Status: GOOD ( 17.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Before there have some efforts and discussion for supprot tracing virtual CPU ID in Arm64 KVM, see [1][2]. The issue was blocked with a main concern that we cannot change the existed trace events to avoid ABI breakage. So the question is how we add new trace events with tracing virtual CPU ID and also need to keep backward compatibility. This patch set is to restart the work, it's inspired by Qais Yousef's work for adding scheduler tracepoints [3]. The first patch changes to register tracepoint callbacks, this can allow us to support multiple trace events with a single call site, it's a preparation to add new trace events. The second patch is to add two new trace events kvm_entry_v2 and kvm_exit_v2, and these two trace events contain the field "vcpu_id" for virtual CPU ID. For more complete view, the third patch is the change in perf tool. It dynamically detects trace nodes under sysfs and decide to use the version 2's trace events or rollback to use original events. This patch set has been tested with mainline kernel on Arm64 Ampere Altra platform. Note: I used checkpatch.pl to validate patches format and observed it reports error for second patch for adding trace events; since the trace event definition uses its own coding style, I just keep as it is. [1] https://lore.kernel.org/lkml/1560330526-15468-2-git-send-email-yuzenghui@huawei.com/ [2] https://lore.kernel.org/lkml/20200917003645.689665-1-sergey.senozhatsky@gmail.com/ [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/sched/core.c?id=a056a5bed7fa67706574b00cf1122c38596b2be1 Leo Yan (3): KVM: arm64: Dynamically register callback for tracepoints KVM: arm64: Add trace events with field 'vcpu_id' perf arm64: Support virtual CPU ID for kvm-stat arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 4 +- arch/arm64/kvm/trace.c | 35 +++++++++++++++++ arch/arm64/kvm/trace_arm.h | 53 ++++++++++++++++++++++++++ tools/perf/arch/arm64/util/kvm-stat.c | 54 ++++++++++++++++++++++++--- 5 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 arch/arm64/kvm/trace.c