Received: by 10.192.165.148 with SMTP id m20csp2474889imm; Sun, 22 Apr 2018 07:49:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hhZW22JDwdNgRJkHpHe83Ngt2Dw08KT8K98t3e2bhUfBuT3nqYToMJvbH7SM19smKb9FQ X-Received: by 10.99.98.198 with SMTP id w189mr14619852pgb.263.1524408541708; Sun, 22 Apr 2018 07:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408541; cv=none; d=google.com; s=arc-20160816; b=Y1jusrIsnz7dCkM7pNry5nPv5eislnwkYZ4ZImuj7EGSdpSqyRfjDOFZF8aD2XHYKf ei4+HO2TxRceCDQc0U0YCWVCvk2kpjBm5i1hSFJFYdDfC0vOi7BUEX7GXa3OHVtemZRr b5IpPZRPeBp6pFEMGNaXNSa7rSC/S251uq7Wts+pry5CICOiO9KJbHP7Fs1oYdv4wifi wkcdMbkqsf4QXjC4bTwviLkmT8fSXmYel5wxOnsGW1fbY720a0V+IsvybMmlUxF/i1S4 vBjtxhQeo4s2NBV5UBHb3JT9RycdcIBH3LPelsRtONpTSXpBW4TKpdlbj2VrsMyct/vd 1Yzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=JLrQy2wge+JtgyZV1HsMKPVWjQb5fZ1e1343jh0EAGk=; b=PduGiyiupQK1pFSULTE1TcCUlxTQvD/cdkOrKaVp0CrdRcXsaT0+JDm+m1AKvZl+T1 l6hsx9vvw3+5+B+xiCGSmu23pGAnyCWuxElUrPaLiP82oHv03NOnxLpD45Pg32YpOvvZ 8Ggi11GAuWMXO1ng794fw+R+qsZptyY12srzrRUUNta/+3nMBWOjasMi+eMrFEIqW23g d8t+PpX9GJNeYccIqmw/puAcaDW4THXJVr13YZgMfFVscSygD9ONwDn+7s9PY3rVuv7B Qm7689O6Eu582q6c457LTBIuuNqSnO+SeuN5Gwm3tZyZHOcm7Rkdb5k5nljtB5JEJA9j PXZA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si9680455pld.168.2018.04.22.07.48.47; Sun, 22 Apr 2018 07:49:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757322AbeDVOq1 (ORCPT + 99 others); Sun, 22 Apr 2018 10:46:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57584 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932295AbeDVOQg (ORCPT ); Sun, 22 Apr 2018 10:16:36 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E16DCC87; Sun, 22 Apr 2018 14:16:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 4.4 04/97] perf intel-pt: Fix sync_switch Date: Sun, 22 Apr 2018 15:52:42 +0200 Message-Id: <20180422135304.872016120@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit 63d8e38f6ae6c36dd5b5ba0e8c112e8861532ea2 upstream. sync_switch is a facility to synchronize decoding more closely with the point in the kernel when the context actually switched. The flag when sync_switch is enabled was global to the decoding, whereas it is really specific to the CPU. The trace data for different CPUs is put on different queues, so add sync_switch to the intel_pt_queue structure and use that in preference to the global setting in the intel_pt structure. That fixes problems decoding one CPU's trace because sync_switch was disabled on a different CPU's queue. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1520431349-30689-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/intel-pt.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -125,6 +125,7 @@ struct intel_pt_queue { bool stop; bool step_through_buffers; bool use_buffer_pid_tid; + bool sync_switch; pid_t pid, tid; int cpu; int switch_state; @@ -852,10 +853,12 @@ static int intel_pt_setup_queue(struct i if (pt->timeless_decoding || !pt->have_sched_switch) ptq->use_buffer_pid_tid = true; } + + ptq->sync_switch = pt->sync_switch; } if (!ptq->on_heap && - (!pt->sync_switch || + (!ptq->sync_switch || ptq->switch_state != INTEL_PT_SS_EXPECTING_SWITCH_EVENT)) { const struct intel_pt_state *state; int ret; @@ -1238,7 +1241,7 @@ static int intel_pt_sample(struct intel_ if (pt->synth_opts.last_branch) intel_pt_update_last_branch_rb(ptq); - if (!pt->sync_switch) + if (!ptq->sync_switch) return 0; if (intel_pt_is_switch_ip(ptq, state->to_ip)) { @@ -1319,6 +1322,21 @@ static u64 intel_pt_switch_ip(struct int return switch_ip; } +static void intel_pt_enable_sync_switch(struct intel_pt *pt) +{ + unsigned int i; + + pt->sync_switch = true; + + for (i = 0; i < pt->queues.nr_queues; i++) { + struct auxtrace_queue *queue = &pt->queues.queue_array[i]; + struct intel_pt_queue *ptq = queue->priv; + + if (ptq) + ptq->sync_switch = true; + } +} + static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp) { const struct intel_pt_state *state = ptq->state; @@ -1335,7 +1353,7 @@ static int intel_pt_run_decoder(struct i if (pt->switch_ip) { intel_pt_log("switch_ip: %"PRIx64" ptss_ip: %"PRIx64"\n", pt->switch_ip, pt->ptss_ip); - pt->sync_switch = true; + intel_pt_enable_sync_switch(pt); } } } @@ -1351,9 +1369,9 @@ static int intel_pt_run_decoder(struct i if (state->err) { if (state->err == INTEL_PT_ERR_NODATA) return 1; - if (pt->sync_switch && + if (ptq->sync_switch && state->from_ip >= pt->kernel_start) { - pt->sync_switch = false; + ptq->sync_switch = false; intel_pt_next_tid(pt, ptq); } if (pt->synth_opts.errors) { @@ -1379,7 +1397,7 @@ static int intel_pt_run_decoder(struct i state->timestamp, state->est_timestamp); ptq->timestamp = state->est_timestamp; /* Use estimated TSC in unknown switch state */ - } else if (pt->sync_switch && + } else if (ptq->sync_switch && ptq->switch_state == INTEL_PT_SS_UNKNOWN && intel_pt_is_switch_ip(ptq, state->to_ip) && ptq->next_tid == -1) { @@ -1526,7 +1544,7 @@ static int intel_pt_sync_switch(struct i return 1; ptq = intel_pt_cpu_to_ptq(pt, cpu); - if (!ptq) + if (!ptq || !ptq->sync_switch) return 1; switch (ptq->switch_state) {