Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2651826rwi; Tue, 11 Oct 2022 11:24:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4V0jBu2zCvhy/AQDSpR2BxEngWc3z6o6FYrGO2aB0sc6oSMIzb0fWPFAZVQw1VThJBamAy X-Received: by 2002:a17:90b:3149:b0:202:e9e9:632f with SMTP id ip9-20020a17090b314900b00202e9e9632fmr529542pjb.96.1665512646103; Tue, 11 Oct 2022 11:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665512646; cv=none; d=google.com; s=arc-20160816; b=jRxzuun2e+aUkZVNw/6O1FuUUZrSp7YyhTMncF9etKCJB3JgDIDAE9/aZ2Jd/HvDGL IqDlOeEFNISvuASQBPCIFeHib6Bpy1PU09Y+KtBSZsMGJ6mO38Vel8wGVeY2U1+OjyeL OVQrQiOpj2Pf7LSUm2K3E13EvytMM9mIV5Jyk5cxIHk7QOKe4ISedUbZe2sY5H5BPyJ5 qV+4sCSrTCWqseA0vOgEE0E4JxwQiDr5dpZdSbE6Jw0sbWsUyeDrufG4jaNdsI54MezB GM9ZK4zW7r9uGFb3aZydBdfASEskulwHRmVySctRjqAL49zsiePWo3uSartUL9hXwlqv ZE0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=ykVcV3A400m9NxlSb65FAH9wpHldwOsYk0FbUGPxnrE=; b=PknyjY3yq2fwdZHN79mZj2ZAuKI8jussx/U33U0hIp45Q7jN0KRuN0c8c0CuK1jne4 /hT9Xaz2z5e1+5jwhAmw3+F7VB6VuJNQPCRlGzFMhAO2dtrTKkBvHxGX1qR3hqnFL2lM aQEM7dqWTV+u2W8BbKJfbw4Oj4Dfqhyzh4qme+Y04oX2UHGXPPjizGyqYHuwtwvlRVQq MDYRY8E1BSwnWS/fumslQlsYnK+LS3PcGurabwj7lQJtojzRKjewmkC9/Bu8aQBIrusn H/JwzmpTpGwgpSFwMwm3UYJNHpAX9gybbmPZZKUj8eLS18p/vL3aP3zvEYeA6jIH1o5V VIYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a634d07000000b00464973ffec4si2715187pgb.60.2022.10.11.11.23.53; Tue, 11 Oct 2022 11:24:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbiJKSV3 (ORCPT + 99 others); Tue, 11 Oct 2022 14:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbiJKSVM (ORCPT ); Tue, 11 Oct 2022 14:21:12 -0400 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995C876444 for ; Tue, 11 Oct 2022 11:21:07 -0700 (PDT) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-1324e7a1284so16894834fac.10 for ; Tue, 11 Oct 2022 11:21:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ykVcV3A400m9NxlSb65FAH9wpHldwOsYk0FbUGPxnrE=; b=uvKq5Y+obbuTfxr3h1OCNfTlSraKqhN0K71Z5pRc9PaCFUkDNDxu/CNIjQ2F1C1Ekv WhMQocTcSpgul+k83iqzPAedJ18WNN+/PEZBU/wQGQrOV6l6TnH5o0u5FPGhtL061a3h B7S/40k2rpB7e/ssIXKJSPwbPENK4nxmOgMA1FtL9bO7vV+dbHNpL8etGep+AAbXT6dc bSXgHKiFZJ1sijJt6UqLgFfa+bSlT1lNeaXDU63C+UfHl1yYFiBV/mM8B1xLMDzJxr0z Vt+tVTjQ8tx6dd4HaFchIQuahF03am5/u11j5rZ4Xoyb7eEm6XHcbXpe0b9Bg5URSa20 AvFg== X-Gm-Message-State: ACrzQf3vPUNhF/Vr4vq0Wjp8M0CBY56EpoOzFJUhpltiIjPlpLeGfYHE eLcluah+QNGkE8PRBjgvPuv+U7vEdZVcPaNBXDyl261j X-Received: by 2002:a05:6870:4184:b0:136:5e73:b40e with SMTP id y4-20020a056870418400b001365e73b40emr254845oac.209.1665512466355; Tue, 11 Oct 2022 11:21:06 -0700 (PDT) MIME-Version: 1.0 References: <20220901130959.1285717-1-kan.liang@linux.intel.com> <20220901130959.1285717-3-kan.liang@linux.intel.com> In-Reply-To: <20220901130959.1285717-3-kan.liang@linux.intel.com> From: Namhyung Kim Date: Tue, 11 Oct 2022 11:20:54 -0700 Message-ID: Subject: Re: [PATCH V2 2/6] perf/x86/intel/pebs: Fix PEBS timestamps overwritten To: Kan Liang Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Stephane Eranian , Michael Ellerman , linux-kernel , Andi Kleen , andreas.kogler.0x@gmail.com, Athira Rajeev , Ravi Bangoria Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Sep 1, 2022 at 6:10 AM wrote: > > 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. I have a report that it breaks the symbolization of samples. It seems time is not in sync between perf_clock and PEBS. One thing I noticed is that the system has a config option CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y. Looking at the code, it seems sched_clock is doing some adjustments in that case. So I'm not sure if it'd work well on those systems. Thoughts? Thanks, Namhyung > > 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 >= 3 && > - event->attr.use_clockid == 0) > + event->attr.use_clockid == 0) { > data->time = native_sched_clock_from_tsc(pebs->tsc); > + data->sample_flags |= PERF_SAMPLE_TIME; > + } > > if (has_branch_stack(event)) > data->br_stack = &cpuc->lbr_stack; > @@ -1705,8 +1707,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, > perf_sample_data_init(data, 0, event->hw.last_period); > data->period = event->hw.last_period; > > - if (event->attr.use_clockid == 0) > + if (event->attr.use_clockid == 0) { > data->time = native_sched_clock_from_tsc(basic->tsc); > + data->sample_flags |= PERF_SAMPLE_TIME; > + } > > /* > * We must however always use iregs for the unwinder to stay sane; the > -- > 2.35.1 >