Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2202379rdf; Mon, 6 Nov 2023 07:31:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpfIMeBMxiVC4WyW9x6OB94Y76QJsa8V3iLhNgzgp4awySm1dIqBZYpTrrzqUfZ+CMZZ3o X-Received: by 2002:a17:902:c1cb:b0:1cc:29ed:96ae with SMTP id c11-20020a170902c1cb00b001cc29ed96aemr27879505plc.41.1699284688383; Mon, 06 Nov 2023 07:31:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699284688; cv=none; d=google.com; s=arc-20160816; b=sdK8axA+bM+bcoThMX0jOU0e6ONMR+iebW8+ORCQwHjn3LomT9zxzO5qc4dMDQwAGn gcLwXkrVIEAEZ4hr/4QkNu3GeJDr7ZIS6F7TS7WeSoaZEf+/P6F6qUxWAtAqClWVberK 2sxclIrBzqwfMrnj9JPNU5yIwxWrz9K3OvcbuBA18XhPw8TUZ/NWbkYENjwwJGn0MI1c VQlDhtULmSgWdrxZvQLXiCziKP4/G7SBNkfjb3N7PVGzk8TgqXUjZtCtzCrX9pDdcrk3 x3c5v5iVFToY9kQqsGT8ixzCSpVMsMNevelCApa/TKP11wLjI/ljopkA8mJZwJO5lAbV L75w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=W4pgWCBKNlAdji/TNyedAYk8usKNcfQXaSq+BvgKk6s=; fh=AEB/Qw9IonDhjFU/1n2f/mT5c/qVgyTY2b2Iv+zVo5Y=; b=n4QcTlR/WHGXDUxYluJsFbR2w58IRrwO/TsXnZav1EZR08ZiYB5cHytsyQoIdsR7bI vSt5IClHFt6khYZz1zY7XGa/m8UXO34xHuZwsw/b328Xd1w3XfIgo1UEQKy54mlk7AKx H0EdKK9A12Hz70jJhxNyppe1bKc6WouZhIVKcq+lSSGLuMk9XVvtqvv8bbFtYqkCW5ez A5iYT0c2Udl5z6cBFnkH2ykMCxzefhKK6U+NBVx5PO+2BJBVF4tMlDC9yJRElVtxvZya e233M2UWmcVaqkuBz2K8RWfDOlcEIW/5lLoM6mcRpxa4djjG6D9B0svNC+uyZVnnaoPk MGMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VS2mrP9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kh3-20020a170903064300b001c7615a8e09si7968707plb.593.2023.11.06.07.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:31:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VS2mrP9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 445078069DBE; Mon, 6 Nov 2023 07:31:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbjKFPbY (ORCPT + 99 others); Mon, 6 Nov 2023 10:31:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjKFPbX (ORCPT ); Mon, 6 Nov 2023 10:31:23 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0065C107 for ; Mon, 6 Nov 2023 07:31:20 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1cc23f2226bso30613375ad.2 for ; Mon, 06 Nov 2023 07:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699284680; x=1699889480; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=W4pgWCBKNlAdji/TNyedAYk8usKNcfQXaSq+BvgKk6s=; b=VS2mrP9JMObCyBc3U1bEWv/lJ3A/ztpYHfW2X8kYcyH8DlefIF2Q68JIoPHsE1HWZj XzIetZ3Uj9A9aIk7gTGVUofPTSKOYlXfhZj2V7f1yb2bSWgRhrkSv+j/fK7AyzBH+6nP htCiW4OTQTAoxnoq7XGc3bNae+4kwFWvOXgAfteefJCKcAqkGMK+yH8i0tN5kHCpH+p4 iilEXbElOIQOoAUbiEhzSLs4nKdK0ICIORxhIh+R2lUVmD5tAi7vQMcsRvKQt3QgHI2h H+/8i8PQ8gp9nGbXs8hZCTU8ZWVs0+7S4y6vKRNKP1vTxRQPKYSRqXXWiw/o7RvS+exH 9PTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699284680; x=1699889480; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=W4pgWCBKNlAdji/TNyedAYk8usKNcfQXaSq+BvgKk6s=; b=tmc9aF8HCOX40fZAnh4irjG6Y4/IQrJ4dS/+R52ztxmESYWSTZY+GdOxNW3b4lDunQ vI5QRYemN6nEDJxpG6DXHaOXDdWBV7HvXSXDMXUmvLIR5mdtKr0EX08RBQS00hz4zU0F qH+nz5+230qTMraWcUw3rNs2Bq1sSjJhGGa2QoRfyrEFQQnXPozafHf2Inyfq8ExMJGK tqA+s9M/kHa4C8VnoeNd+WI27kQnW+Br3EXV3SibGHFXvYNbUD2bHqbKiW6tMjocm9Ky JFf8S7/UZ2hO5vgMLMtUPe7QMGHfqTxDT3X6oz1MjXrx4dk84wmYEifzGpbggkdKasR3 AFEg== X-Gm-Message-State: AOJu0Yz+dhJjYlCXw2KpNjdjEo1QfunaW0BaYNXJltI1Iep+TAERKze+ WvuaD/1JWRFzhvxB4t5hR2USdgcd3xo= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ac8e:b0:1cc:30cf:eae6 with SMTP id h14-20020a170902ac8e00b001cc30cfeae6mr498273plr.10.1699284680259; Mon, 06 Nov 2023 07:31:20 -0800 (PST) Date: Mon, 6 Nov 2023 07:31:18 -0800 In-Reply-To: Mime-Version: 1.0 References: <20231104000239.367005-1-seanjc@google.com> <20231104000239.367005-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH v6 02/20] KVM: x86/pmu: Don't enumerate support for fixed counters KVM can't virtualize From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kan Liang , Dapeng Mi , Jinrong Liang , Like Xu , Aaron Lewis Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 07:31:27 -0800 (PST) On Sat, Nov 04, 2023, Jim Mattson wrote: > On Fri, Nov 3, 2023 at 5:02=E2=80=AFPM Sean Christopherson wrote: > > > > Hide fixed counters for which perf is incapable of creating the associa= ted > > architectural event. Except for the so called pseudo-architectural eve= nt > > for counting TSC reference cycle, KVM virtualizes fixed counters by > > creating a perf event for the associated general purpose architectural > > event. If the associated event isn't supported in hardware, KVM can't > > actually virtualize the fixed counter because perf will likely not prog= ram > > up the correct event. >=20 > Won't it? My understanding was that perf preferred to use a fixed > counter when there was a choice of fixed or general purpose counter. > Unless the fixed counter is already assigned to a perf_event, KVM's > request should be satisfied by assigning the fixed counter. >=20 > > Note, this issue is almost certainly limited to running KVM on a funky > > virtual CPU model, no known real hardware has an asymmetric PMU where a > > fixed counter is supported but the associated architectural event is no= t. >=20 > This seems like a fix looking for a problem. Has the "problem" > actually been encountered? Heh, yes, I "encountered" the problem in a curated VM I created. But I com= pletely agree that this is unnecessary, especially since odds are very, very good t= hat requesting the architectural general purpose encoding will still work. E.g= . in my goofy setup, the underlying hardware does support the architectural even= t and so even if perf doesn't use the fixed counter for whatever reason, the GP c= ounter will still count the right event.