From patchwork Wed May 12 14:51:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 435616 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp5066168jao; Wed, 12 May 2021 11:12:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxpN+UlPCmPx0tXUQ5ZMNneEHWFN7ajbR8uF6ua2h97xgKcsX1clw5EoS3BtwwyXzlIrAk X-Received: by 2002:a92:b111:: with SMTP id t17mr33137113ilh.208.1620843151128; Wed, 12 May 2021 11:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620843151; cv=none; d=google.com; s=arc-20160816; b=Rn8lirQBmAYh9ADUgd+6e0f40RGFzBCScf26sr40BjE/qs2DvuaT0h9BBeoSx80A8+ qFVyVld2PjLT1U4V898Tm6p0wx2m8EhqzlLs3DTctag0MW6+XaH7LroJXjNohxFDZGry ZKKJsSF6JZZa9do7iOHHTnNzaumU+TlE7Glq9Yn6VLUAWW/nYEy+XmCMEOAUMk/BzxdY ZfnSJpmWHvngwx9/mvsB/XkQhSLAYEzmGLHoqh31KA/bqBEFG4cBX6XxrG+qOIbsZ06f qa56S+jBGMFnuRcVsMZrtGrkEtXadctV4CDyFCj9baPqlNLF3pzG4rTG1Qo/w0Fy25Sq ud6Q== 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=yvPCPR/cBX+xaEDU+mJkxMIfXyCMbdrtVGBkuyjEvfU=; b=PhOE8NgxJYiJkidGKa/uUB81DOh6bXepYbmTmRuC8j2aWwh3GgFH5uEYsbXrofjlCo 6F68BA7PvkEy1wmIrJcrKEA0kJeCl/MN1MR12QCq/1LGjGSVoGhJSZuvyXRwR7nwzTgd ptUcO+b/AIRk1losOfuE3X3RuIJAZq8p0ZiDdvHbnCjD6ps/Z2q/MTNSDNA7fcExIOb3 33R9OTiKzCsx/Rr+rK45n6aWtDCVdLD9LAJK/zwjrAaiHVZZqVjq/9J+ZOKvytDuMPrL ifzaOERd4bIrz0nQ7+i6hKmm8RpTn9EGM0/Xw7vSeXuaftlGWizxbVE7IEn+77xbc6bl Z6NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qJiYbRR6; 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.11.12.30; Wed, 12 May 2021 11:12:31 -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=qJiYbRR6; 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 S241902AbhELQbF (ORCPT + 12 others); Wed, 12 May 2021 12:31:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:40962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241014AbhELQ0O (ORCPT ); Wed, 12 May 2021 12:26:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2077D613DF; Wed, 12 May 2021 15:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620834544; bh=/WpdCAH7OBdM+Gjc1GJs0uSStzoOduD2q4THrHjr1B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJiYbRR6U0Wst7/TIyyh5mHR/w/KBSggxBZ9EjXMsSOnSzaZWkkK0GaGZRFh0poUI EKM+PMEO0D86XDAI/3h5NwwntGrepBT7MBwdZLzIEY6jEyHtkHC5pbix/6lSwIK+Ld OGcLxxe/wzSBWbaFggdZqZ6jzlAqZGWLK69qURDU= 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.11 586/601] perf session: Add swap operation for event TIME_CONV Date: Wed, 12 May 2021 16:51:03 +0200 Message-Id: <20210512144847.148436801@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@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 25adbcce0281..052181f9c1cb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -946,6 +946,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); @@ -982,7 +995,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, };