From patchwork Sat Oct 14 07:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13421932 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 366F6CDB465 for ; Sat, 14 Oct 2023 07:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=COzviP/4q3YPwr7aL7kL0cX++KRSfUK9D7qXtCcanO0=; b=ZX5BKwzl8eTHkP WGQzfGpo2b70Zqr3MynAsxzoKEqfCMQh3p/khbcS5sgbyZE/ssakdhlLFBxkq69/uly6dbLUaf6p1 JnOzCfO/n+yn2SBXsWllSV/0NRSs3McypbsizKQ+GdmdEVHqYUuUoQVuYJ7OKT2xaYWavOUxMw7EO gg4wt6btkAhNsYD/lGIUCJrdSyzKKuyA0lcODUUkI0Lel14Ry+I9fMnhqaSRsFvl8s5x/hnxVAZWO QY8sZs2j+ePw0BVj2xhRPladNvHt4i91WtDj3dnXe8AUA0eQReb5fzuNeV/Jo8qox10sg0OaTsKwN o5HDGVzpSkK675UidkeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrZHz-004vJk-37; Sat, 14 Oct 2023 07:42:23 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrZHx-004vIj-0E for linux-arm-kernel@lists.infradead.org; Sat, 14 Oct 2023 07:42:22 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-578b407045bso2135998a12.0 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=lists.infradead.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=b3f72Xj2Ahle7H86S2om/Ktrgvkf1J9adidZZ5Hm1v+XXpPQwLUvzPwniNm8x5Uro4 vUUbhZDx7i7B2Be9ac6kugPC9x3bTYoiIZs3yRbz+ow0mQ/2+DIWRbOtjPamkZaBhrFl fezHm4cHplOCdtdHJ5dEj3W2dZvBc0ojaBoTO2EgufsZtF+a2jyBe7/WpfB7XuHlLP+K ZKMP2TvgLuFuavPmsb//WucV21l0b/NzsFTwTTBMJSYr2ID9buJtmFy016S5WDWCfU+Q EY78fkzC24TgLRNyzpkhqgXY8zy7DVBP3RLDhItRjkqMm4GSxHC8J9K0uO4Eb3XhUizJ Fe/w== 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=lQfrZbRhGPKnKWdh/CVdLyE42kgto22XCn1cq8zTJDuCsQ2E7YrRdFTP6XpKqpv9ye /0d0PT/xb60T3pIaLTql1aNNAD7g82lNaACKFxbUag4LbWdP7bM4B+p9vXwXzYZ5mKLQ 9oue+R5OXP6s0U4H6+6g8ivbG42s0bAM0Is0utDKBtIS5f90YWFFZx4WKvj1Pl+p+puB CmVeZFyEqfVE6O0Jt2SfdQzPEco7qQGiqTjfyswYazxmxUIBcUP25+TRJPBFRLbsHZu+ wb5W2q8/FPuUJVRj0kJ6ssei8CvJYqo7lZqBcD3dF9Wa7nFvOxI3QW7xZFUePlQFTGN6 z5FA== X-Gm-Message-State: AOJu0YyXdLOZOxJoyZtTWi38iloFjIy6QwI6tiegySjLK9H+Y8LDmyU5 ddbvC37ijNEAlQ0iXpHbi5A43g== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231014_004221_113100_9FCC21C0 X-CRM114-Status: GOOD ( 17.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/cs-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_record *itr, for (i = 0; i < cpu__max_cpu().cpu; i++) { struct perf_cpu cpu = { .cpu = i, }; - 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; err = cs_etm_validate_context_id(itr, evsel, i);