Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1473282pxv; Fri, 16 Jul 2021 10:05:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlyhM4iKM7SVMbcrti4Cp+qLmQZqll6rph0L0YwD3+mnd3fVc9odONzC0GFQBHtngnrBbw X-Received: by 2002:a5d:9acb:: with SMTP id x11mr8128262ion.133.1626455140179; Fri, 16 Jul 2021 10:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626455140; cv=none; d=google.com; s=arc-20160816; b=T0pH8s0AKdc7zxzttUwOOuAe+kGiN5aozIV3MGaciTsaqw1lsZMgTl2QkvhQiU29yh eHpeFienxu2Ze88IpFaxr0kSdpUtS7qtsIQzebqmiPbxhHYn23twKpBOJh6zj5PkVk4N NGbYzkRK7wsEYSXea+FsJdFcjlCoVFhEkAh732wAta6NBVqIIqj4CMKNlf8Vk6qVPGcD i06AyyyktnBniiWYZhqwJUFeu3PMLQNKhjAbq8g+G/i8QGB8Ra+s4dVz6WYQZlt3FFBm DQ1lZzrda52tkdBQJjgfGPyumWbgGY+0BtcHypeg/AD6iHsdNiv5f/shfY71Z7jIQf75 olzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l5+sbnoetmWZo2JNdEqLWaey1bVFrcYQ13fx9gWuL+4=; b=X7TSGCErLlRVH6y9BF7SFH2riyWAAnRV7yByo3DwsFSkMTXs4V2Z8tQCRoe9ZFdKAB eWLVyog1uPe8jhROmnN45xlrM7z3ovP3vqQxrqKt2dMZEuGYEOo4JIbijee2Bn66ugi+ 4ewTEkxg3kON2L3YEugV0ZMRyPbbbRhYgnPXKuWOYsKDJSpGtEp0h686mM7oaXLVDQq6 k/AWf4lTWoNRFPF5Y4ZWK0pJw4xFSd++O59Zgn/lX57lSTOugjRMk18jP73D5ljEUbJb foBhoYdcg24nqgJw0tMjEvM6oLVXvgAJXcIxobA7+m8BipPk14nPSNWnW5kjudNdCuK2 KAwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hzZyj0MC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y139si66240iof.100.2021.07.16.10.05.28; Fri, 16 Jul 2021 10:05:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hzZyj0MC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbhGPRGH (ORCPT + 99 others); Fri, 16 Jul 2021 13:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbhGPRGG (ORCPT ); Fri, 16 Jul 2021 13:06:06 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E4CEC06175F for ; Fri, 16 Jul 2021 10:03:10 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id a132so808325oib.6 for ; Fri, 16 Jul 2021 10:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l5+sbnoetmWZo2JNdEqLWaey1bVFrcYQ13fx9gWuL+4=; b=hzZyj0MCkTQEI714kBick4I22s4vTbHAm0FVKUrPd9kWwJaGfZjIiELv12bqvZq1f/ JyD9ZsuD7RVFB15M5VPOX4S3TrL4oO+aIXXEnpNxp7p2HOaZ9krO50+PN8n+t6IZY6XY TkDXHGsWIE2/DpP41ZryBix+V+K11vBkpE+OVxl1VOcmbWVttNQgy5rMZtDlaQkb2fQ+ 3XltIf1JG3/2aOstZtJRm2aGtcGkp4yDkF3HvSIneFTzHKj6VLtkjftx4clrYx+5JSeU Q7vE3+v+uyjJl3hGoa3jOEL+uOEfyike6aJrHLRCaD7pbm5Qd4u7MVIEWmonDyZa2Wg4 qeGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l5+sbnoetmWZo2JNdEqLWaey1bVFrcYQ13fx9gWuL+4=; b=iBDt20D59QXrqCRFCj1XOYxoINSiqFSrc99XWvE5zF3NOJmxcunVZKRr6N8S5QlEdw aspD2FVj8xQhAMRjrKDqS0Nj8fAZQwrMuw82wlUBWh2XuOykpMDca4ECuL7HFFTo7Guu z8cxMExPeksPHdEslGzUiU5RQt2ZB1gcZjYPpAdwo/LJ47ctQTGIRCUpHFtvpnVJ2bhQ 8YC5KvI4mxPj37LHdu/0fw02KMi8m9XbqAQdmRXeSxMu9YqC7ImJZf+Iu0RfroFDX/4Z xK1ndLFBkedNTTIZMSq26WfphiO9FFfXsDGCDkeYSB7sFYFPE9y8LXMP01hdkJBohqTO RpEA== X-Gm-Message-State: AOAM531A+FKQxg84rIjxIuRs+sj0VUOp1ULC3JGGyVz7LeKKNXlhs/kz hO54MsoJMdrRSKuMgsfZ43FFcbYbYV6j7Wf8yBSqiA== X-Received: by 2002:aca:1e07:: with SMTP id m7mr8420800oic.28.1626454989592; Fri, 16 Jul 2021 10:03:09 -0700 (PDT) MIME-Version: 1.0 References: <20210716085325.10300-1-lingshan.zhu@intel.com> In-Reply-To: <20210716085325.10300-1-lingshan.zhu@intel.com> From: Jim Mattson Date: Fri, 16 Jul 2021 10:02:58 -0700 Message-ID: Subject: Re: [PATCH V8 00/18] KVM: x86/pmu: Add *basic* support to enable guest PEBS via DS To: Zhu Lingshan Cc: peterz@infradead.org, pbonzini@redhat.com, bp@alien8.de, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, joro@8bytes.org, kan.liang@linux.intel.com, ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, like.xu.linux@gmail.com, boris.ostrvsky@oracle.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 16, 2021 at 1:54 AM Zhu Lingshan wrote: > > The guest Precise Event Based Sampling (PEBS) feature can provide an > architectural state of the instruction executed after the guest instruction > that exactly caused the event. It needs new hardware facility only available > on Intel Ice Lake Server platforms. This patch set enables the basic PEBS > feature for KVM guests on ICX. > > We can use PEBS feature on the Linux guest like native: > > # echo 0 > /proc/sys/kernel/watchdog (on the host) > # perf record -e instructions:ppp ./br_instr a > # perf record -c 100000 -e instructions:pp ./br_instr a > > To emulate guest PEBS facility for the above perf usages, > we need to implement 2 code paths: > > 1) Fast path > > This is when the host assigned physical PMC has an identical index as the > virtual PMC (e.g. using physical PMC0 to emulate virtual PMC0). > This path is used in most common use cases. > > 2) Slow path > > This is when the host assigned physical PMC has a different index from the > virtual PMC (e.g. using physical PMC1 to emulate virtual PMC0) In this case, > KVM needs to rewrite the PEBS records to change the applicable counter indexes > to the virtual PMC indexes, which would otherwise contain the physical counter > index written by PEBS facility, and switch the counter reset values to the > offset corresponding to the physical counter indexes in the DS data structure. > > The previous version [0] enables both fast path and slow path, which seems > a bit more complex as the first step. In this patchset, we want to start with > the fast path to get the basic guest PEBS enabled while keeping the slow path > disabled. More focused discussion on the slow path [1] is planned to be put to > another patchset in the next step. > > Compared to later versions in subsequent steps, the functionality to support > host-guest PEBS both enabled and the functionality to emulate guest PEBS when > the counter is cross-mapped are missing in this patch set > (neither of these are typical scenarios). I'm not sure exactly what scenarios you're ruling out here. In our environment, we always have to be able to support host-level profiling, whether or not the guest is using the PMU (for PEBS or anything else). Hence, for our *basic* vPMU offering, we only expose two general purpose counters to the guest, so that we can keep two general purpose counters for the host. In this scenario, I would expect cross-mapped counters to be common. Are we going to be able to use this implementation?