Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4382326ybv; Tue, 25 Feb 2020 19:04:30 -0800 (PST) X-Google-Smtp-Source: APXvYqx979X+C1gTMayyT4lRfci2ga2ZrqauK9WwNFra/WDtVJ1fuJqVWJm7MhBTq8lNZ0Ra10tA X-Received: by 2002:aca:f517:: with SMTP id t23mr1431767oih.160.1582686270329; Tue, 25 Feb 2020 19:04:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582686270; cv=none; d=google.com; s=arc-20160816; b=R1TnfTY/pJEaBhCHKYCduuhgoeubCJPVaFkL5KEfenaIvIgCpT57lOKrZk+F26Rus9 qxx2n1AMnmUIgarlgeDeljlh0+pGTBHNlSYVs+jQXPPA0F0fLIkQVQzbgMmcbvY6KCx9 OdsiN8RnrnFD8UejQ/DC5LE08OLjfEB0ZUCOH4RQlKU1g9Dv9LCExM/52MSexubtIV7n MQd5pi9R3RYCBLCG4K4doQzhMFeVyo2i9lYgxZrvQchZoexhkn4tjQMZ2ws04XfZxtZH 6vHXUUMciE/DUKTFvmIrbMCI9BiYbcyIEsb1Inx4xvf4aYJ5iWiZ1HO2mIRx/AWFfhSA t7tQ== 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=yrMwZpbW+HzGtWMzY+sJQt7bF+SCHOP96s7Gy4HxFFg=; b=Os+KbWJUcvrLMMQ0d+q3qFpnjAkUhfG39UqsLgit/lbqkDODBwf7ZFHfg1Q/3fY6tl /S58JqUoQ8yNKYmWSP8L0BXUKXJNK23T1KOCheMGhPpeFGMoDBSLsEtwF0BuILaZS9zP KJDVYq0LlUb1RzWQtfPeI7ugJsJBDVGI7f1atCLX2Z3aLybC9gtOm2ZSZJqutr42Ut5y c3lBTzGqxf8lnhHSFHxsX1+uh60WD+tA89K9hATgK/fc34mzMmFcJE2zaCatt/YM6Cfw 8Og5OaBF7uRA87ui9Y4zKTvyXon0tMdLV9Uzsbj8ELcsvr9kJFsjB1UZq8EtPlx14ORr fvSA== 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 f9si460499oti.44.2020.02.25.19.04.16; Tue, 25 Feb 2020 19:04:30 -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 S1730024AbgBZDEH (ORCPT + 99 others); Tue, 25 Feb 2020 22:04:07 -0500 Received: from mga07.intel.com ([134.134.136.100]:56379 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgBZDEH (ORCPT ); Tue, 25 Feb 2020 22:04:07 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2020 19:04:06 -0800 X-IronPort-AV: E=Sophos;i="5.70,486,1574150400"; d="scan'208";a="231248041" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.82]) ([10.238.4.82]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Feb 2020 19:04:05 -0800 Subject: Re: [PATCH] KVM: x86: Adjust counter sample period after a wrmsr To: Eric Hankland Cc: Paolo Bonzini , Jim Mattson , Peter Shier , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <20200222023413.78202-1-ehankland@google.com> <9adcb973-7b60-71dd-636d-1e451e664c55@redhat.com> <0c66eae3-8983-0632-6d39-fd335620b76a@linux.intel.com> From: Like Xu Organization: Intel OTC Message-ID: <8b48666a-c6a8-6dce-d784-424f5c447576@linux.intel.com> Date: Wed, 26 Feb 2020 11:04:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 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 On 2020/2/25 8:08, Eric Hankland wrote: > Hi Like - > > Thanks for the feedback - is your recommendation to do the read and > period change at the same time and only take the lock once or is there > another way around this while still handling writes correctly? For non-running counters(the most common situation), we have too many chances to reflect their new periods. In this case, calling perf_event_period() in the trap of counter msr is redundant and burdensome. A better way is to check if this counter is running via pmc_speculative_in_use (), and if so, just trigger kvm_make_request(KVM_REQ_PMU, pmc->vcpu). Thanks, Like Xu > > Eric >