Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp17692lqn; Thu, 11 Apr 2024 12:18:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZf1Wc3y4GhhyMjaoyjDYqtPkGDqQUEU2HozYZQYiGKdeWU/9oarcGKiSRoPZ4ddqd4fbJzuukr8/WFZlNY+BAjU3QKRJQzzBTMfi1Dw== X-Google-Smtp-Source: AGHT+IFk5oo54f5Bdz/hi2+7vWtk5CqdzPh6E6bjYQ0IV5PPvGc7wxA4Ow4Pe9dNibNWtObLlgMo X-Received: by 2002:a05:6820:996:b0:5aa:4a08:7f26 with SMTP id cg22-20020a056820099600b005aa4a087f26mr509002oob.5.1712863085996; Thu, 11 Apr 2024 12:18:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712863085; cv=pass; d=google.com; s=arc-20160816; b=CNbgR7Kc7wjAiGGaJIgVXKTTpsUwjBx4idjee7eHByLJrm2Is00UJ0iUoLBZ2crSm3 5L7ApqqejamRbKg7SWoTr4GVvD/mcEkTytIkaGsjVli5OB3mNkqeP8jXj+d6GDaUANhP Cd8qDv6T9hSW41pCeCilQ4uXfhIl+8EbLMUeoB5ZJM/UuJoiHYnTM4SgXuP5YAJTR5Gy 37+vLKCQA0KJo5bjm3dJcjvhaDPOUH4upkDuD2l7giNktBBnL2yKRQ6Xfupn1lf+xS6r hTkUHnodNM7+JOwKKfEACbndmCAUxKKsA6FTrlQCuPsvOvpy5H6Uaxsj5/+BFKMprLwc xCRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=LMIixoIt6lY2SkR94o/u4nUsQeakPmVSC2HlUkV0a60=; fh=bStSaxeBW0fMbBNQD94OtoQoYzTRNAXO8gisC5o6IhY=; b=LRHDWF84sg1pEY1uZVNsmQzVMFyrBYmImGHdbau0aOHt8qFudRymyOI542eqarrR2u xXg9Hx2M/K5JBBCxtwZuezXQ9VJgGIUg9mHpSGhmKUDWIdObX8xYICvbxX35P9lxfmLf gr2RGGfY4jBjSG98BuJKyuA+SjVgXQ6I/QJK+VvT5S718r+5vY4dlqnMEkRJfX6X6kSH hG5QlxMjtAB4tILh2b35FTqpelZ3fgaXsN46282OQvQWBZ5iWezB3TtZ4yOc8kC588Fc qif01WMORVIJ7VtoxJOGlcSNPZ04XlHnC3xki3kbAi7JFU1zkoNIthwyA467EemVwHGT Iasg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ji3XyGUr; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r2-20020a05622a034200b004347d76f441si2169808qtw.173.2024.04.11.12.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 12:18:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ji3XyGUr; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-141520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B176F1C22C6E for ; Thu, 11 Apr 2024 19:18:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D292214AB4; Thu, 11 Apr 2024 19:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ji3XyGUr" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3514610E for ; Thu, 11 Apr 2024 19:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712863075; cv=none; b=pZL0fEmtaERPuOk6LreX7/x+yGAS7CW+wFF3hu01MiigHunr9MgDTIPHn5urZuls0i6rIcIAFo4MJqmsz62iFkCaMNy4mlbFEM7THu+VTvQUXXYhT/R9i3lWRmRQM2LkTVz1tNKSApmA43z+7JNzqFAdTKmV/HzUUKNEpwAcA2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712863075; c=relaxed/simple; bh=sD4t/uLxUXQneloPRvioqFpGGr++WQw2Vhn8idLNvnQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aK268+UbdnlaoFJtVoDUQS5q5Eg4+OgfGJtoTXAQTeT56koHFGV9HnZ7ldH+TB7lR18dN0On2HEEO9H3ImXVXWIrsOYG7mPQpLZAEfl1WapbbI9zW1sPaEtVHSzqxnn5cTsK2Rox+UNqpl1Uc0a/2STj5FDU3NSE3jfYy3qG3BE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ji3XyGUr; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5d8bff2b792so159747a12.1 for ; Thu, 11 Apr 2024 12:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712863073; x=1713467873; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LMIixoIt6lY2SkR94o/u4nUsQeakPmVSC2HlUkV0a60=; b=ji3XyGUrxqhwI1zj90rfih7kd0TW0YjfCRz3T346bA7OGtMLhT8NjY06BjnAlzBUw+ OxmiuMvYQsMKttH0jSge8uOcp1izuIXfV0D95sHdFR4wdoPqy2XYPE90nxjtX5K/VzIu e9LDyPKnA5GBaAjeLP5jhU6cynBesB37QYvftHmbNu56NLvDWcpX6JEaoK+0qo5bafBT 1VpIOOmXkSLuX0rzH+ZkkbGOV9LVJROgKSDeOb2EEU5gqmMd2NE+TfCHetXQvjPTOX50 r9OljLwy2I+wPKi8np1FQUxXuqOCRZBD/k+uC8XIUeAvFRtiONSfzONu1P20xbkYsYkl XwKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712863073; x=1713467873; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LMIixoIt6lY2SkR94o/u4nUsQeakPmVSC2HlUkV0a60=; b=ZTqx+yQMDv6bPr29C7ARfeGbKfWaD9FdpDNBl0xfsc0z1lxvhHB3brnb1RsdQQHoYH WwOmh7mYy8U65dVuzWXDiX8SQO7Em3F+wAKPDm66AOruR2cMT6fVGK8SB0ur1KiTiRkL x1EAKVNUq/5yIL/1XuYbEAR7TOUPkDVl5yJOdeHoN1vmzRI4R5DZ+TFg2s8BYopmglJs 5OzEBxxNeo1GS7SeyMZHY7pbLe982iobg7sr4uzyz/hKTYxMEJSgxIXUjMao5Nn+EH/m lIpC9OtL1Dwr/r+rRQtKrRtT5A8p7YOEZ0t834UBITLct/sONiJj/mKquKbHIFGw/l5s eUkA== X-Forwarded-Encrypted: i=1; AJvYcCXHqmqOnl1AnNSYfudWc//Y9iFCL+DBgIuXUM4qMz2CQL4xhKMmfaCVbfcheQO0BLYK1E4zPnDxGNnLjPEdGcRmCYYskDCobkY6vlhO X-Gm-Message-State: AOJu0YwFmWTngQwfkkC53osYHNhgqC5wQMK1Ednw/uFNoN/dIrKG2VK/ Vom6qzcWJGu54Bf/tQIm8nbq9LqzFzqdW1Ec+NxEKaSFv4R4s2vYLd6VZduImKVNg9oU6raw3At fmQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:1761:0:b0:5e4:292b:d0eb with SMTP id 33-20020a631761000000b005e4292bd0ebmr1192pgx.2.1712863073071; Thu, 11 Apr 2024 12:17:53 -0700 (PDT) Date: Thu, 11 Apr 2024 12:17:51 -0700 In-Reply-To: <20240126085444.324918-7-xiong.y.zhang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> <20240126085444.324918-7-xiong.y.zhang@linux.intel.com> Message-ID: Subject: Re: [RFC PATCH 06/41] perf: x86: Add function to switch PMI handler From: Sean Christopherson To: Xiong Zhang 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 Content-Type: text/plain; charset="us-ascii" 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().