Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3358062pxy; Sun, 25 Apr 2021 22:58:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhm1oPndinKw2jbGIrN6KwBh/sgGMAZetTIuWsJdGyQeD3J+qrF1xNI0PgYOyc/KU/lbJS X-Received: by 2002:a50:c004:: with SMTP id r4mr18603772edb.192.1619416710519; Sun, 25 Apr 2021 22:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619416710; cv=none; d=google.com; s=arc-20160816; b=WmdQPtPU3l5eCs9EFbbJSEztsNehT0fJBqjo4D+xUQA0/A2qI2dEF1nKldrqao+rsn C/xMq4i5bUx8y3X7HjNdtZMVJqlMGnOES7VHt9iqp8uMeJejLODII239/BGhU51+KxLL m+oenxG59K21N/MqI5MO/mN2d4tAdxL9XwloMEYFsq2zMwFyVFbd7Sm4mjCA9YsLDCV+ MaX7ZBilhfXH1fT7b2PU/CoP+O09tchxeNHgczbZDpvvfzLXQWMinlcxFo8dl9za2ng9 QGcmWmIsE4e9f409aUL4+Mc+tfWl/N5yn08voJ2c+0C8iHKR9qkdv2eMPRXC37TnSrO9 tS6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:to:subject:ironport-sdr:ironport-sdr; bh=mRTDrt7vF9G4zxt4ausWiy8ybbbf1lqVhVaWfdh7az8=; b=v6KDgrw6ceTU2K1yTMcYNZ9jwmylp7TfPgq3adfvGePCF9SKSbvGsRz9oq/i8aUHN4 fpoP1y8WmNF8IT51F7xWKI0zNresgTZeqxe5FG+865/cMyjp8k9J50MPl8NRphZ/sU1Q B4o4zW1+2rXouetQkhic9F9xMh5gjr5uu3jslPAGNcWiCI/H0Pm+a3iIlFg/yzXjhXit W0jHU59LVyPFyqAzlurSaKopzzVAhSJFo32My7gZVQH2wes72fw3+KNd3eqPgtHq1z6j w3xuG7EiFw1rzOpB4TG84t0bJRib7gS3wnVtbS1c3XXwqx1VTClceM0Krj3/YAvXVPYa 6MyA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si12344241ejj.682.2021.04.25.22.58.03; Sun, 25 Apr 2021 22:58:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231888AbhDZFzw (ORCPT + 99 others); Mon, 26 Apr 2021 01:55:52 -0400 Received: from mga14.intel.com ([192.55.52.115]:45935 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhDZFzw (ORCPT ); Mon, 26 Apr 2021 01:55:52 -0400 IronPort-SDR: wiGbxDK0wU7SZQxXcPnBNjQ3ol32X5wEWOOx4ohhUkh3VocVHMmF5OcEY8Ic6Jh9Qgg72czlfs LHxmth/UrLaQ== X-IronPort-AV: E=McAfee;i="6200,9189,9965"; a="195837768" X-IronPort-AV: E=Sophos;i="5.82,251,1613462400"; d="scan'208";a="195837768" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2021 22:55:11 -0700 IronPort-SDR: Ym5rzJuV8O6vKtLMfvZYxiPZwJ5QlVFB9tOZWynsi6WoPFiIyan1hv6mmXVl+M0jr9AvDwLWQ5 AlpMfN0C++OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,251,1613462400"; d="scan'208";a="422509303" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by fmsmga008.fm.intel.com with ESMTP; 25 Apr 2021 22:55:06 -0700 Subject: Re: [PATCH v1 1/3] perf jit: Let convert_timestamp() to be backwards-compatible To: Leo Yan , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , "Gustavo A. R. Silva" , Steve MacLean , Yonatan Goldschmidt , Kan Liang , linux-kernel@vger.kernel.org References: <20210412083459.462817-1-leo.yan@linaro.org> <20210412083459.462817-2-leo.yan@linaro.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <9efe1e7f-a0e3-7908-acf1-ca4a26fa29b9@intel.com> Date: Mon, 26 Apr 2021 08:55:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210412083459.462817-2-leo.yan@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/21 11:34 am, Leo Yan wrote: > Commit d110162cafc8 ("perf tsc: Support cap_user_time_short for event > TIME_CONV") supports the extended parameters for event TIME_CONV, but it > broke the backwards compatibility, so any perf data file with old event > format fails to convert timestamp. > > For the backwards-compatibility, this patch checks the event size, if > the event size confirms the extended parameters are supported in the > event TIME_CONV, then copies these parameters. > > Fixes: d110162cafc8 ("perf tsc: Support cap_user_time_short for event TIME_CONV") > Signed-off-by: Leo Yan Perhaps could make use of a helper like the one described in my comments for patch 2. Nevertheless: Acked-by: Adrian Hunter > --- > tools/perf/util/jitdump.c | 31 +++++++++++++++++++++---------- > 1 file changed, 21 insertions(+), 10 deletions(-) > > diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c > index 9760d8e7b386..67b514c38a43 100644 > --- a/tools/perf/util/jitdump.c > +++ b/tools/perf/util/jitdump.c > @@ -396,21 +396,32 @@ static pid_t jr_entry_tid(struct jit_buf_desc *jd, union jr_entry *jr) > > static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp) > { > - struct perf_tsc_conversion tc; > + struct perf_tsc_conversion tc = { 0 }; > + struct perf_record_time_conv *time_conv = &jd->session->time_conv; > > if (!jd->use_arch_timestamp) > return timestamp; > > - tc.time_shift = jd->session->time_conv.time_shift; > - tc.time_mult = jd->session->time_conv.time_mult; > - tc.time_zero = jd->session->time_conv.time_zero; > - tc.time_cycles = jd->session->time_conv.time_cycles; > - tc.time_mask = jd->session->time_conv.time_mask; > - tc.cap_user_time_zero = jd->session->time_conv.cap_user_time_zero; > - tc.cap_user_time_short = jd->session->time_conv.cap_user_time_short; > + tc.time_shift = time_conv->time_shift; > + tc.time_mult = time_conv->time_mult; > + tc.time_zero = time_conv->time_zero; > > - if (!tc.cap_user_time_zero) > - return 0; > + /* > + * The event TIME_CONV was extended for the fields from "time_cycles" > + * when supported cap_user_time_short, for backward compatibility, > + * checks the event size and assigns these extended fields if these > + * fields are contained in the event. > + */ > + if (time_conv->header.size > > + ((void *)&time_conv->time_cycles - (void *)time_conv)) { > + tc.time_cycles = time_conv->time_cycles; > + tc.time_mask = time_conv->time_mask; > + tc.cap_user_time_zero = time_conv->cap_user_time_zero; > + tc.cap_user_time_short = time_conv->cap_user_time_short; > + > + if (!tc.cap_user_time_zero) > + return 0; > + } > > return tsc_to_perf_time(timestamp, &tc); > } >