From patchwork Wed May 12 14:50:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 435582 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4977566jao; Wed, 12 May 2021 09:17:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbSO+4SsoPiQkpySBp+sI/2UEtyUcfE3iAEAiQHNMp7WliwQQS2jKrTP1SgZvx3CggGPi2 X-Received: by 2002:a05:6e02:118f:: with SMTP id y15mr6006344ili.52.1620836269033; Wed, 12 May 2021 09:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836269; cv=none; d=google.com; s=arc-20160816; b=0Jm83+j74OLBvWLdKDzeDJdnH6HYsjyPCGNaeuPkwI0lB8RvUSw2zNzRqtDsc7/7Vo pOfcokZ4bSkGY6/i3CREOJyunVveYUld6Hqy/gGmBZOfyOdYPjbLu2ASR8Nz1mJT6Acl nGqMn/FisC5TxRv7FegO3ZBY4VMnYyXJeNldVPtAneoSuAHcHTf+dJU7V3+FCR267oeB BmXwq+yk2EnJpU0uT8HPJzJeiXjNgNk1lnv3pM/gRpAK1W4/cd463UqNmO++NEZQA6n2 awpA+aj3LjSLumKvzst+pPZaZomCCTK+CCh/TCzS6FzrHE2VdDKD1Sk2Svg9BkTakGa+ 8VuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KS2o8iFYeKKDOqBQYHXou5nEYiw87nI21kwsyO+eN+c=; b=royIyZSkf9hrU/nlVb3Lc1ErUsaAgbwcI6xzegoTwAED9hcl1vTDezdMxO9xV8c1mr WeAocnsTo+l9BNPc+PClkZRqoVhpXcVpTJRhfSSHASOpospLElIwMqwe7BwNbfl/P+4v dNpJzKDx5fgvAYUzaGXzvB4Qx38kRNIZ4RtwffaXMGzq4HwzNnTkSYWl0yXL2oqBaG09 Is+0cJUu8rqZjjHzNFthsu8WuMk1AT9k+mJ5ugV33Q8KgKVIn+btRofXi+Taxhzd0q6V l1x0K+dENBvwgnVKL597Vw74UdQ5sbK+wyHjN0QsatdVm4H3XbBdP0b0Ho1V6MAyqB71 2e5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1q/CyK9x"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si330223ior.12.2021.05.12.09.17.48; Wed, 12 May 2021 09:17:49 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b="1q/CyK9x"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233658AbhELPvK (ORCPT + 12 others); Wed, 12 May 2021 11:51:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:40104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236745AbhELPqC (ORCPT ); Wed, 12 May 2021 11:46:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D9B1E619B7; Wed, 12 May 2021 15:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833016; bh=aIPXcInevJp710qACFbSnlNQ8/rrDQKnD5jE89U4u+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1q/CyK9xn0EBbgfQzBaynR/78G+m8y8OBfwOwGf7RlfRbVWO7cCHXEFZHxCQJNb5l KC4LR7lIte4yERozlSWzzHpktQ05h2+ZqaLGWzAr/X1XZ9MwOUDVGErNAcVLvCe8G9 b1yq53znzRTYRWWjBsvEj9I8FI0md1FJ8KpuJ2yg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , "Gustavo A. R. Silva" , Ingo Molnar , Jiri Olsa , Kan Liang , Mark Rutland , Namhyung Kim , Peter Zijlstra , Steve MacLean , Yonatan Goldschmidt , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.10 514/530] perf session: Add swap operation for event TIME_CONV Date: Wed, 12 May 2021 16:50:24 +0200 Message-Id: <20210512144836.650520829@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Leo Yan [ Upstream commit 050ffc449008eeeafc187dec337d9cf1518f89bc ] Since commit d110162cafc8 ("perf tsc: Support cap_user_time_short for event TIME_CONV"), the event PERF_RECORD_TIME_CONV has extended the data structure for clock parameters. To be backwards-compatible, this patch adds a dedicated swap operation for the event PERF_RECORD_TIME_CONV, based on checking if the event contains field "time_cycles", it can support both for the old and new event formats. Fixes: d110162cafc8 ("perf tsc: Support cap_user_time_short for event TIME_CONV") Signed-off-by: Leo Yan Acked-by: Adrian Hunter Cc: Alexander Shishkin Cc: Gustavo A. R. Silva Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steve MacLean Cc: Yonatan Goldschmidt Link: https://lore.kernel.org/r/20210428120915.7123-4-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/session.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 22098fffac4f..63b619084b34 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -945,6 +945,19 @@ static void perf_event__stat_round_swap(union perf_event *event, event->stat_round.time = bswap_64(event->stat_round.time); } +static void perf_event__time_conv_swap(union perf_event *event, + bool sample_id_all __maybe_unused) +{ + event->time_conv.time_shift = bswap_64(event->time_conv.time_shift); + event->time_conv.time_mult = bswap_64(event->time_conv.time_mult); + event->time_conv.time_zero = bswap_64(event->time_conv.time_zero); + + if (event_contains(event->time_conv, time_cycles)) { + event->time_conv.time_cycles = bswap_64(event->time_conv.time_cycles); + event->time_conv.time_mask = bswap_64(event->time_conv.time_mask); + } +} + typedef void (*perf_event__swap_op)(union perf_event *event, bool sample_id_all); @@ -981,7 +994,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_STAT] = perf_event__stat_swap, [PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap, [PERF_RECORD_EVENT_UPDATE] = perf_event__event_update_swap, - [PERF_RECORD_TIME_CONV] = perf_event__all64_swap, + [PERF_RECORD_TIME_CONV] = perf_event__time_conv_swap, [PERF_RECORD_HEADER_MAX] = NULL, };