From nobody Tue Apr 7 03:49:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67B4AECAAD3 for ; Thu, 1 Sep 2022 13:12:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbiIANM5 (ORCPT ); Thu, 1 Sep 2022 09:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233877AbiIANML (ORCPT ); Thu, 1 Sep 2022 09:12:11 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8298617049 for ; Thu, 1 Sep 2022 06:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662037805; x=1693573805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sbi6khNsjjvSS4caSIbQyKIV39nuU2klly/xGl3rjT8=; b=QzVPrnf0A4xUqdXjv4tvAGcXWnApZGcBKS6NcF6t3sAGdNB5kVXk4hVC RVlUHGFuvYcvjHDIAtzj2EgeGUqwzPZpqiU+sB6l0XQXHnDN/cj+oVFzc 2gYxcxqQoiF5JayAIqPq5ksRatbpB84n5zaQy3myYNX1ae/NZENiDa2wl MO3SSMji3J7h/BQsAaa7jSdi50olxHChEygI1HcPX2efoXGNw4QN8APiJ Yc517HVfp8Y/78Y3JXkxYy/JSKXMZkKx9k8Os2RsJGp8YHUJelJzKYe3N wEbSUU8LofEKbxnr3FV8FFXEBJ8XK3gxfWEFNNy/uARY0M7qY7+IH/3ng A==; X-IronPort-AV: E=McAfee;i="6500,9779,10457"; a="321858087" X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="321858087" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2022 06:10:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,280,1654585200"; d="scan'208";a="612485335" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga002.jf.intel.com with ESMTP; 01 Sep 2022 06:10:02 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@kernel.org, mingo@redhat.com, eranian@google.com, mpe@ellerman.id.au, linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, andreas.kogler.0x@gmail.com, atrajeev@linux.vnet.ibm.com, namhyung@kernel.org, ravi.bangoria@amd.com, Kan Liang Subject: [PATCH V2 2/6] perf/x86/intel/pebs: Fix PEBS timestamps overwritten Date: Thu, 1 Sep 2022 06:09:55 -0700 Message-Id: <20220901130959.1285717-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220901130959.1285717-1-kan.liang@linux.intel.com> References: <20220901130959.1285717-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kan Liang The PEBS TSC-based timestamps do not appear correctly in the final perf.data output file from perf record. The data->time field setup by PEBS in the setup_pebs_fixed_sample_data() is later overwritten by perf_events generic code in perf_prepare_sample(). There is an ordering problem. Set the sample flags when the data->time is updated by PEBS. The data->time field will not be overwritten anymore. Reported-by: Andreas Kogler Reported-by: Stephane Eranian Signed-off-by: Kan Liang --- arch/x86/events/intel/ds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index de1f55d51784..01cbe26225c2 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1643,8 +1643,10 @@ static void setup_pebs_fixed_sample_data(struct perf= _event *event, * We can only do this for the default trace clock. */ if (x86_pmu.intel_cap.pebs_format >=3D 3 && - event->attr.use_clockid =3D=3D 0) + event->attr.use_clockid =3D=3D 0) { data->time =3D native_sched_clock_from_tsc(pebs->tsc); + data->sample_flags |=3D PERF_SAMPLE_TIME; + } =20 if (has_branch_stack(event)) data->br_stack =3D &cpuc->lbr_stack; @@ -1705,8 +1707,10 @@ static void setup_pebs_adaptive_sample_data(struct p= erf_event *event, perf_sample_data_init(data, 0, event->hw.last_period); data->period =3D event->hw.last_period; =20 - if (event->attr.use_clockid =3D=3D 0) + if (event->attr.use_clockid =3D=3D 0) { data->time =3D native_sched_clock_from_tsc(basic->tsc); + data->sample_flags |=3D PERF_SAMPLE_TIME; + } =20 /* * We must however always use iregs for the unwinder to stay sane; the --=20 2.35.1