From patchwork Mon Jul 4 08:11:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 12904874 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 478E4C43334 for ; Mon, 4 Jul 2022 09:00:57 +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=O/78d7rQFEmmzxDi4RXhaVxf1EWSS2ocsKbBGldewUI=; b=RwAc5Zb0SHMccY q4gNXt7iRHLwjosp/x6+JxO5TQ27J6KbAY24mBvUWyiTDA0dSm4jtst1AYSRm+qTpANUj4hqf6MCc 5j9/KdlVX8LXLtIQMoBh6L7p6jpJdPr0DtdTffPexJkxsg5qhnDvl4qu9qjjgBFEXQiL4hP5490q0 raqRm+WIFYbkGlbwk1EGNWCVTNfnMVswJfJIEPUu+rgq/bdmdl21YA6dmh6D/gKjd90j6tf/vzGIz Iuy56vDMjSi/STBhK6+w7weHpCDRnwmeH4964jFQHn/Z6V3WnQ/z59oGNlvRE/LZnOYTJ87VSn8d8 1FDxoet4IrCrrI89q4Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8Hvu-006EFB-5B; Mon, 04 Jul 2022 08:59:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8Hvb-006Dv2-VU for linux-arm-kernel@bombadil.infradead.org; Mon, 04 Jul 2022 08:59:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=References:In-Reply-To:Message-Id:Date :Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PTooRwbsdLD3OOIuzOYJzIkCxcUPBK7VZILGtwDxgv8=; b=WzYupgQgS7RMOYnFOT70LPLdOE UWJ1uNWQNcMulT9aCf75JVmhd3QKfZNxh2hq2pJjRrETEWqOYaMFgp/PMjAv6L9HSZhk8I0Xb2NmS 9ZDMk0AYkklU9RhROHUfZKsVRKKHo+RE6VruD6WR8b3gWbul0O/64jrTQuNevjanHU/tZEKniTNdU K6RqoG8NOB35JyNoZ+AqF0q2t8ylao21uJHqdIAOoWeYK80RyhCWPLFoP4Nmjeiz3ywVcdAsA94lb kusfZmhZA3ol5gGNC0RQwwoxWHxbO2Fkr6v1m98gyYVbim6yEM3zEYIk0Tywklik3FBBf+vbS8YMs iLOG2hkQ==; Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8HBn-00H2qR-M5 for linux-arm-kernel@lists.infradead.org; Mon, 04 Jul 2022 08:12:21 +0000 Received: by mail-wm1-x32c.google.com with SMTP id bi22-20020a05600c3d9600b003a04de22ab6so5155934wmb.1 for ; Mon, 04 Jul 2022 01:12:05 -0700 (PDT) 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=PTooRwbsdLD3OOIuzOYJzIkCxcUPBK7VZILGtwDxgv8=; b=PQ4bNkRRVNU2cYS7j7W1mfEhb+fKztLHPOlexnGD/LLD5abRR2eteBvUPs0dD8PpxK njYPHJncc7vU7yD8ODW5mtlpu6LExnSOvJxyJ4zuavRr7KMPVE1gLRwzzPBpacjopt3c rQ7Q1SQfFk7rTHU4MVAN5u62VHSuEpmSXQQiHuGNom8Q88Y9QJcAQz8CWHUNcga5Ogxk QkovaD/tjndCQHIZ1crG9I/i7IEWel3qBQzL9/bCO3J8n97eah+qDBJbyxybJMPeeuE3 6lNP2niosAGtY/8yYGxmt9MhxMFYofi164Y6r3s4mnQbMQKzt5qgGZeIZQ1gK/sVjj2e IBeg== 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=PTooRwbsdLD3OOIuzOYJzIkCxcUPBK7VZILGtwDxgv8=; b=HhaoE/TUbZwFH9owv2htnObAZH30HyPMuo8URiODXa8Ga10GiYSFnewVAEMUAc6fdd LQ38DKrrZG9LgqS87urf3aFmFWSkZxhPmW+dn0al7h26WbiLioEM4j/HqAvkEEpYO4fT Cwow/S1xbQNII/ocf6XHUDCPLrbWSxXPnrdE1nVC227XLlKhyKBWdQZB3ENcCRO2yB9I /9UXEEm1PcUgwUzuQH92Q3LRscYOJZhFDvPYUHnKm2kY2uk3BjLBTMhdRRQfkvWM4TRz 6oWM/3CwgAW0zT9sGI+hknKFRqIQlKhm5FxleOUcp8fbgzXDInt3HIC6ROypU1QbjMSm TVzQ== X-Gm-Message-State: AJIora/bdTBP0d9WXUSj7nhOnrqQ4kHjcVdLoohjPqLLfoAfoMPIKtDC oQ6wO5d3lqeB8pvJKMk9Yl4Xgw== X-Google-Smtp-Source: AGRyM1tjEn71qrKmNMS7wp3T3S+d/t0dVPqKJQezpaQfm5B9v8Y+F+k95yPYU5LV/RIbsvx/NRnIZQ== X-Received: by 2002:a05:600c:1c21:b0:3a1:9608:1ffb with SMTP id j33-20020a05600c1c2100b003a196081ffbmr11837879wms.163.1656922324210; Mon, 04 Jul 2022 01:12:04 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6809:2201:c4c4:4ed1:ae43:27f2]) by smtp.gmail.com with ESMTPSA id u3-20020adfdd43000000b0021d650e4df4sm4388276wrm.87.2022.07.04.01.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 01:12:03 -0700 (PDT) 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, quic_jinlmao@quicinc.com, Mike Leach Subject: [PATCH v2 13/13] coresight: trace-id: Add debug & test macros to Trace ID allocation Date: Mon, 4 Jul 2022 09:11:49 +0100 Message-Id: <20220704081149.16797-14-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220704081149.16797-1-mike.leach@linaro.org> References: <20220704081149.16797-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220704_091219_806422_2C930C1C X-CRM114-Status: GOOD ( 12.48 ) 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 dac9c89ae00d..841307e0d899 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) { @@ -81,6 +102,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) { if (per_cpu(cpu_ids, cpu).pend_rel) { @@ -126,6 +148,8 @@ static int coresight_trace_id_map_get_cpu_id(int cpu, struct coresight_trace_id_ get_cpu_id_out: spin_unlock_irqrestore(&id_map_lock, flags); + DUMP_ID_CPU(cpu, id); + DUMP_ID_MAP(id_map); return id; } @@ -151,6 +175,8 @@ static void coresight_trace_id_map_put_cpu_id(int cpu, struct coresight_trace_id put_cpu_id_out: spin_unlock_irqrestore(&id_map_lock, flags); + DUMP_ID_CPU(cpu, id); + DUMP_ID_MAP(id_map); } static int coresight_trace_id_map_get_system_id(struct coresight_trace_id_map *id_map) @@ -164,6 +190,8 @@ static int coresight_trace_id_map_get_system_id(struct coresight_trace_id_map *i 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; } @@ -174,6 +202,9 @@ static void coresight_trace_id_map_put_system_id(struct coresight_trace_id_map * 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); } /* API functions */ @@ -207,6 +238,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); @@ -217,6 +249,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);