Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1305727pxk; Mon, 31 Aug 2020 15:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwylvlvDz7o4jxCmjY4SjfXGu6T92D8sv93+E/8LlmXyqdkndpZcpX24rt1oN/g6G7oKi0n X-Received: by 2002:aa7:cf96:: with SMTP id z22mr3238491edx.120.1598914442673; Mon, 31 Aug 2020 15:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598914442; cv=none; d=google.com; s=arc-20160816; b=aQMYIb+yLmUxrbsxTO9XT7fU6h0huFfoZWq8aFOuJS6IaQzEyTuP5LAdm2NS12SagI +QYNvhXHVn5sF80Vc2Twf5PgSSz0aUr0KB+dcZj7rPBUR+ERlCT1qogUa7zHqfnzeEUZ +gF0BKgzVhYxc+rqXdpDpoPfJKHbJe123Y5by0R15J9Ie4PQGV8/TR5Tnt48Bk3p2HxK raXforKdZBF6LZVz7hBrHcAO+Oi41nLya88qCL0V8gTCKLmVgtmsPVNC4cenoLSkrCUu TcIE5xTIcdyHcmoE4yWPSsLkTE6I4A3pOiiBWzp1s4ZO1UpVtPZ2cHtFbwbRwhHWFJS3 umCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=K/7PK6S5Q6HPaHq1eTEnKf0uxbke5x5RCxK0h2wg5MI=; b=jqkrtWfBsCwioh3wqYy/4lr7I66VDzF7Bl9urhdZoK2mDg5Ou0X2eXtguWKVrjrkX9 +3j2AM+H/PffCdrwrcL5viH+u9b+YxHCK3GZN+oI9/O2cnu2yOUv2o4QguiKGHAcHapM jlTD4QQs7Gd66c1DwtOZcSMpWF71+qG9W/5E1ldVVKb4q9yxVP7Ve+qjtnw1GQ52WCxF cCQJ2dsqUoVN8+w3vHLAh5Bz5IFB3jUl/QnhyPCAS9p0VWgARpgvdXnLl/PE5EGts1a1 QrAELUi7djpgeRcaQNXIQkqm2AC5xXQTkEUy9LI1flevxLtkB118G04nH+/UHWLYFgXp MO0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iD3qjy7K; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p60si6037073edd.302.2020.08.31.15.53.39; Mon, 31 Aug 2020 15:54:02 -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=@linaro.org header.s=google header.b=iD3qjy7K; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728755AbgHaUih (ORCPT + 99 others); Mon, 31 Aug 2020 16:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgHaUig (ORCPT ); Mon, 31 Aug 2020 16:38:36 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1479DC061573 for ; Mon, 31 Aug 2020 13:38:36 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u128so1312567pfb.6 for ; Mon, 31 Aug 2020 13:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=K/7PK6S5Q6HPaHq1eTEnKf0uxbke5x5RCxK0h2wg5MI=; b=iD3qjy7K7rLQsbdLS08nvec3+rM9z7c+f4CUp0k4t39HnIujZ8vk0S8wvig/Z+Afhd sjXJYjB/unW5U/y62CSJod/KXZxJRFkEnUC1VWxC+KIPPzPmNBKoP93r0k/7HLVSzk4g QKUrimlJnMdc4cyZHkskrXezSxkUzb80x5/b5FzkLGNpGunkUWqOnV5/JZ6zTQl42Bjd cHSUscDipKnvrcPDtsBKFWkOVYxr9tQgD0aJrCKfUXFQT85BZvQe2rB9b1jLLcykGKl7 GGbhN8LiBhSjcNbNmg5ZqLkaTJG3/W0PjQo6SJoBYmx44NG/8LgG6DOv+dtbAacwo4dj bUIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K/7PK6S5Q6HPaHq1eTEnKf0uxbke5x5RCxK0h2wg5MI=; b=M89TXZBCLDJ34zc8brDK0RDBky1sm3ODLyQ9pUY6ouWKOLKlZTNJq7eEeemfqi/eBk PdfOs5hwXVQnaVTtOUdyB7t19tA6Xkdt9R+IqS8OgT6qpVAo+46Cm9zhD/v57aTOxFJx 2ah0aeaxBE56MGi+mPMEE937ThajRVQvs4mqKHeqXIyBp5SoOLmezG+LxZbAY4ioZvsy mXDgmjciQOWIMUQUfM6FvxUR8lAYaVe+AbfLcLIomFSWoVezRkadTEB1Ga5aM7ch5eug /HSlppguT9bvtI9L8rjGDqPgUKaT9XJvXytkvu5oK8+YgY1QRRblXmnp9TwX+TS/XMV6 2Vwg== X-Gm-Message-State: AOAM531bbkNHKaLEbUV1sTnzuRIqU/hA41YHv1eC3enOXcj2xAx4EuXz hKAHdvvJ74zbyFvIthhLfL8Pqw== X-Received: by 2002:a65:4847:: with SMTP id i7mr2554665pgs.385.1598906315528; Mon, 31 Aug 2020 13:38:35 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id l23sm8267869pgt.16.2020.08.31.13.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 13:38:34 -0700 (PDT) Date: Mon, 31 Aug 2020 14:38:32 -0600 From: Mathieu Poirier To: Leo Yan Cc: Arnaldo Carvalho de Melo , Suzuki K Poulose , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Andi Kleen , Kan Liang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AAl Grant Subject: Re: [PATCH 2/2] perf intel-pt: Fix corrupt data after perf inject from Message-ID: <20200831203832.GA120995@xps15> References: <20200819084751.17686-1-leo.yan@linaro.org> <20200819084751.17686-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200819084751.17686-2-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 04:47:51PM +0800, Leo Yan wrote: > From: Al Grant > > Commit 42bbabed09ce ("perf tools: Add hw_idx in struct branch_stack") > changed the format of branch stacks in perf samples. When samples use > this new format, a flag must be set in the corresponding event. > Synthesized branch stacks generated from Intel PT were using the new > format, but not setting the event attribute, leading to consumers > seeing corrupt data. This patch fixes the issue by setting the event > attribute to indicate use of the new format. > > Fixes: 42bbabed09ce ("perf tools: Add hw_idx in struct branch_stack") > Signed-off-by: Al Grant > Signed-off-by: Leo Yan Arnaldo, please consider. Reviewed-by: Mathieu Poirier > --- > tools/perf/util/intel-pt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c > index 2a8d245351e7..0af4e81c46e2 100644 > --- a/tools/perf/util/intel-pt.c > +++ b/tools/perf/util/intel-pt.c > @@ -3017,8 +3017,15 @@ static int intel_pt_synth_events(struct intel_pt *pt, > > if (pt->synth_opts.callchain) > attr.sample_type |= PERF_SAMPLE_CALLCHAIN; > - if (pt->synth_opts.last_branch) > + if (pt->synth_opts.last_branch) { > attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; > + /* > + * We don't use the hardware index, but the sample generation > + * code uses the new format branch_stack with this field, > + * so the event attributes must indicate that it's present. > + */ > + attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX; > + } > > if (pt->synth_opts.instructions) { > attr.config = PERF_COUNT_HW_INSTRUCTIONS; > -- > 2.17.1 >