Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp390143rdh; Thu, 26 Oct 2023 05:19:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFh98WJOjiv4pSTDPItnaLYIgcuM2as9qoXbDPe8+HHoCVbOnHTf/hWWO4+DKIAeePhMkHi X-Received: by 2002:a05:6830:719d:b0:6b8:9483:35ba with SMTP id el29-20020a056830719d00b006b8948335bamr23456524otb.24.1698322765900; Thu, 26 Oct 2023 05:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698322765; cv=none; d=google.com; s=arc-20160816; b=qp+znag9GEoYLWV8nbr810BzFCXVp/wOQmsUfIKR86yn4gs1IKC1mLrKEan7eQkwKl 2tyPPosJ7S3F6fs4YhUFYmQWXzlyaxBxmC5yu2TCV2TQMmRFEPpKRrAETIz9GleCX4sN +Qdvb7QwhStEzsJb02mw9ZUn1JuKbBMpmtyUs9Lek/aUfGIIhGBtobKf0c2RSBlotSO1 2kmz+QfpseUjs918aqExq5iNTMxnqfwgq9bf3+JjXEJfjFnQrJYdFOKQFjQjEFAXvcJF w5AB/OtVGYlB0k1ethrJn4UtTwRnEZ/u3CecmO4zTG1BSz8d19r4JS4ynmGmgqyy+Lf9 vMQA== 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:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mn9vwEQwhu04QoIQoViUo1uyYhhZK+omIbWYXKZt2G0=; fh=uHS0/9G41/xc7SfwaImOsh2CmuncZhRxHxVdkkWVxmc=; b=CZtRYkMj46FIWTe7N/rnhJyms3/+LJJ6vlV9eP7lx4CMVs9WDnMzTanLRqHO03e03h GrNFnk1pDxv9246+YUltPSREYwxpAf9cGSVBgJBnQoS3Ew1Mn7xBa76nQ2j+nLhfYagY 5+vedorDCgq9k8GTmHMKQS83BLttn8ViSnKzSg3ZhMhn9L7t86g6eswLqYydrBU45xSB Z4mUTKc/PzvOzy6VyS8GytkU0ByxIv+9vQfqehMFwwHD13Nzrv61eprzr+BaQ2icpxRx 5QTYxDWth19pvg00Ye7tMTiGHYMmzcPXeLHD0uMCYD/2vmblbZdxKzuYGee7c5PEzG4x gq7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4vBAeB6+; 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 j5-20020a0dc705000000b005839913d489si12900240ywd.551.2023.10.26.05.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 05:19:25 -0700 (PDT) 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=4vBAeB6+; 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 E6DC68218229; Thu, 26 Oct 2023 05:19:23 -0700 (PDT) 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 S234955AbjJZMTW (ORCPT + 99 others); Thu, 26 Oct 2023 08:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbjJZMTV (ORCPT ); Thu, 26 Oct 2023 08:19:21 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668801B3 for ; Thu, 26 Oct 2023 05:19:16 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40837124e1cso82145e9.0 for ; Thu, 26 Oct 2023 05:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698322754; x=1698927554; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mn9vwEQwhu04QoIQoViUo1uyYhhZK+omIbWYXKZt2G0=; b=4vBAeB6+dWymdQ7lx+OaLwT/lkizkiOnU6+wLGKllSzf8B74PxqMH7t/8kcIe2oQ3d Hpo0opEQuZ9MvERHrpkQToDoS91/pbXozZcviJWfSVbiOgKu3vNY8O8pACF+Se3GB23V IXqXzDfs3aAdrl59UdgIhG4UC6elVK4HgMR8WpHRsvDaxhi3YltsoT7bbRlEIYYy4JMX kMKPtzi7wp+NIlgxRmDyAh0WX24nlcfb2398cSjF8at3UIXqvhupHKJQD6e5fMJAl8Md Z62zjmbADQLqY8BZEfC1shsWw7u8//+BAuHujn3yiiY3GmJmeyDDLDUqBHgwNf+X0e8g twvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698322754; x=1698927554; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mn9vwEQwhu04QoIQoViUo1uyYhhZK+omIbWYXKZt2G0=; b=tpF+VSe8Da8DXIIQYMmA+HriNsSoYTgJdhQvRdQL77im/Ip7Lh/GLqFNprvyAxlE66 U93cpqkuptSvvau942oze44FSUdTWVVlSohT/b3Bq1FdMTZ7pqHnrK5MkqOBvEBlqVE4 BKWegX4j5NG7mwpeoTVUVh8tieaR1sMSpCX7ZNI+39sJ9WNlAUb5HP9G6zcOV+b+926a hvAFm4KoUkokr8lvjLfNZcnAfSH2tx1yHo3tCtgLPGVcSpK8ECyDnMJyCZkiEaQ/NMXG 2TcpZKDDFXo2OeiZ6OFaEzFCb0U54G4C0m/eeiC0J3uwYIzRRVCBGot7TVzbtoBs1MyS ZgiA== X-Gm-Message-State: AOJu0YzZi0T+pdae6OpWcetEJO290OkDFQpMJZBTctmbJ5+HseFhXL/6 n/aXNvovxhaGV/a8bqwGQ5bIcfs6BmusqXcIzMp1ww== X-Received: by 2002:a05:600c:3c96:b0:404:74f8:f47c with SMTP id bg22-20020a05600c3c9600b0040474f8f47cmr225576wmb.5.1698322754434; Thu, 26 Oct 2023 05:19:14 -0700 (PDT) MIME-Version: 1.0 References: <20231024075748.1675382-1-dapeng1.mi@linux.intel.com> <20231024075748.1675382-3-dapeng1.mi@linux.intel.com> <6132ba52-fdf1-4680-9e4e-5ea2fcb63b3c@linux.intel.com> <99684975-6317-4233-b87b-14ca731b335a@linux.intel.com> In-Reply-To: <99684975-6317-4233-b87b-14ca731b335a@linux.intel.com> From: Jim Mattson Date: Thu, 26 Oct 2023 05:19:01 -0700 Message-ID: Subject: Re: [kvm-unit-tests Patch 2/5] x86: pmu: Change the minimum value of llc_misses event to 0 To: "Mi, Dapeng" Cc: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Mingwei Zhang , Like Xu , Dapeng Mi Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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]); Thu, 26 Oct 2023 05:19:24 -0700 (PDT) On Wed, Oct 25, 2023 at 7:14=E2=80=AFPM Mi, Dapeng wrote: > > > On 10/25/2023 8:35 PM, Jim Mattson wrote: > > On Wed, Oct 25, 2023 at 4:23=E2=80=AFAM Mi, Dapeng wrote: > >> > >> On 10/24/2023 9:03 PM, Jim Mattson wrote: > >>> On Tue, Oct 24, 2023 at 12:51=E2=80=AFAM Dapeng Mi wrote: > >>>> Along with the CPU HW's upgrade and optimization, the count of LLC > >>>> misses event for running loop() helper could be 0 just like seen on > >>>> Sapphire Rapids. > >>>> > >>>> So modify the lower limit of possible count range for LLC misses > >>>> events to 0 to avoid LLC misses event test failure on Sapphire Rapid= s. > >>> I'm not convinced that these tests are really indicative of whether o= r > >>> not the PMU is working properly. If 0 is allowed for llc misses, for > >>> instance, doesn't this sub-test pass even when the PMU is disabled? > >>> > >>> Surely, we can do better. > >> > >> Considering the testing workload is just a simple adding loop, it's > >> reasonable and possible that it gets a 0 result for LLC misses and > >> branch misses events. Yeah, I agree the 0 count makes the results not = so > >> credible. If we want to avoid these 0 count values, we may have to > >> complicate the workload, such as adding flush cache instructions, or > >> something like that (I'm not sure if there are instructions which can > >> force branch misses). How's your idea about this? > > CLFLUSH is probably a good way to ensure cache misses. IBPB may be a > > good way to ensure branch mispredictions, or IBRS on parts without > > eIBRS. > > > Thanks Jim for the information. I'm not familiar with IBPB/IBRS > instructions, but just a glance, it looks there two instructions are > some kind of advanced instructions, Not all Intel CPUs support these > instructions and not sure if AMD has similar instructions. It would be > better if there are more generic instruction to trigger branch miss. > Anyway I would look at the details and come back again. IBPB and IBRS are not instructions. IBPB (indirect branch predictor barrier) is triggered by setting bit 0 of the IA32_PRED_CMD MSR. IBRS (indirect branch restricted speculation) is triggered by setting bit 0 of the IA32_SPEC_CTRL MSR. It is true that the desired behavior of IBRS (causing branch mispredictions) is only exhibited by certain older parts. However, IBPB is now universally available, as it is necessary to mitigate many speculative execution attacks. For Intel documentation, see https://www.intel.com/content/www/us/en/developer/articles/technical/softwa= re-security-guidance/technical-documentation/cpuid-enumeration-and-architec= tural-msrs.html. If you don't want to use these, you could train a branch to go one way prior to measurement, and then arrange for the branch under test go the other way. > >>>> Signed-off-by: Dapeng Mi > >>>> --- > >>>> x86/pmu.c | 2 +- > >>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>> > >>>> diff --git a/x86/pmu.c b/x86/pmu.c > >>>> index 0def28695c70..7443fdab5c8a 100644 > >>>> --- a/x86/pmu.c > >>>> +++ b/x86/pmu.c > >>>> @@ -35,7 +35,7 @@ struct pmu_event { > >>>> {"instructions", 0x00c0, 10*N, 10.2*N}, > >>>> {"ref cycles", 0x013c, 1*N, 30*N}, > >>>> {"llc references", 0x4f2e, 1, 2*N}, > >>>> - {"llc misses", 0x412e, 1, 1*N}, > >>>> + {"llc misses", 0x412e, 0, 1*N}, > >>>> {"branches", 0x00c4, 1*N, 1.1*N}, > >>>> {"branch misses", 0x00c5, 0, 0.1*N}, > >>>> }, amd_gp_events[] =3D { > >>>> -- > >>>> 2.34.1 > >>>>