From patchwork Mon Mar 13 11:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13172302 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 E0334C61DA4 for ; Mon, 13 Mar 2023 11:42:14 +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:References:In-Reply-To: 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: List-Owner; bh=4iX7SjBmKLIcTiSdt44/VFCtU1Qj7bba7gqVoZtyZIA=; b=JJrR+J/Mg7s4eD kriAATDHvALBpsprlBJ2q6ADmZRhV+mv9X3Twn3c99sIcsELCms5On6KCoXjYAtnP588Z8Rb4zpV0 3E0xyvSfZeb4fTsK9Dm3yngku0oNBmB5O34wvaA556zAYjdHvYS29MUxZQNaX1BAsOsc78z8diBCw lStPRfphrLeD2tyL4z0LT+/jsV8V7RobYb9/xKLoH0mq0BzifPszVRJeADq/6ubrjDH/OLMW2y8Au GnWJe7LwteedfFYrCyVCB0mZ5sR2hvRiXplhdTmKW1JwfRn+I0d3+wuVV75HEaUt4NlA12LL7yXVQ 7PzONJeas4OevfmHrQHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbgY0-005S4Q-50; Mon, 13 Mar 2023 11:41:00 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbgXq-005S0N-7F for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 11:40:51 +0000 Received: by mail-pj1-x1035.google.com with SMTP id kb15so11708803pjb.1 for ; Mon, 13 Mar 2023 04:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678707647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uN7zwUTTarFdEEyI4xavpEstkRipyyWqLXdanEnFXps=; b=ys+dsTy2vh5IRMXu/71+ZQS9QxgiwshRjarRfNFvlFiW60uTbW/yU0lWs+E37FB4qz VSPJHNbcO33USpFkL/q9Adz8H03Zhlk0Q3tIsXazE/d9+g8USW9+18mTPEORCn6mP9wx JF1xEietU5qPMMzExkFMe/Q1aL0hz7F5EL2rxl6sh3mclaE+XDHgej7K0aEcXF/fl2tQ k01DVC2W2dXjTDnptjKW/fRRstP2X41ql9tXQKTnmvbDl/QR3Of8lQuxNexFkTPbfVaN IERCN2JEGZC1Sp4Gw2tU8tbCM85A9E2bqYLC42pgd8r309b/27IP4+aWTujQPYJtuOE2 oWcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678707647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uN7zwUTTarFdEEyI4xavpEstkRipyyWqLXdanEnFXps=; b=f9q5P41PoLyoU6awy/ufSkPSnZ3hhl8PR5cymw3ok2wJ6lBKUgf0GCwNDuSTpAVvJR nBo/eJj7lbIoP4hjAqJ3WK5xcGW0ST9AAogkCu56ajZCkc1eypS2Rv3JCV3S9mK0BgVk EOrVWzw0uSJZnVgAvkW313ZFfjY10EKxl1tf2gW0wpXltfuzYik1d43GkGcCD7g6Ywyn 6px8i19PNTrf0lMjUoGWOtQeCdAKfQK7yA+vqMdC7131qJwlL5niquiutRcyIstdYEPo fa5J0JDZ2SXyD58CP0xK782+rYbO5NJI4mICBtQzeXtc4baKhqKyRUVA3WTqRrc45xM6 9i8g== X-Gm-Message-State: AO0yUKWuQetFYaFrsorUDEe7xuY0Ez1djZ1xMyD4CsPk4i2zbjAHlczy kXLkGkq8yfuEeRaEU/q735Qz9Q== X-Google-Smtp-Source: AK7set9XabVkPC0XB7oQedZ03RgD/a3sbthW1LOnLfUx8dkqc7s8K45x5xD5S1HL2sqJ+GK0fRCdqQ== X-Received: by 2002:a17:90a:ec13:b0:23d:9ae:a49a with SMTP id l19-20020a17090aec1300b0023d09aea49amr2896119pjy.30.1678707647136; Mon, 13 Mar 2023 04:40:47 -0700 (PDT) Received: from leoy-huanghe.lan ([156.59.236.112]) by smtp.gmail.com with ESMTPSA id q21-20020a17090a2e1500b0022335f1dae2sm4281625pjd.22.2023.03.13.04.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 04:40:46 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , John Garry , James Clark , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v4 02/16] perf kvm: Add pointer to 'perf_kvm_stat' in kvm event Date: Mon, 13 Mar 2023 19:40:04 +0800 Message-Id: <20230313114018.543254-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230313114018.543254-1-leo.yan@linaro.org> References: <20230313114018.543254-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_044050_269999_EC441B7E X-CRM114-Status: GOOD ( 14.70 ) 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 Sometimes, handling kvm events needs to base on global variables, e.g. when read event counts we need to know the target vcpu ID; the global variables are stored in structure perf_kvm_stat. This patch adds add a 'perf_kvm_stat' pointer in kvm event structure, it is to be used by later refactoring. Signed-off-by: Leo Yan Reviewed-by: James Clark --- tools/perf/builtin-kvm.c | 6 ++++-- tools/perf/util/kvm-stat.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 0172e5b0d26e..3d2560ec6b37 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -209,7 +209,8 @@ static bool kvm_event_expand(struct kvm_event *event, int vcpu_id) return true; } -static struct kvm_event *kvm_alloc_init_event(struct event_key *key) +static struct kvm_event *kvm_alloc_init_event(struct perf_kvm_stat *kvm, + struct event_key *key) { struct kvm_event *event; @@ -219,6 +220,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key) return NULL; } + event->perf_kvm = kvm; event->key = *key; init_stats(&event->total.stats); return event; @@ -238,7 +240,7 @@ static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm, return event; } - event = kvm_alloc_init_event(key); + event = kvm_alloc_init_event(kvm, key); if (!event) return NULL; diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index 6f0fa05b62b6..40a4b66cfee6 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -24,10 +24,13 @@ struct kvm_event_stats { struct stats stats; }; +struct perf_kvm_stat; + struct kvm_event { struct list_head hash_entry; struct rb_node rb; + struct perf_kvm_stat *perf_kvm; struct event_key key; struct kvm_event_stats total; @@ -44,8 +47,6 @@ struct kvm_event_key { key_cmp_fun key; }; -struct perf_kvm_stat; - struct child_event_ops { void (*get_key)(struct evsel *evsel, struct perf_sample *sample,