From nobody Thu Dec 18 06:16:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 856CDCDB465 for ; Sat, 14 Oct 2023 07:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232933AbjJNHmW (ORCPT ); Sat, 14 Oct 2023 03:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232919AbjJNHmU (ORCPT ); Sat, 14 Oct 2023 03:42:20 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66C5C0 for ; Sat, 14 Oct 2023 00:42:18 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c5cd27b1acso24219835ad.2 for ; Sat, 14 Oct 2023 00:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697269338; x=1697874138; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iPjwMRuEKu2fsJk8eO76Y756wMaad6TrvFKtRdmyvgc=; b=W3FqjgaTUX+Z10b2sszwoijXfVfsbd5Ihyzcu6ETyB/T2qd4qJjlaWWTIRM2E3L2IU s72nNG4SpPaWGuU859X7P3eTLbqRT9YikLK0O8ZQpm2+hcXAmwBfLF3Ax9AbFR5sRbfd 6lJzVeBcYAgoDeDVawaI0i3prQb5g53M/BMj4aq/apE4FnP8J64gE69Vq6YlQdO7ILKc Mh1z9IDYeSTL0SumYlUqEX/hgX3789aCv8fyV0VeoeAKjQ8VAaq2kC+adFvg8m6dl3QS +hM2wlhCT17194oApu3FIztjFATMfzE7vGi1lhEtCm2KMEs0y9dgWyC98kqLovJp4B62 q5XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697269338; x=1697874138; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iPjwMRuEKu2fsJk8eO76Y756wMaad6TrvFKtRdmyvgc=; b=ADCXIxHQv4H9HNx2pWsspr7IS1MXI8N1WNJIggREEX8lK5ylEyfnfxoaweQ2DAgDO9 2dMfoIfHCkdHOPjd+dPPhhVIPwDZE6Ijda7rnxlLVUOch5jhvmvC14z67abDOnvYku7A srzbHeWj7loY/JVjaRFNgfGioFwQmMtnf4mZJY5xXrsSy3ENOCSorLgYUGf+Q2kXndPi nexw78hSA0cgXvNmfjx90aC3zcqVQZ2CBnbqsrJs2qQVk7hh77YlvvajGG4Yq8jkw04j jPScrr6rny+Rj23P1kI3v7H0mFMEwOQiRJnYGaY/Y8aRrIJ+Z+WFkI22r9Sb06leKcs/ gW1w== X-Gm-Message-State: AOJu0YydtZaXKmbGmZAIcs3Vpb8qqNwP75UH+oVuD1bMK+hzrNOhcWDa p48gIjhO43zDD1bguWjQCq/RVg== X-Google-Smtp-Source: AGHT+IECBCN/waMn4CVxWfjTHzRQM0vxC1enXmqkv/HTlH8YN6+Hz/gOIJlqQsRCWAKJZ3FI/AW8xQ== X-Received: by 2002:a17:902:c408:b0:1c5:f0fd:51b5 with SMTP id k8-20020a170902c40800b001c5f0fd51b5mr36509701plk.40.1697269338131; Sat, 14 Oct 2023 00:42:18 -0700 (PDT) Received: from leoy-huanghe.lan ([98.98.49.106]) by smtp.gmail.com with ESMTPSA id e11-20020a170902b78b00b001c5b8087fe5sm4957319pls.94.2023.10.14.00.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:42:17 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Suzuki K Poulose , Mike Leach Cc: John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Yan Subject: [PATCH v1 RESEND 1/2] perf cs-etm: Validate timestamp tracing in per-thread mode Date: Sat, 14 Oct 2023 15:41:58 +0800 Message-Id: <20231014074159.1667880-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231014074159.1667880-1-leo.yan@linaro.org> References: <20231014074159.1667880-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" So far, it's impossible to validate timestamp trace in Arm CoreSight when the perf is in the per-thread mode. E.g. for the command: perf record -e cs_etm/timestamp/ --per-thread -- ls The command enables config 'timestamp' for 'cs_etm' event in the per-thread mode. In this case, the function cs_etm_validate_config() directly bails out and skips validation. Given profiled process can be scheduled on any CPUs in the per-thread mode, this patch validates timestamp tracing for all CPUs when detect the CPU map is empty. Signed-off-by: Leo Yan Reviewed-by: James Clark Acked-by: Suzuki K Poulose --- tools/perf/arch/arm/util/cs-etm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/c= s-etm.c index b8d6a953fd74..cf9ef9ba800b 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -205,8 +205,17 @@ static int cs_etm_validate_config(struct auxtrace_reco= rd *itr, for (i =3D 0; i < cpu__max_cpu().cpu; i++) { struct perf_cpu cpu =3D { .cpu =3D i, }; =20 - if (!perf_cpu_map__has(event_cpus, cpu) || - !perf_cpu_map__has(online_cpus, cpu)) + /* + * In per-cpu case, do the validation for CPUs to work with. + * In per-thread case, the CPU map is empty. Since the traced + * program can run on any CPUs in this case, thus don't skip + * validation. + */ + if (!perf_cpu_map__empty(event_cpus) && + !perf_cpu_map__has(event_cpus, cpu)) + continue; + + if (!perf_cpu_map__has(online_cpus, cpu)) continue; =20 err =3D cs_etm_validate_context_id(itr, evsel, i); --=20 2.34.1 From nobody Thu Dec 18 06:16:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9542ACDB482 for ; Sat, 14 Oct 2023 07:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbjJNHma (ORCPT ); Sat, 14 Oct 2023 03:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbjJNHm0 (ORCPT ); Sat, 14 Oct 2023 03:42:26 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B85ECF for ; Sat, 14 Oct 2023 00:42:23 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c88b46710bso20778465ad.1 for ; Sat, 14 Oct 2023 00:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697269343; x=1697874143; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MWOAPqRfJlFeGZpcN7zM2S+ByCB4SMNDEstgKNTnaCs=; b=AkHjspckxsgd2hxEurDMoIaqdpc26U/hAk3ns5JmzsnDOLfKFX9gPbQkDRScCIu97o TjeqYN2u7BZ3MZth50pxQRQ/YsiUWLaevy9kARkYNWCjln8AwqT68hhtvbJCqi59W1Xx kNMzbB1ELctinhUfOsfUM3ZUA0Y0Ue4bvdfX8oHY5wfSr6liGuMKPTKU0shgaWYBdcp+ 1qfRyT2fCPQfD0xBkGSe/imxdz/OCorZe4cStU1A02NrZSsuBK4gcM/bg0ywbkrpgdAQ u7YtZ6fTN4jUULn9kVzbGkg4YCEzTAUwXaS9fXqo8Ie13PtcLUcIHdX7dPSkgBwlgw5q 3KRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697269343; x=1697874143; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MWOAPqRfJlFeGZpcN7zM2S+ByCB4SMNDEstgKNTnaCs=; b=wGAzTDns/PFkYJmthLIoK3YgbXtXKEEqjvj82YJ0IdIhPxeNm3N0Eo4KdSBcjQZVxD bXxNpT7Mzri8pxdtVm6LrZkxYkd5A53JpzwxC4UiV7I278jyJC4admBYRZjW6/MeYUW3 Vcolj+M7+wa2E2BVvM8d0cIhyMDZ3CKDM/ST4ZZJl57NNZIREz9zb6PEkZGKUpBXoWgQ 4FZSU0giteTkQkyukhIWG1szrU4s0wyDLPlrNKm5dAC7IwsFn4A3Y2iO5vV/X7xcn5Um FCur+mXajXUz7QwCiauWe/ncDAKKOhaf5PBDERfYw3qhTx/c8BALN+RpLB+lAIV9Ugvo NUyg== X-Gm-Message-State: AOJu0YxTm6wf8U1XQVhJmOQE3kthPGOstMwYznPplkd5ysgUUKEGtage RJjBvPN/QZxtyoTpgx0X3XwGIw== X-Google-Smtp-Source: AGHT+IE4fFHIwPowtX28NpMjG4rwpVawnPYgQzzkATlSIS071tzOVwmxcTYq9ltdsTO+Ac9Hv4/pXg== X-Received: by 2002:a17:902:e80e:b0:1c6:2b9d:56ce with SMTP id u14-20020a170902e80e00b001c62b9d56cemr28094278plg.21.1697269342540; Sat, 14 Oct 2023 00:42:22 -0700 (PDT) Received: from leoy-huanghe.lan ([98.98.49.106]) by smtp.gmail.com with ESMTPSA id e11-20020a170902b78b00b001c5b8087fe5sm4957319pls.94.2023.10.14.00.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:42:22 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , James Clark , Suzuki K Poulose , Mike Leach Cc: John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Yan Subject: [PATCH v1 RESEND 2/2] perf cs-etm: Respect timestamp option Date: Sat, 14 Oct 2023 15:41:59 +0800 Message-Id: <20231014074159.1667880-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231014074159.1667880-1-leo.yan@linaro.org> References: <20231014074159.1667880-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When users pass the option '--timestamp' or '-T' in the record command, all events will set the PERF_SAMPLE_TIME bit in the attribution. In this case, the AUX event will record the kernel timestamp, but it doesn't mean Arm CoreSight enables timestamp packets in its hardware tracing. If the option '--timestamp' or '-T' is set, this patch always enables Arm CoreSight timestamp, as a result, the bit 28 in event's config is to be set. Before: # perf record -e cs_etm// --per-thread --timestamp -- ls # perf script --header-only ... # event : name =3D cs_etm//, , id =3D { 69 }, type =3D 12, size =3D 136, config =3D 0, { sample_period, sample_freq } =3D 1, sample_type =3D IP|TID|TIME|CPU|IDENTIFIER, read_format =3D ID|LOST, disabled =3D 1, enable_on_exec =3D 1, sample_id_all =3D 1, exclude_guest = =3D 1 ... After: # perf record -e cs_etm// --per-thread --timestamp -- ls # perf script --header-only ... # event : name =3D cs_etm//, , id =3D { 49 }, type =3D 12, size =3D 136, config =3D 0x10000000, { sample_period, sample_freq } =3D 1, sample_type =3D IP|TID|TIME|CPU|IDENTIFIER, read_format =3D ID|LOST, disabled =3D 1, enable_on_exec =3D 1, sample_id_all =3D 1, exclude_guest = =3D 1 ... Signed-off-by: Leo Yan Reviewed-by: James Clark Acked-by: Suzuki K Poulose --- tools/perf/arch/arm/util/cs-etm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/c= s-etm.c index cf9ef9ba800b..58c506e9788d 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -442,6 +442,15 @@ static int cs_etm_recording_options(struct auxtrace_re= cord *itr, "contextid", 1); } =20 + /* + * When the option '--timestamp' or '-T' is enabled, the PERF_SAMPLE_TIME + * bit is set for all events. In this case, always enable Arm CoreSight + * timestamp tracing. + */ + if (opts->sample_time_set) + evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel, + "timestamp", 1); + /* Add dummy event to keep tracking */ err =3D parse_event(evlist, "dummy:u"); if (err) --=20 2.34.1