Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp338334pxa; Wed, 12 Aug 2020 03:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+VvO76GZ7bZZebDoEvQkJi3AiBO9pe+XRg0ZehQO77MjTWoqxB6Jq4BLxNnBXLpYuDSb6 X-Received: by 2002:a05:6402:12d7:: with SMTP id k23mr30482484edx.312.1597228007500; Wed, 12 Aug 2020 03:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597228007; cv=none; d=google.com; s=arc-20160816; b=gPzlnxeK3Wfs2YZhgbmxuukS+wuVM+1Ju+2osh4yPPvkVht9CBZBQOLEeBQabR/3kv QMuQl6M/eSbDfnSbJ7hk3KChmRtr1fVcBbhXi3Wvd9GV324YF+LrcNJ1PV0VERrWv/4j Rc2dzD5qK1xba2fyUHGH134H88pUvBIt1UW+ArZ50gUKF72lbbdAE6c9JRRgHy30sCgQ VYOClVBjPgGsfEwId0gKMWuo5EP3OhQXiTr6sy0rNCGWMUpGheWB95tZaEv7ddjH9y6U BRztZ6f40lRLTAY8ydKp6Qtct2TZYvb8em3WU77laYh0cgqbvw0+JGa1HAxi6+w2ngyn IBKg== 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:from:references:cc:to:subject:dkim-signature; bh=o7xZf6bRAQ1fAn5OtHzaQRhzaOM4m+C5MJxnLgV/A0w=; b=DOYhyUzIDNLwa+kVsKNKVouSuRJkY0j0+iXR6xbTXC6/UkV9ULK6HGQMdQzFLz4V5t xk/A3yod3rZIMToNIG7Efr5F8CTRLREyyoingcozK8GA2VI9ZFKbvmskbBbmBPNxkI0i r14h8mI0iW8I2YXIEJKKkmaNnQ/e5hShxvPi2kdzNUzjURX9vZmP8tQU4n125H4p6HZ/ D4iQGd6447P3aoD37jESCnbigo9lQsZ4EMhKpZebju6t3GwPVo/87XY8ZymNtcsJm/GR N3LTkF6MVZ3DPodhwHvT62QBg727jHqSUZ2lVPgkh340I23UNqeqQbp3XyeIaegwX+d1 rAgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M7fjpYUr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si916911ejl.139.2020.08.12.03.26.23; Wed, 12 Aug 2020 03:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M7fjpYUr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbgHLKZu (ORCPT + 99 others); Wed, 12 Aug 2020 06:25:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22776 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726595AbgHLKZt (ORCPT ); Wed, 12 Aug 2020 06:25:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597227947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o7xZf6bRAQ1fAn5OtHzaQRhzaOM4m+C5MJxnLgV/A0w=; b=M7fjpYUr3yQGphKPvkT7YdheDLTF++Jce/ljt5I1reGFgZ8Es9fvBqj76z53tLXbgZMmfl vsYOEXQ1P4trLS6gg5ICPab870FadsW0lz75KHbEqTJE34VmNkHmN2uWChHOnjpvAxJLQX 1S76AfEsMMpfh7UcWkIpZcJNiCEX6uI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-JqgksIIUMcurcbMs6RXipA-1; Wed, 12 Aug 2020 06:25:45 -0400 X-MC-Unique: JqgksIIUMcurcbMs6RXipA-1 Received: by mail-wr1-f72.google.com with SMTP id m7so727047wrb.20 for ; Wed, 12 Aug 2020 03:25:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=o7xZf6bRAQ1fAn5OtHzaQRhzaOM4m+C5MJxnLgV/A0w=; b=J0xGjwddk/V/Hwzz1BJzC6ZZ1gy5EeIgsVuxx9XkQ24fUESnbRUDg2tozwgGbmIpCf BMlBOjS0vgfCMrQNGXC02VAPQCepcOLOZwV5QTyczSC2A4cP0aJHfDV7oDY3Zy7GbSCZ vCJAMel4HRMnmeL0ChH3HRgdECuJLtSjo9qdpaHFjmCK4SkfpwSGFf4G8TfYsc+aNzJV i3VyqGTALC9eqD9d97VhCEAhxitM1JNSPG2jq7JBT0HVXWkwORvaZ1UJQy+ukgX6o8fT fgn7VKVKDXpWWslc9sHO6T2q9mHWe1Lgu1NgyODDT/4YB6GcKCaSos3mVE1QWzwF1o07 /vMQ== X-Gm-Message-State: AOAM533ROiAgtEj8qPF66BVOl1xYoWseMRscqqk6GTlPF/8UTZIr4hdM CeZLHw7bXlI7FzVPzYBj6KQ55BJL27wFAN/uyp+998osO8MYdJ9thvxejzLlRdP3i8bVsd08gnP NfN+IkS/8x2xjPcSX1c/MQIuU X-Received: by 2002:adf:c64d:: with SMTP id u13mr3988971wrg.114.1597227944529; Wed, 12 Aug 2020 03:25:44 -0700 (PDT) X-Received: by 2002:adf:c64d:: with SMTP id u13mr3988958wrg.114.1597227944318; Wed, 12 Aug 2020 03:25:44 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:744e:cb44:4103:26d3? ([2001:b07:6468:f312:744e:cb44:4103:26d3]) by smtp.gmail.com with ESMTPSA id d21sm3171340wmd.41.2020.08.12.03.25.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2020 03:25:43 -0700 (PDT) Subject: Re: [PATCH] KVM: x86/pmu: Add '.exclude_hv = 1' for guest perf_event To: Like Xu , Peter Zijlstra Cc: Yao , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200812050722.25824-1-like.xu@linux.intel.com> From: Paolo Bonzini Message-ID: <5c41978e-8341-a179-b724-9aa6e7e8a073@redhat.com> Date: Wed, 12 Aug 2020 12:25:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200812050722.25824-1-like.xu@linux.intel.com> Content-Type: text/plain; charset=utf-8 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 12/08/20 07:07, Like Xu wrote: > To emulate PMC counter for guest, KVM would create an > event on the host with 'exclude_guest=0, exclude_hv=0' > which simply makes no sense and is utterly broken. > > To keep perf semantics consistent, any event created by > pmc_reprogram_counter() should both set exclude_hv and > exclude_host in the KVM context. > > Message-ID: <20200811084548.GW3982@worktop.programming.kicks-ass.net> > Signed-off-by: Like Xu > --- > arch/x86/kvm/pmu.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index 67741d2a0308..6a30763a10d7 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -108,6 +108,7 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, > .exclude_host = 1, > .exclude_user = exclude_user, > .exclude_kernel = exclude_kernel, > + .exclude_hv = 1, > .config = config, > }; > > x86 does not have a hypervisor privilege level, so it never uses exclude_hv; exclude_host already excludes all root mode activity for both ring0 and ring3. Paolo