Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2842166ybc; Wed, 13 Nov 2019 23:14:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzYaHr3N3Ae8JQdcmm6JuOHLuJwbOkfmj4eWdSR4bSdz4R0LepG1YJSIVmWHrq66bk6sj1c X-Received: by 2002:a50:9353:: with SMTP id n19mr8311300eda.258.1573715676968; Wed, 13 Nov 2019 23:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573715676; cv=none; d=google.com; s=arc-20160816; b=b/wekG3ZgQwuCFZajPBYWtNgwXZQt0r0Vs7KYRfHCXPj94THvVXntrJCjDtQBudA40 z4wIZyTfw3ySKrpa/kUyuYAHeKpu+d7pbYcHNEfMkgsl3RmUw7bi8ookhr8py1GC326x dXC2NNCFLjgZhyq40qBnoXJuaCTlEfgL7jMFKjdlG6NL7x4qCcIo4hwky9XSvWoM3Gci TG7v6R6MZFLgAI/64hnfPrttUL5sA9z+J0rFiA7BXIx8YELgPBfat6BsqOLjESnvxig2 rptuNkDpRzkaU1AjJ14HQQWjAS75jcTPbY/EAzfEjZw2R7IIDlqXVEZJlBOqghkO4gSF 9fCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=LtilG2k3yGQNFesWoA+thS0Brt7jwbJW8UjVuv3DmfY=; b=IWR3vZ/A0+vy3HhsuFW0UlvTqO3fkzVgpE86dHjMm8hKODd9mNJnkboLwWdNXE2zpA P3W/UBBkEAs3XN/UJ9cf83D6WQhtkrC3a0KgJVk+dzriwwDjTYRwiOj4F1KMw8GFaFVF OyfiIG2w1h0hVRFtGavTdUzhTuvnuDLxcj/1ZCofM3mRszYTzq9wmSsfJaMHuUwH0jZm z1hlht17AWAOapPaVvmIgQLiqU/91pJrG4TzgEtzXGISPfQPS2mPWSzKPTnfZ11pemPm Ccv4qPJnPILdZaFtuDE6UbeXr3GZx1rDSUdrsMFVhRrKSAv9skejnIhoJNWQK0Eor/MI OO0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si3126463edc.102.2019.11.13.23.14.11; Wed, 13 Nov 2019 23:14:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725838AbfKNHNa (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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