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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 404AEC636D7 for ; Wed, 8 Feb 2023 17:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbjBHRVL (ORCPT ); Wed, 8 Feb 2023 12:21:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbjBHRVH (ORCPT ); Wed, 8 Feb 2023 12:21:07 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F0F79EF0 for ; Wed, 8 Feb 2023 09:21:06 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id j1so13188660pjd.0 for ; Wed, 08 Feb 2023 09:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SevCBdyXjXvSH4omRiXD/fDq6ifdvqidYsrVMN1iQlw=; b=DC8QtD2YeXVbofL1K3rriL4INGSEPrOdo5/LyTggPWJecHfKLNO2cbXvqTZcYICYrw Yp2J3Sn9GgPgr6pNSnRFbQxSctJ3Ef45hs0Pt3t7byi6cW//9dv8G9ZfDza2POogaen4 GabQQGBKfFP/oKhORM4XJCAmHYuI7GNu2svUiCa618/OMPP7GM4jkwd/QyMA4DF1vwxJ +BqnfMSMOiG4d+5MOsvTdDH2AXICwcNCXKplinbkmHGLZr5U4xavxdBheUCoQV94kl1V kGoK6btiuaS8T3dzFH2BLyHgqwttiODVoeOLegb74SUJkEuOM303rPiV1EW8b9MRuS/i Ialw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SevCBdyXjXvSH4omRiXD/fDq6ifdvqidYsrVMN1iQlw=; b=oUPiIdaukQe93SF3fhRJFvJqq355UovgykIxg6AhBTxyO7CEbLN7rbpkB7eAHqaiXl V0dTMeDnHuCrAaQb6f4rbQ5IA6xYqVGPNZlRE9qtAmKDpyRQrT1lOVvreMA/r1XPAfa8 gg3qORzUv+BJcd9VTDkLpkmGA5NM60hr+jX53H1iuNj7rusUDadmhElTr4mc9mjyD1D8 lbnP5h9Bgo3nbJORp2kMnV6a6Nu278dwFaJ8urct7oTR2o+6lTCxQ+jjJfxFLc7wF+Rv 3+XmgJPt3SvtMj7PFURPWWIkaJ0Eyyj9YpiQz/LCS0TKw3ORmGgKaMoC6myN5Scob306 KHdw== X-Gm-Message-State: AO0yUKVYP7Ux+NoEeH6dHvkzFC8qraaabw3S7G/xTKmKNECwN6muIR3O wVacY5XgXImHp4dxzaGWNTmqeA== X-Google-Smtp-Source: AK7set96+zJFQcJ6GKkd7AtudNHL9Hq/NXwLqLQqeOJ2xGUtA3yeXDV/yCXAW7bbSZe4ZAoACokjmA== X-Received: by 2002:a17:903:330f:b0:198:af4f:de12 with SMTP id jk15-20020a170903330f00b00198af4fde12mr283390plb.18.1675876865274; Wed, 08 Feb 2023 09:21:05 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id h38-20020a631226000000b004fb10399da2sm3447480pgl.56.2023.02.08.09.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 09:21:04 -0800 (PST) Date: Wed, 8 Feb 2023 17:21:01 +0000 From: Sean Christopherson To: Kevin Cheng Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan Subject: Re: [PATCH] KVM: selftests: Added eBPF program and selftest to collect vmx exit stat Message-ID: References: <20230126004346.4101944-1-chengkev@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230126004346.4101944-1-chengkev@google.com> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jan 26, 2023, Kevin Cheng wrote: > diff --git a/tools/testing/selftests/kvm/kvm_vmx_exit_ebpf_kern.c b/tools/testing/selftests/kvm/kvm_vmx_exit_ebpf_kern.c > new file mode 100644 > index 000000000000..b9c076f93171 > --- /dev/null > +++ b/tools/testing/selftests/kvm/kvm_vmx_exit_ebpf_kern.c > @@ -0,0 +1,73 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +#include > +#include > +#include > +#include > +#include > + > +struct kvm_vcpu { > + int vcpu_id; > +}; > + > +struct vmx_args { > + __u64 pad; > + unsigned int exit_reason; > + __u32 isa; > + struct kvm_vcpu *vcpu; > +}; > + > +struct stats_map_key { > + __u32 pid; > + __u32 vcpu_id; > + __u32 exit_reason; > +}; > + > +struct { > + __uint(type, BPF_MAP_TYPE_HASH); > + __uint(max_entries, 1024); > + __type(key, struct stats_map_key); > + __type(value, int); > +} vmx_exit_map SEC(".maps"); > + > +struct { > + __uint(type, BPF_MAP_TYPE_HASH); > + __uint(max_entries, 1); > + __type(key, __u32); > + __type(value, __u32); > +} pid_map SEC(".maps"); Can you add comments to explain why maps are used? From our internal discussions, I think I know the answer, but it would be super helpful for others (and me) to explain exactly what this code is doing, and more importantly, why.