Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2297800ybh; Mon, 9 Mar 2020 03:06:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvyo+PeWF/KHAS4SUYRSfEGali6y83+lEVLzrpPaFjumAZO93k5QwWWWZ7rF3fhjt6c6Gp2 X-Received: by 2002:aca:b1d5:: with SMTP id a204mr10642281oif.82.1583748401394; Mon, 09 Mar 2020 03:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583748401; cv=none; d=google.com; s=arc-20160816; b=KukR1WKb9EKswP9e9MMkLEs3U1SXiTTLwXJFwXbPtyrwA4VAai5JWktqaQBZ0hZ9pR 4Bc0yVHh9hMpB07FMhrKTY/Da1X5Oe+oiWNxpBzPiSUO694WxnanVN9YC7HZySuacJIV 86ebdSKBBOB84HRAMDBbcruihml2f/RKasqiiR+o1B+Hzptz4LysZ5LTK0doGER11QL7 mqMIZLo8xyqfMvL4CgqD0iv3zowWAdVPv9i3KoTsM4vTF3mT+Plvsol8Qp6+xJuRMKzY V1Abig/v4ALrlK0i5qrQv570v2Cw13zG+vT0rqWIMrKKo7AHdmXtysOHar5SWwkktmLe 0PXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=cH9d5s5skj+POkYSuWj5kZEqcL/x30ONYbTKCTwNqJo=; b=ZvAhLF4IS9U10rFYSz4HM6qEaCocPIt0mhNREqh27YmZuU7l2g168SKcEntT9WDE40 ZxN24c3SWMhfG8hT/OVLoJewv3XIgDHCQBX/qL+zqQhyQ3nHEX7WU5KYWXE0VU0cnyDA wxNHHdoI3U43wbJkCVJeDRn0Rz06/5Coh/opbxO3TNmtVii2d+ZKlI4FnXx0DeYC7tSs /fGcXiGxuy9f0EdxeZFTwnPFFsrQbTBI3ahIk91CuVLaxVEq9ogpKVVwXwMmkk8jRzwA nm2MjHNdPpBgq7Wju7bg6qXLrky9Fq/3F7P84BF+g5yessFZdkx2yR+FYxwVUB5mcoSJ YW4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gqsfUsen; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si745207otf.196.2020.03.09.03.06.29; Mon, 09 Mar 2020 03:06:41 -0700 (PDT) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gqsfUsen; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbgCIKFS (ORCPT + 99 others); Mon, 9 Mar 2020 06:05:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33420 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbgCIKFR (ORCPT ); Mon, 9 Mar 2020 06:05:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cH9d5s5skj+POkYSuWj5kZEqcL/x30ONYbTKCTwNqJo=; b=gqsfUsenwszWL3nli8z5CzNc2i W+77bUrm7N3nyuSb4y+Oev7DBRugilabh+W6Dlsrl1M8N+uTNCumnq79J4R5xM8raQDE6KcW8+mjl kUXxLI6ljPz+p5pmmZRstg8jzkWc8ADF6HDeZRw5IcE5p1sjPKutoarcxOyv70E+3TVF/DXMJgQZU /VK8oliwK4CGXtlYV7Sg6dTjKS7WUGGQvOrAgknXM2oUHm/xgIrgw7mgH7hfK2xlr+JC50s9X1b5I 5cam09L3pNDVTpQOlzZAZhfgaRZdkh/l2FKuBJJ2iDhyaUguAPwfLPs83aYlzi2iSvS2r4US/7sef wjAO1ifQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jBFHC-0004fF-FA; Mon, 09 Mar 2020 10:04:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2620430066E; Mon, 9 Mar 2020 11:04:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1166B25F2A4F2; Mon, 9 Mar 2020 11:04:43 +0100 (CET) Date: Mon, 9 Mar 2020 11:04:43 +0100 From: Peter Zijlstra To: "Liang, Kan" Cc: Luwei Kang , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, pawan.kumar.gupta@linux.intel.com, ak@linux.intel.com, thomas.lendacky@amd.com, fenghua.yu@intel.com, like.xu@linux.intel.com Subject: Re: [PATCH v1 01/11] perf/x86/core: Support KVM to assign a dedicated counter for guest PEBS Message-ID: <20200309100443.GG12561@hirez.programming.kicks-ass.net> References: <1583431025-19802-1-git-send-email-luwei.kang@intel.com> <1583431025-19802-2-git-send-email-luwei.kang@intel.com> <20200306135317.GD12561@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 09:42:47AM -0500, Liang, Kan wrote: > > > On 3/6/2020 8:53 AM, Peter Zijlstra wrote: > > On Fri, Mar 06, 2020 at 01:56:55AM +0800, Luwei Kang wrote: > > > From: Kan Liang > > > > > > The PEBS event created by host needs to be assigned specific counters > > > requested by the guest, which means the guest and host counter indexes > > > have to be the same or fail to create. This is needed because PEBS leaks > > > counter indexes into the guest. Otherwise, the guest driver will be > > > confused by the counter indexes in the status field of the PEBS record. > > > > > > A guest_dedicated_idx field is added to indicate the counter index > > > specifically requested by KVM. The dedicated event constraints would > > > constrain the counter in the host to the same numbered counter in guest. > > > > > > A intel_ctrl_guest_dedicated_mask field is added to indicate the enabled > > > counters for guest PEBS events. The IA32_PEBS_ENABLE MSR will be switched > > > during the VMX transitions if intel_ctrl_guest_owned is set. > > > > > > > > + /* the guest specified counter index of KVM owned event, e.g PEBS */ > > > + int guest_dedicated_idx; > > > > We've always objected to guest 'owned' counters, they destroy scheduling > > freedom. Why are you expecting that to be any different this time? > > > > The new proposal tries to 'own' a counter by setting the event constraint. > It doesn't stop other events using the counter. > If there is high priority event which requires the same counter, scheduler > can still reject the request from KVM. > I don't think it destroys the scheduling freedom this time. Suppose your KVM thing claims counter 0/2 (ICL/SKL) for some random PEBS event, and then the host wants to use PREC_DIST.. Then one of them will be screwed for no reason what so ever. How is that not destroying scheduling freedom? Any other situation we'd have moved the !PREC_DIST PEBS event to another counter.