From patchwork Tue Mar 8 20:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 12774379 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 2DA0BC433EF for ; Tue, 8 Mar 2022 20:56:21 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=c5rlJReC01P2cM8Q+10JXV6Du7IsFrcuJKkttYof24w=; b=XSJCcx4Kdx1Rqo +5z3uyH1ZlavirUn6ffSbCNa3hK2cvekHwm5QdCo2TnrQjmz9DlfoMpMLCRsY/Yxt023EzQoq5Gw2 Mny3LwRMruqK6bxzPQx9HM8Dy39wO9pyyRuMSQnwRZKd3kgbrhjppd+lW2+AKXGQcU0Adg6NzEQ/O y6zQF/E5xKEj6T2z3LPyMuyNCtRnIE1Dv0K0TCQw9FsAaL7UOiVFWoBk9fhVKPLmZAYBxGrknp6DK gaSmxS3xQWTiIJXbf803f/TKZslliaxlkqueoJNuP9nwiYxbhhztgPLZNS855k58cmggtMaCRwSlL P7bSZGDPQE/LaN9iMDLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRgq2-006DP6-Gs; Tue, 08 Mar 2022 20:53:47 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRgmd-006Bs2-Hd for linux-arm-kernel@lists.infradead.org; Tue, 08 Mar 2022 20:50:19 +0000 Received: by mail-wm1-x32e.google.com with SMTP id i205-20020a1c3bd6000000b00389d0a5c511so29912wma.5 for ; Tue, 08 Mar 2022 12:50:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xe7R99xlGwoKuAS3wrEqyXZp3yI8XEYJM9lw/vO8NYg=; b=tYKOgv1979h8LZb91Na6znYmERgLvMDR7BoDXLdax/BqQ5weQ/1uUEHgSLUszHDlD7 jpvArASGGFcjWsazR23WkbFIGp+xXkEte8YuhAToaW5OLSP8xUQVzqBWShV7CYRFC17I iotPeM9M2Jfz4jVPc19tYkhb9putbA5hNz75MLVcwyGZNVpKrWPFGP83qWNa+2M3hOKX XYneBkZHPwRMyIH6fDSG6Eg/noA3nnO3qgQU9KZM9ItcnNb0kKp/+C28SKCP1sV3sGF4 y2EFsy1+PuyjUcr/V99Sygk36cNEsxI12lislEK8hOhFdYc8LaEukpEzATYfuyL3IRNn MwUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Xe7R99xlGwoKuAS3wrEqyXZp3yI8XEYJM9lw/vO8NYg=; b=8A160gLcERIAH++iwM8mhg278wNSoCrsbgJCJRq9N0ycD7y9p8dgLEzCqoS/6bXb5/ iLZJEPK+N7lYE/xL6dgNwGIhLZcZClpCKnefU2l7/Lp31VB3EkNyXkda21qLRF2bwKdb iGYttttmeExI2+saFpB4CB43K26H7eKv9MAjb5Mssb5y9kqs3MTTaRDEmyG2DZnQxDiB qmo2l5nqndOIhDx8sbgTru1b5WJt5t3ViZE/EYBbk0Hhx/OJRnIMROZzVMmmEeUwmdoL FMvilvprV4eBCZquGukBjrmre8qzUjAJjCPR5DquzL6hUuz44W58bDP+0mjFjQKqm0+H JMQA== X-Gm-Message-State: AOAM532vptdgCuFUQQZdqbAghoHubF5nzNm4a32Q3pVnyZK5Ed8I2nmD XcVYiHYfSPBZ0s/25w6Sqxcsrg== X-Google-Smtp-Source: ABdhPJxCHJnxJZE/r6ZL7nJ0y7w9OoRJ4o+m2KyamsuT/8NnTRDXGrRnqDN1KOnJRNiJide62pdVkA== X-Received: by 2002:a05:600c:3ac3:b0:389:adb4:e7a1 with SMTP id d3-20020a05600c3ac300b00389adb4e7a1mr852701wms.136.1646772612778; Tue, 08 Mar 2022 12:50:12 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:546d:7d59:1703:bf96]) by smtp.gmail.com with ESMTPSA id p26-20020a1c741a000000b00389ab9a53c8sm3245758wmc.36.2022.03.08.12.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 12:50:12 -0800 (PST) From: Mike Leach To: suzuki.poulose@arm.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, Mike Leach Subject: [PATCH 10/10] coresight: trace-id: Add debug & test macros to trace id allocation Date: Tue, 8 Mar 2022 20:50:00 +0000 Message-Id: <20220308205000.27646-11-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220308205000.27646-1-mike.leach@linaro.org> References: <20220308205000.27646-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220308_125015_723797_70D0118E X-CRM114-Status: GOOD ( 12.19 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Adds in a number of pr_debug macros to allow the debugging and test of the trace ID allocation system. Signed-off-by: Mike Leach --- .../hwtracing/coresight/coresight-trace-id.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c index ce6c7d7b55d6..8dcb698b8899 100644 --- a/drivers/hwtracing/coresight/coresight-trace-id.c +++ b/drivers/hwtracing/coresight/coresight-trace-id.c @@ -71,6 +71,27 @@ static int coresight_trace_id_find_new_id(struct coresight_trace_id_map *id_map) return id; } +/* #define TRACE_ID_DEBUG 1 */ +#ifdef TRACE_ID_DEBUG +static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map, + const char *func_name) +{ + /* currently 2 u64s are sufficient to hold all the ids */ + pr_debug("%s id_map::\n", func_name); + pr_debug("Avial= 0x%016lx%016lx\n", id_map->avail_ids[1], id_map->avail_ids[0]); + pr_debug("Pend = 0x%016lx%016lx\n", id_map->pend_rel_ids[1], id_map->pend_rel_ids[0]); +} +#define DUMP_ID_MAP(map) coresight_trace_id_dump_table(map, __func__) +#define DUMP_ID_CPU(cpu, id) pr_debug("%s called; cpu=%d, id=%d\n", __func__, cpu, id) +#define DUMP_ID(id) pr_debug("%s called; id=%d\n", __func__, id) +#define PERF_SESSION(n) pr_debug("%s perf count %d\n", __func__, n) +#else +#define DUMP_ID_MAP(map) +#define DUMP_ID(id) +#define DUMP_ID_CPU(cpu, id) +#define PERF_SESSION(n) +#endif + /* release all pending IDs for all current maps & clear CPU associations */ static void coresight_trace_id_release_all_pending(void) { @@ -82,6 +103,7 @@ static void coresight_trace_id_release_all_pending(void) clear_bit(bit, id_map->avail_ids); clear_bit(bit, id_map->pend_rel_ids); } + DUMP_ID_MAP(id_map); } for_each_possible_cpu(cpu) { @@ -112,6 +134,8 @@ int coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map get_cpu_id_out: spin_unlock_irqrestore(&id_map_lock, flags); + DUMP_ID_CPU(cpu, id); + DUMP_ID_MAP(id_map); return id; } EXPORT_SYMBOL_GPL(coresight_trace_id_get_cpu_id); @@ -138,6 +162,8 @@ void coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_map *id_ma put_cpu_id_out: spin_unlock_irqrestore(&id_map_lock, flags); + DUMP_ID_CPU(cpu, id); + DUMP_ID_MAP(id_map); } EXPORT_SYMBOL_GPL(coresight_trace_id_put_cpu_id); @@ -152,6 +178,8 @@ int coresight_trace_id_get_system_id(struct coresight_trace_id_map *id_map) coresight_trace_id_set_inuse(id, id_map); spin_unlock_irqrestore(&id_map_lock, flags); + DUMP_ID(id); + DUMP_ID_MAP(id_map); return id; } EXPORT_SYMBOL_GPL(coresight_trace_id_get_system_id); @@ -163,6 +191,9 @@ void coresight_trace_id_put_system_id(struct coresight_trace_id_map *id_map, int spin_lock_irqsave(&id_map_lock, flags); coresight_trace_id_clear_inuse(id, id_map); spin_unlock_irqrestore(&id_map_lock, flags); + + DUMP_ID(id); + DUMP_ID_MAP(id_map); } EXPORT_SYMBOL_GPL(coresight_trace_id_put_system_id); @@ -172,6 +203,7 @@ void coresight_trace_id_perf_start(void) spin_lock_irqsave(&id_map_lock, flags); perf_cs_etm_session_active++; + PERF_SESSION(perf_cs_etm_session_active); spin_unlock_irqrestore(&id_map_lock, flags); } EXPORT_SYMBOL_GPL(coresight_trace_id_perf_start); @@ -182,6 +214,7 @@ void coresight_trace_id_perf_stop(void) spin_lock_irqsave(&id_map_lock, flags); perf_cs_etm_session_active--; + PERF_SESSION(perf_cs_etm_session_active); if (!perf_cs_etm_session_active) coresight_trace_id_release_all_pending(); spin_unlock_irqrestore(&id_map_lock, flags);