From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 6CDFEC432C3 for ; Thu, 14 Nov 2019 07:13:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41069206E6 for ; Thu, 14 Nov 2019 07:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbfKNHNa (ORCPT ); Thu, 14 Nov 2019 02:13:30 -0500 Received: from mga05.intel.com ([192.55.52.43]:19847 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbfKNHN3 (ORCPT ); Thu, 14 Nov 2019 02:13:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 23:13:29 -0800 X-IronPort-AV: E=Sophos;i="5.68,302,1569308400"; d="scan'208";a="198721968" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.239.196.126]) ([10.239.196.126]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Nov 2019 23:13:25 -0800 Subject: Re: [PATCH v4 5/6] KVM: x86/vPMU: Reuse perf_event to avoid unnecessary pmc_reprogram_counter To: Wanpeng Li Cc: Peter Zijlstra , Paolo Bonzini , Sean Christopherson , Jim Mattson , Wanpeng Li , Alexander Shishkin , Arnaldo Carvalho de Melo , Borislav Petkov , Ingo Molnar , Jiri Olsa , Joerg Roedel , Namhyung Kim , Thomas Gleixner , Vitaly Kuznetsov , kan.liang@intel.com, wei.w.wang@intel.com, LKML , kvm References: <20191027105243.34339-1-like.xu@linux.intel.com> <20191027105243.34339-6-like.xu@linux.intel.com> From: Like Xu Organization: Intel OTC Message-ID: Date: Thu, 14 Nov 2019 15:13:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Wanpeng, On 2019/11/14 11:51, Wanpeng Li wrote: > On Mon, 28 Oct 2019 at 21:06, Like Xu wrote: >> >> The perf_event_create_kernel_counter() in the pmc_reprogram_counter() is >> a heavyweight and high-frequency operation, especially when host disables >> the watchdog (maximum 21000000 ns) which leads to an unacceptable latency > > Why when host disables the watchdog, > perf_event_create_kernel_counter() is more heavyweight and > high-frequency operation? > > Wanpeng > - Fist, let me assume you do have experienced the fact that the perf behavior on guest for multiple hardware events is extremely sluggish when you disable watchdog on host. The setting of host watchdog is the uncontrollability the patch series wants to eliminate for vPMU users. - Disabling host watchdog brings higher frequency is imprecise. In legacy vPMU code, the operation is high-frequency regardless of the host watchdog setting. The exact frequency depends on perf sampling frequency and guest pmu driver pattern. - The sched_clock() time consumed by perf_event_create_kernel_counter() is tested on various x86 platforms and the values suddenly become larger when and only when host disables watchdog. Sometimes watchdog damages the accuracy. In the early stages of exploration, we found if host disables watchdog, the synchronize_rcu() from account_event() in perf_event_alloc() becomes much more heavyweight and it seems to be a general necessary mechanism. The deeper reason behind this is undefined. Thanks, Like Xu