Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp512979rdb; Sat, 17 Feb 2024 21:45:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXH3bL6mlZkznRR5ETR1JD4ChUtwEu4oiPQJDMhIw2aoccyJDTvoAaDxuLcrycymPwYO2jlMrioRL1eLoeZW9Nrgd7zCwcVVFZcEI2fYg== X-Google-Smtp-Source: AGHT+IFATvRD876K/pUJPX0IJrv5ziHObcvXYQyybvCCKeaXSIiqBLUuTCftUxN9ZsingiUdQ5oQ X-Received: by 2002:a17:903:2b07:b0:1db:e6f6:e2a0 with SMTP id mc7-20020a1709032b0700b001dbe6f6e2a0mr827262plb.31.1708235108862; Sat, 17 Feb 2024 21:45:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708235108; cv=pass; d=google.com; s=arc-20160816; b=aalG5ipF/HG9HFGb/rFusXD6EQ85Nk5yZRAPhOzuQNno3VcFAAfbIzAbYoGYgl6p44 HcNkARpUjK6lvbRPIHqzgRZhI192vvITSidd74rsuWIgYsX6snW9nxdoaUUS2BPPsk2d Q2cXYUdVtmOg7wbCun/AFsNtDTfT2xDTDsVhLZBvn/W5to9bHwwEbeLMzAV1mo5qdMR3 CcxqVQ8oEpLtTYE/4Milq5A/l+Y90BIRA73gtDxjYdpja5MaZnhSQHGHTpehfA4eRxpL mw9fi7P2EN0Gan9Tbi2bhib0Kt9f0QVd1FTKM10x/uMsXVcEXNZMcfyO8KSrNMOF7O2O 7HIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Pq8ozQ4trpQ1tiJvhn5gCAOjR0F+RoVhy9w4Ug2zorI=; fh=Nt1Nr04Ofg+mPcN4Ar0/gcq2Sz8eYMIFmSDvi3ypb5w=; b=p4VtXkusZH01A7b90ePPeJhcHaEwTqKarqQnwFC7cbngx4bikPMWckYDl5eIIWyLgq 5MKVzGr8DvyYM5ynHZ0QL8r3WLlPxPIIoTl0XeYx46bOghnifwig0teQcuC24G9obL4y mji8xz6WTCTYbIN2Vm9uAOhCS/PUGhUzFdDAr17t1vSOyTS1/ymCI4491Kqfz4EK7bzJ sqskyposkPxeMAeZLofBGCwoWuvIw+K86/DlKKWZggH7Ti/4k8nwyHKhQXXZgbk4+VvC OzSC5isThLKCYbbLkT3DP8zf5+9asTVxowctIEn0iQ9p1cGvJ6cHbw5OH+T6wEc1i8q3 OGww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RVTZYtJA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l13-20020a170903120d00b001da1fe7cacasi2450676plh.370.2024.02.17.21.45.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 21:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RVTZYtJA; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-70174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0DBB92830FE for ; Sun, 18 Feb 2024 03:17:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3F651865; Sun, 18 Feb 2024 03:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RVTZYtJA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEAF215C0; Sun, 18 Feb 2024 03:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708226220; cv=none; b=tyxnUSa5O+cM2AbCx031tKkAN8P1CczwCJtEWzKfibfvETPfRLZE/ppgp3akMey9ZoVFP1PUAfClQJ6/XL2mG+M9bvsLWgM/sbHKpcXJd/zJKIfU2kdJCLOpCxwFJPHnLusNSVInXkv0NAtrtTLg53hb0uj58zXXWX/kwLoMgQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708226220; c=relaxed/simple; bh=DeGDrMAgGcdQj3OmlPemYT17RoDy097NuhgcWvnkTOw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qsWZevX5BjcxZD4wRjlu5p0SeB7c3MRFvLmkaM9aHKuiJ7m1+coEGwAphgwb4PEFHgiwpA93sRtXjFWZHNquS+6SAwxRifyW+E/D0CQHI7NP6I1RfEpLuCdQSCGcL6rWI0w9n0fEagBrN/R1kMRCBxOuJ1zp0EZNDK0pRC6VxUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RVTZYtJA; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708226220; x=1739762220; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=DeGDrMAgGcdQj3OmlPemYT17RoDy097NuhgcWvnkTOw=; b=RVTZYtJAguZcY7TMWhKkUA5q0rbB6uwvaU8qMBIl2cLY+zDsGogirdVR TRgh3hBPyOdHsiU6muZNyMcuE3aUNacJsCLFcXYNt6oa7CTwmp1hD+uMT t01oKqCbV6GjeRmSb6yTSCZICgccoPuCGhhE2dcnnOYCmVBFX50DDu9rp 8WPGV9ip7UEYAmnbZxsBfaoc0owON890tmz1wcG9np1g7hhLO9IPo7qMQ ZzU6ah4vl4DEjDfpoUtNLFEfLBUxIzT6ZSBXiyZ6UxAxSwqMlwQTcknNa lYrdLzNPAENPf0eFnLLxvwzBZLyu5PgDU7xhDal6levj5k3Z/YzDX+Ek+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10987"; a="19749191" X-IronPort-AV: E=Sophos;i="6.06,167,1705392000"; d="scan'208";a="19749191" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2024 19:16:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,167,1705392000"; d="scan'208";a="8855672" Received: from dapengmi-mobl1.ccr.corp.intel.com (HELO [10.93.20.184]) ([10.93.20.184]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2024 19:16:56 -0800 Message-ID: Date: Sun, 18 Feb 2024 11:16:53 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] KVM: selftests: Test top-down slots event To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kan Liang , Jim Mattson , Jinrong Liang , Aaron Lewis , Dapeng Mi References: <20240201061505.2027804-1-dapeng1.mi@linux.intel.com> <95c3dc22-2d40-46fc-bc4d-8206b002e0a1@linux.intel.com> Content-Language: en-US From: "Mi, Dapeng" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/3/2024 1:24 AM, Sean Christopherson wrote: > On Fri, Feb 02, 2024, Dapeng Mi wrote: >> On 2/2/2024 2:02 AM, Sean Christopherson wrote: >>> On Thu, Feb 01, 2024, Dapeng Mi wrote: >>>> Although the fixed counter 3 and the exclusive pseudo slots events is >>>> not supported by KVM yet, the architectural slots event is supported by >>>> KVM and can be programed on any GP counter. Thus add validation for this >>>> architectural slots event. >>>> >>>> Top-down slots event "counts the total number of available slots for an >>>> unhalted logical processor, and increments by machine-width of the >>>> narrowest pipeline as employed by the Top-down Microarchitecture >>>> Analysis method." So suppose the measured count of slots event would be >>>> always larger than 0. >>> Please translate that into something non-perf folks can understand. I know what >>> a pipeline slot is, and I know a dictionary's definition of "available" is, but I >>> still have no idea what this event actually counts. In other words, I want a >>> precise definition of exactly what constitutes an "available slot", in verbiage >>> that anyone with basic understanding of x86 architectures can follow after reading >>> the whitepaper[*], which is helpful for understanding the concepts, but doesn't >>> crisply explain what this event counts. >>> >>> Examples of when a slot is available vs. unavailable would be extremely helpful. >>> >>> [*] https://www.intel.com/content/www/us/en/docs/vtune-profiler/cookbook/2023-0/top-down-microarchitecture-analysis-method.html >> Yeah, indeed, 'slots' is not easily understood from its literal meaning. I >> also took some time to understand it when I look at this event for the first >> time. Simply speaking, slots is an abstract concept which indicates how many >> uops (decoded from instructions) can be processed simultaneously (per cycle) >> on HW. we assume there is a classic 5-stage pipeline, fetch, decode, >> execute, memory access and register writeback. In topdown >> micro-architectural analysis method, the former two stages (fetch/decode) is >> called front-end and the last three stages are called back-end. >> >> In modern Intel processors, a complicated instruction could be decoded into >> several uops (micro-operations) and so these uops can be processed >> simultaneously and then improve the performance. Thus, assume a processor >> can decode and dispatch 4 uops in front-end and execute 4 uops in back-end >> simultaneously (per-cycle), so we would say this processor has 4 topdown >> slots per-cycle. If a slot is spare and can be used to process new uop, we >> say it's available, but if a slot is occupied by a uop for several cycles >> and not retired (maybe blocked by memory access), we say this slot is stall >> and unavailable. > In that case, can't the test assert that the count is at least NUM_INSNS_RETIRED? > AFAIK, none of the sequences in the measured code can be fused, i.e. the test can > assert that every instruction requires at least one uop, and IIUC, actually > executing a uop requires an available slot at _some_ time. Yeah, looks the instruction sequence can't be marco-fused on x86 platforms, the slots count should be equal or larger than NUM_INSNS_RETIRED. > > diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c > index ae5f6042f1e8..29609b52f8fa 100644 > --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c > +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c > @@ -119,6 +119,9 @@ static void guest_assert_event_count(uint8_t idx, > case INTEL_ARCH_REFERENCE_CYCLES_INDEX: > GUEST_ASSERT_NE(count, 0); > break; > + case INTEL_ARCH_TOPDOWN_SLOTS_INDEX: > + GUEST_ASSERT(count >= NUM_INSNS_RETIRED); > + break; > default: > break; > }