Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4631518pxj; Wed, 12 May 2021 09:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5Y2NmhdQoLjnSZhSnljgYfpJRuk14T7pCs8cVzsiSvQCd3yXf2ROJAqhxKgSbU0xdztBG X-Received: by 2002:a05:651c:151:: with SMTP id c17mr26772202ljd.398.1620837496178; Wed, 12 May 2021 09:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837496; cv=none; d=google.com; s=arc-20160816; b=vUrLxIl0tRxcl4oGfAlYMOdq3H56FQzp3RA2w+SMDgzD7AJwhAlpfOMYyV97Jo0oP4 2qO04Twxx3jtVi3YF6cVP5MgMDPZYMtrRDM4g76UMAz+5jsS0djPHmiX0GndFq/dpdN4 UM6k4QNtGmXERhuG5gzG+46skPymp8RszPhiyqva2jKIzMzZOs5fWiK+kxK+q8m1Q8+z WSD14SwuQKnx5Otjreuu9Mk6YDkRH3bUtFmDFbrY40iheKfNLikytqRuz6ev35BliyIP cQIjrCPdqbWWtGGu9MPwRK9sJJqSFf95ZjxI5+0nZBoHXJFVFhUUw77aU0e9RnM+jkXg 6FDw== 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=EMSir4PuqL50SmNZ6QwZBblH4A/ZiCT1ACUnwUIgQgCqr0xzZPggghQBuy4UjyXaDz 4V/JkoUFOMOrxDsJ+/4RlovasUl7HDUWdIc5QG2XkaAeYT9d7M6ONdcrMF6/Ez3DEtSn JeFgUU9ESUhOgADPs2bml1tuxPQ6TsvVSagBWmHz0XfIwFekA//V0ObMDzCbkLrk4ubr TZNz7XwEU0PfAxGR+c5tEWpFcnU8JgWwGN7weKh2MWvFhPpxpheH+iiIUUHt/VEjqFVT o1LjND/HMpuSbgMvyO9srXsBLZDAuUs2+ZRa7ldYmrSuFJBEM2m3nZFVitAdF7+ixUI8 5ovQ== 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 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 i23si273665ljj.294.2021.05.12.09.37.43; Wed, 12 May 2021 09:38: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="1q/CyK9x"; 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 S236316AbhELQhc (ORCPT + 99 others); Wed, 12 May 2021 12:37:32 -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 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 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, }; -- 2.30.2