Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4115848ybg; Fri, 25 Oct 2019 13:34:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOdiyK/7Xa3UFnZDtECF7B3/ayO0sHNYiwVzVfLJYa3/kYTnspGj6xH5OnZJrCpSeUhU1A X-Received: by 2002:a17:906:d72:: with SMTP id s18mr5390487ejh.29.1572035676540; Fri, 25 Oct 2019 13:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572035676; cv=none; d=google.com; s=arc-20160816; b=T6QvVKIoTR7tpyg+CKE3qQ1sqo2s0D9TVDaF6UUE7xBsW7X24VY9Y/IU38TEgZYrVJ oGEh/gvHHuAK2AzaR2M0I5KQmMRfkaSYsVvqGAmvXR4WBl9IzfTBFGOHOq6uAXBXWUMA NtBbUZ8Td+g6O90r3PnErv4dwIof1+8LGezdz0Trql5FHrbfcLFp1xE5fIlqyWrVb/X+ 9IyAJ/ipMHUMgVIuoo51gmZR2aZ1myV9CLzJnre2DvnSBQV599ZkjQjW+8XR4zo+IKPs Y6IYUyNZWTqEIxNPPXi/Ct6ez6PVwO+Plqqn1MPn7Hv3rnhYrWfw9OYGud6AWhkJ+5Of WNaw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hWo0SNct04iwh/EQ5jLRQ9M6P+sh19yIA5xiluSxtT0=; b=ruxV3bqNLlk84+KOmjJzx8e4txZXiSvQUxLyKU4kiE4CJJVBqNGu/SVDFrUCVualLw /+lOMzfThV77ZoUCz9OycSCwe5ag2px4Im2nMk7hTIlolwnvokaEUBqWBOrotwABzpYg 2J07509UhfadzSL+6HjChw3dsTRJhB9KEXl8+vRJs7bVh2h9grBHy5MiJxj6wOhuC7tQ F47beRZPZUBQ/auJoboABuhbCPKH+pwQDYqapzUOKB9gQUWXsHN9j1SyDPykIE+w+lsU 44I2cbKV7HpedqSQfTn6mpkpVAYVZzZK+Kx8md/+BhQmMrm4oN6rC39Y3agUEftPmFwD OLhQ== 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 q5si1745793eju.387.2019.10.25.13.34.12; Fri, 25 Oct 2019 13:34:36 -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; 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 S2503339AbfJYOI7 (ORCPT + 99 others); Fri, 25 Oct 2019 10:08:59 -0400 Received: from mga11.intel.com ([192.55.52.93]:57127 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503311AbfJYOI6 (ORCPT ); Fri, 25 Oct 2019 10:08:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 07:08:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,228,1569308400"; d="scan'208";a="350035414" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 25 Oct 2019 07:08:54 -0700 From: Alexander Shishkin To: Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, jolsa@redhat.com, adrian.hunter@intel.com, mathieu.poirier@linaro.org, mark.rutland@arm.com, Alexander Shishkin Subject: [PATCH v3 2/3] perf/x86/intel/pt: Factor out starting the trace Date: Fri, 25 Oct 2019 17:08:34 +0300 Message-Id: <20191025140835.53665-3-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191025140835.53665-1-alexander.shishkin@linux.intel.com> References: <20191025140835.53665-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PT trace is now enabled at the bottom of the event configuration function that takes care of all configuration bits related to a given event, including the address filter update. This is only needed where the event configuration changes, that is, in ->add()/->start(). In the interrupt path we can use a lighter version that keeps the configuration intact, since it hasn't changed, and only flips the enable bit. Signed-off-by: Alexander Shishkin --- arch/x86/events/intel/pt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 05e43d0f430b..170f3b402274 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -397,6 +397,20 @@ static bool pt_event_valid(struct perf_event *event) * These all are cpu affine and operate on a local PT */ +static void pt_config_start(struct perf_event *event) +{ + struct pt *pt = this_cpu_ptr(&pt_ctx); + u64 ctl = event->hw.config; + + ctl |= RTIT_CTL_TRACEEN; + if (READ_ONCE(pt->vmx_on)) + perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_PARTIAL); + else + wrmsrl(MSR_IA32_RTIT_CTL, ctl); + + WRITE_ONCE(event->hw.config, ctl); +} + /* Address ranges and their corresponding msr configuration registers */ static const struct pt_address_range { unsigned long msr_a; @@ -468,7 +482,6 @@ static u64 pt_config_filters(struct perf_event *event) static void pt_config(struct perf_event *event) { - struct pt *pt = this_cpu_ptr(&pt_ctx); u64 reg; /* First round: clear STATUS, in particular the PSB byte counter. */ @@ -501,10 +514,7 @@ static void pt_config(struct perf_event *event) reg |= (event->attr.config & PT_CONFIG_MASK); event->hw.config = reg; - if (READ_ONCE(pt->vmx_on)) - perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_PARTIAL); - else - wrmsrl(MSR_IA32_RTIT_CTL, reg); + pt_config_start(event); } static void pt_config_stop(struct perf_event *event) @@ -1381,7 +1391,7 @@ void intel_pt_interrupt(void) pt_config_buffer(topa_to_page(buf->cur)->table, buf->cur_idx, buf->output_off); - pt_config(event); + pt_config_start(event); } } -- 2.23.0