Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4752951pxj; Wed, 12 May 2021 12:26:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoLDnpqyfjNopnjxZExL0zmieVPY5/uSILmNqPnCJThc2DFucGtFGd1Bol/mxfkq1VSgsZ X-Received: by 2002:a05:6402:3488:: with SMTP id v8mr44512521edc.51.1620847456949; Wed, 12 May 2021 12:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847456; cv=none; d=google.com; s=arc-20160816; b=OZnIk4T0iOdX8wKCg+RMd0v4PDKvmsVstKsl6pku8FOkIFZiqLjiYoHh+OFuu3MUCe 59ExsPagE4lZAUfuoh9Kj/OCF/Hwoko3PUARKKakg1F71zWAlf59s74tHWss+o2ajnbL gpZq9CPQCz1JeuAO6OoqNGJ6hMWuf8bdCSnwZ7lealH0VHdhY2lDPev6FZ6Yn5yGTGxp TzPHnCjoTpLTdQC1WJcVxW82RE/ABJ/d+tYWwEmQJZREtXaYwUDcYiMgLeJpx71VKkTT LHhvsPEWyAkSXAoyQeozfjbjdWlJBQzQg2vaVupCXqzPxIPQEI6klWgGaKG1xQwz0bE7 EIXw== 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=Aa0I/HsKnCmL33bsZ3dNPGXrZv5ku2jTVL0xOivkweg=; b=wvfBf8k1x/Xp4RYqYZvGNWsj5AIx3hTUC1Tdv94Z9GrQblj2pnZbGidTBxDu0GM2IB W7FeIq7aLCWbcqkd//lAdg1qK8u8JdOk58uUl2l9sXFETaS6/zpZeGSEs1nFRL7VrxDr UEC2F/Z6vTaULN+noABDVoepoWTzs/lpwO2/4NpgWDzJ7evf0BwIDd27fm8kUV1FIMzG JrmY5B8EOVShVpWHBMriBAGwUjJ9u0VYFESoKEf1rUTBLFZmBWrc+0AjTgBKGSWSdAFe qPsyRA4/yvZum8GPggjMJPyxmF9aiusKG6qk8iQBOJm6mAJmgXhtxW0VWpdRqXP7YGWI l/rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EDVUHSlI; 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=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 bl1si705407ejb.408.2021.05.12.12.23.52; Wed, 12 May 2021 12:24:16 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EDVUHSlI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379540AbhELTT7 (ORCPT + 99 others); Wed, 12 May 2021 15:19:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:42358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244618AbhELQuz (ORCPT ); Wed, 12 May 2021 12:50:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 532F761D62; Wed, 12 May 2021 16:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620836228; bh=qYzOQYvQRdsH5Vz40natoQqdoyc77/FzAM5ICUFfWMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EDVUHSlIwv3XDlARhDjqDNvjrE/0inCUt2pYaO1HJf+Lju61bKHCoanEQLIwL3K01 JQmCH+5x0J0pbWAi2d+phr89/WhulEI1+GSDrUKRyuHARn+IMvrWgWmhkveu7ovEkv 6JZIFomblACxK4tyUP5d6QC6//cAAAvGowOe0vfE= 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.12 662/677] perf session: Add swap operation for event TIME_CONV Date: Wed, 12 May 2021 16:51:48 +0200 Message-Id: <20210512144859.359413885@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 859832a82496..e9d4e6f4bdf3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -949,6 +949,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); @@ -985,7 +998,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, }; -- 2.30.2