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 46A0DC636CC for ; Wed, 8 Feb 2023 17:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbjBHRVO (ORCPT ); Wed, 8 Feb 2023 12:21:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjBHRVH (ORCPT ); Wed, 8 Feb 2023 12:21:07 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3F8900C for ; Wed, 8 Feb 2023 09:21:05 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id r8so20087093pls.2 for ; Wed, 08 Feb 2023 09:21:05 -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=InsXA+RguG9WJGEF806uxDmE5GSmGEeKkXmIKDQEC3t7AJPQQr+J2JF+DKSKj57wjy xPQ3lM5ef/h+77E3TeAr6Zv4AGHbVj1nYoGv/xfpq83tlS1JObucek5ZyuEMhQEed0cc gSUCDoMnPX4tlT250O0lpDkkHIOSCCZgvaefsH6bgJ0JjYRcOR8hARrE+tV9sNWknGlq fQdtJ+ub+D3ELQP98SG7n+Hl7j4F/iJ5s8+HoPXrAeOBbADY3i0gU9hM+2YuAsuHDIkW Rm9YWd+x/8glMnrR+LNRnW4bLkvthoe8jHkQ8cncob32lpzaRbqkp8Q/4bV0EifkEJs1 FPpg== X-Gm-Message-State: AO0yUKWcHxdpfqa8hhBqj4Op8R06yXvU8uOMUX8LDb8PzBGAAuJdnhWF 5L1zepf3O04N5VBitvU67j8jBYoWhSJ3sdSC968= 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: linux-kernel@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.