Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp2726lql; Fri, 12 Apr 2024 01:26:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2nARqUc6HdK3+TNcZFI29M22eYDUN9iHQsKRO+41fnTeQ5ia6Mwk29KJl2Y8WjMz1Ai1YA3AJ7fW9kwFtq9KOsZwaii0BbxLTrilxqQ== X-Google-Smtp-Source: AGHT+IH4cRbg5H3WFkz6CIHjgS5PFeBe1DlhHRLq0AtuqlgWPZ/n7MZ0Y2toEvt8xZQoLY6yDR1s X-Received: by 2002:a50:f687:0:b0:56c:19d2:85be with SMTP id d7-20020a50f687000000b0056c19d285bemr1400101edn.11.1712910378923; Fri, 12 Apr 2024 01:26:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712910378; cv=pass; d=google.com; s=arc-20160816; b=FwPLLEFSuH/NtqEg6qfnMdJ5NEpxf3Nq9MRRXbHMFzW3D0lF9SK66XtcRljPnVTxqN rBZyHn0EiC9j0qqI32AiPve5Eqn2kDUN5QR9+xSJhB2qeaeDot0Coy8Xwfj1ZU38ohym RPoEQZ/f43C54GOzvvSDfVhj4sofRwFU6yeWo2h3OgAL/CGcRO4KDdm/wcb2Xrbi0Zk1 uo0Hdf20CcPxooQ/+RP+0rdVv5ID3MxaWaGZBjOprU/q2JMTnp9p91XBEGv9JEPNA5Dk ZDs6KW/eT9tI2MNhNCj4+T7KKkY7J9l5Zp3GUgdq7HB3qF5wCdkyBcR2Pk+3axpzQm2I cNBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=WIzh4tEdHnIVlp/ZIEBhy5/KXk0Q6QhN6lKmCRwLEEY=; fh=rQFU4kFolTL9s3r3UhdFq9yOlLRa7cBQ7COi5Uhjtq4=; b=x1gTEeMx0874cQhoJWCq2KMDtkJ0CIP3x/vt1ta6h7wsRY1YWe/aUfhtb6bBi/D/om Qyr+R9Jap3vR1nzN5uVt3X3ggZdXnFfPkApJ2NJ/fSLK4ue/M0LqWVFvRP4cc7kpJMF4 fhCV2bmybDtOGJiX1YB4Y+Hf4SALSxqI0UWr6MxOpIz2FekeAFkX3UQZbMx0d11vhRKI bgkYUmmfKshYcCRiH/GupRbsU7XhED6PQPB+Bkq9uVcsVgFg7aVb4N/sceL9O6hBkuX5 WZ3WK0p+jD+M+eNfWxj1S0fPgWo0tU5++x4OOwD3C3Xfu4qmysGDSovNJTamMqjYeAIs dKrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F1C7VCAu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-142009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c67-20020a509fc9000000b0056fdaa4f18dsi1524463edf.520.2024.04.12.01.26.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:26:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=F1C7VCAu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-142009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B25951F22C36 for ; Fri, 12 Apr 2024 05:58:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42BD72C683; Fri, 12 Apr 2024 05:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="F1C7VCAu" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B54691DDDB; Fri, 12 Apr 2024 05:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712901477; cv=none; b=cpvl+vDNIeuWcy8Pr58/HEw0BVzVPgPe0qDtk4zajgsH/BaLB8OlGVsozS3dQRJoLOW+m7q45LC0HfeLL37cxcGQxSy9A1xSDe0GVld0o4baPbdrrje3i2rzogfbz6lQYG/CFk97ANs9j+FWkU5+SIvo690h8jFMYKk2NsofKck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712901477; c=relaxed/simple; bh=G8hY+FjLTfuIVDy57N/LtDBhn3ksctV6ZZ1Ygu0usZ8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bAyLvjS6wZs5X4bVJP7scr8yBXUC0q/E6dswUN56VR9v/5oP495nYHyqGl0HR2USl9Dg3aSuTlfhZ4DBn2vLvtkSrC/TSYGo7Q5pGlT0MztjiYQ1caNyFx2oH14BQ7vxacExgPjXSpGzEnAwGAfsjkgr6oTc8IAxg/Sxuy92zo0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=F1C7VCAu; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712901476; x=1744437476; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=G8hY+FjLTfuIVDy57N/LtDBhn3ksctV6ZZ1Ygu0usZ8=; b=F1C7VCAubQQsab5goh3xq6S7Bu+5YTBCQLs10oQWTUNqOOeF5/8sczwa peFNL7N2XO+QcpPu4CWfipJPdrDclVwFSdQqiojAGhDmGvdYHyq2sSQ46 BzLDkMAnk9Dq6zflhEYnHxJlNQxm84AXQMwmaX1wTyAfC9+6G4h+jZYVV 6eWBfvUShzwafdHWLsTag5772oW1OHn8i9l3pqRkhltYMiU88ZcxJqDxw n39U37icRo3fFD+wl1TTS3EJgMItqv60OmV8j5cS0zuD79+/oHXx9qhBw jJm4C5MgHiAPwJ8z/ksnMfK3luN6uFyO77j04RIALZM56LD7fyHtncag7 w==; X-CSE-ConnectionGUID: gNngCGD/R2KaO1nj2A1zVw== X-CSE-MsgGUID: D2jLTxB3SM6YanerxoLrgA== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="12197661" X-IronPort-AV: E=Sophos;i="6.07,195,1708416000"; d="scan'208";a="12197661" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 22:57:56 -0700 X-CSE-ConnectionGUID: 1KuqrSs2RDat7Er/1WVpHg== X-CSE-MsgGUID: 8iIV9R12Si+eflAuqF5r4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,195,1708416000"; d="scan'208";a="52299881" Received: from xiongzha-mobl1.ccr.corp.intel.com (HELO [10.124.244.162]) ([10.124.244.162]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 22:57:50 -0700 Message-ID: <41c6af10-82f8-4e67-9d55-6034ad079418@linux.intel.com> Date: Fri, 12 Apr 2024 13:57:47 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 06/41] perf: x86: Add function to switch PMI handler Content-Language: en-US To: Sean Christopherson Cc: pbonzini@redhat.com, peterz@infradead.org, mizhang@google.com, kan.liang@intel.com, zhenyuw@linux.intel.com, dapeng1.mi@linux.intel.com, jmattson@google.com, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhiyuan.lv@intel.com, eranian@google.com, irogers@google.com, samantha.alt@intel.com, like.xu.linux@gmail.com, chao.gao@intel.com, Xiong Zhang References: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> <20240126085444.324918-7-xiong.y.zhang@linux.intel.com> From: "Zhang, Xiong Y" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/12/2024 3:17 AM, Sean Christopherson wrote: > On Fri, Jan 26, 2024, Xiong Zhang wrote: >> From: Xiong Zhang >> >> Add function to switch PMI handler since passthrough PMU and host PMU will >> use different interrupt vectors. >> >> Signed-off-by: Xiong Zhang >> Signed-off-by: Mingwei Zhang >> --- >> arch/x86/events/core.c | 15 +++++++++++++++ >> arch/x86/include/asm/perf_event.h | 3 +++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c >> index 40ad1425ffa2..3f87894d8c8e 100644 >> --- a/arch/x86/events/core.c >> +++ b/arch/x86/events/core.c >> @@ -701,6 +701,21 @@ struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data) >> } >> EXPORT_SYMBOL_GPL(perf_guest_get_msrs); >> >> +void perf_guest_switch_to_host_pmi_vector(void) >> +{ >> + lockdep_assert_irqs_disabled(); >> + >> + apic_write(APIC_LVTPC, APIC_DM_NMI); >> +} >> +EXPORT_SYMBOL_GPL(perf_guest_switch_to_host_pmi_vector); >> + >> +void perf_guest_switch_to_kvm_pmi_vector(void) >> +{ >> + lockdep_assert_irqs_disabled(); >> + >> + apic_write(APIC_LVTPC, APIC_DM_FIXED | KVM_VPMU_VECTOR); >> +} >> +EXPORT_SYMBOL_GPL(perf_guest_switch_to_kvm_pmi_vector); > > Why slice and dice the context switch if it's all in perf? Just do this in > perf_guest_enter(). > As perf_guest_enter() is in perf core which manages all PMUs, while switch_pmi_vector is for x86 core PMU only, so switch_pmi_vector is put in x86 pmu driver. pmu driver can call perf core function directly, perf core manage pmu through pmu->ops and pmu->flags. If switch_pmi_vector is called in perf_guest_enter, extra interfaces will be added into pmu->ops, this impacts other PMU driver.