Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A73C432BE for ; Thu, 2 Sep 2021 06:20:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2BF10610C9 for ; Thu, 2 Sep 2021 06:20:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2BF10610C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.176938.322005 (Exim 4.92) (envelope-from ) id 1mLg4w-00060H-3C; Thu, 02 Sep 2021 06:20:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 176938.322005; Thu, 02 Sep 2021 06:20:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mLg4v-0005zU-VR; Thu, 02 Sep 2021 06:20:01 +0000 Received: by outflank-mailman (input) for mailman id 176938; Thu, 02 Sep 2021 06:20:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mLg4u-0005t9-4L for xen-devel@lists.xenproject.org; Thu, 02 Sep 2021 06:20:00 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id cc3910cd-0bb5-11ec-ae3e-12813bfff9fa; Thu, 02 Sep 2021 06:19:58 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F8BB1FB; Wed, 1 Sep 2021 23:19:58 -0700 (PDT) Received: from [10.57.19.246] (unknown [10.57.19.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CFB03F766; Wed, 1 Sep 2021 23:19:56 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cc3910cd-0bb5-11ec-ae3e-12813bfff9fa Subject: Re: [PATCH] xen/arm: Introduce pmu_access parameter To: Stefano Stabellini , Julien Grall Cc: Bertrand Marquis , "xen-devel@lists.xenproject.org" , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu , Volodymyr Babchuk References: <20210901124308.31573-1-michal.orzel@arm.com> <599515f0-4b8a-3a71-caea-b17ec27c9123@xen.org> <44B48162-EB44-4295-9629-2D95A40D7232@arm.com> <46e36ba5-8b3d-2d43-6297-b92d2654ab72@xen.org> From: Michal Orzel Message-ID: <0c527a57-44f2-d888-3210-644ea3aa940e@arm.com> Date: Thu, 2 Sep 2021 08:19:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Hi Stefano, On 01.09.2021 19:54, Stefano Stabellini wrote: > On Wed, 1 Sep 2021, Julien Grall wrote: >> On 01/09/2021 14:10, Bertrand Marquis wrote: >>>> On 1 Sep 2021, at 13:55, Julien Grall wrote: >>>> >>>> Hi, >>>> >>>> On 01/09/2021 13:43, Michal Orzel wrote: >>>>> Introduce new Xen command line parameter called "pmu_access". >>>>> The default value is "trap": Xen traps PMU accesses. >>>>> In case of setting pmu_access to "native", Xen does not trap >>>>> PMU accesses allowing all the guests to access PMU registers. >>>>> However, guests cannot make use of PMU overflow interrupts as >>>>> PMU uses PPI which Xen cannot route to guests. >>>>> This option is only intended for development and testing purposes. >>>>> Do not use this in production system. >>>> I am afraid your option is not safe even in development system as a vCPU >>>> may move between pCPUs. >>>> >>>> However, even if we restricted the use to pinned vCPU *and* dedicated >>>> pCPU, I am not convinced that exposing an half backed PMU (the overflow >>>> interrupt would not work) to the guest is the right solution. This likely >>>> means the guest OS would need to be modified and therefore the usage of >>>> this option is fairly limited. >>>> >>>> So I think the first steps are: >>>> 1) Make the PPI work. There was some attempt in the past for it on >>>> xen-devel. You could have a look. >>>> 2) Provide PMU bindings >>>> >>>> With that in place, we can discuss how to expose the PMU even if it is >>>> unsafe in some conditions. >>> >>> With those limitations, using the PMU to monitor the system performances or >>> on some specific use cases is still really useful. >>> We are using that to do some benchmarks of Xen or of some applications to >>> compare the behaviour to a native system or >>> analyse the performances of Xen itself (hypercalls,context switch …etc) > > I also already had to write a patch almost exactly like this one to > provide to customers a few months back. > > >> I understand this is useful for some setup and I am not trying to say we >> should not have a way to expose the PMU (even unsafely) in upstream. However, >> I think the option as it stands is too wide (this should be a per domain knob) >> and we should properly expose the PMU (interrupts, bindings...). > > I have never used PMU directly myself, only provided a patch similar to > this one. But as far as I could tell the users were fully satisfied > with it and it had no interrupts support either. Could it be that > interrupts are not actually needed to read the perf counters, which is > probably what users care about? > Most of the people using PMU do not need interrupt as PMU can only be programmed to generate overflow interrupt request when a counter overflows. If we want to catch counter overflow without using interrupt, we can check if overflow status bit is set to 1 in PMOVSCLR register. > In regards to "this should be a per domain knob", in reality if you are > doing PMU experiments you don't care if only one or all domains have > access: you are working in a controlled environment trying to figure out > if your setup meets the timing requirements. There are no security or > safety concerns (those are different experiments) and there is no > interference problems in the sense of multiple domains trying to access > PMU at the same time -- you control the domains you decide which one is > accessing them. > > So I am in favor of a patch like this one because it actually satisfy > our requirements. Even if we had per-domain support and interrupts > support, I don't think they would end up being used. >