From patchwork Tue Oct 22 19:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13846114 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2080.outbound.protection.outlook.com [40.107.220.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D4C1CBEBE; Tue, 22 Oct 2024 19:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729626160; cv=fail; b=ownPH8c/swUO4Ao8l+ndJYcT+z8gG4RUWLg/KZTIRQfjYtPh2SYHvnRC5QOD4Zzc78vli1uGvSdsjUlgLOfuITE74Rr7KyCsgDG3ASnY8+K+qEFD7iX8J3RdL8NBfCDWIKyBuw3RNtQMxqM5mv0yv3mk379hrtTgyEBAJ0GnEG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729626160; c=relaxed/simple; bh=+p3FZ9tuqUwudT2pgTVSrmLaB5UvxyZoUapZxDNJQbs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KUWFSuRbeKPIMtW2EYxu7fRZ9gqv7NXceCi7zDPQV4BrQ6mrPdipciKbw8pXNHttT6Fl44kNk05uwOPzi9RVWS4eQh/v/IZEZ4LYQjDM3+TYdBdfAf/iZlfLUN264Zl5/xMcKhRKV+OB+w53QoqbWaRQVuKtPonuE4JREQpxPfI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=zk6OIsjB; arc=fail smtp.client-ip=40.107.220.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zk6OIsjB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rRIzZahdLGXggE8ZiNj1FdEuBxe50kBPuRMZGjDy8VbUSYT+cWTI5XRZ/bGxoEzlBM2zr0szlVkfs5SEIwurnaw75SJX5YxpFTtXTd8ZAPIVXtQFQOqXXxrP+iHxsr3pfYwxB3XSHrX4mCPiF0sHwBprvh4EIjn2tXYEEsGlpCVvmKxDfn8PlNTp4TOZgBQi4n+UugmhZOkS91On+P4hcMRWiZkVkimdmkyViJxgl9LBgcJiAbBoPBprJInoWvYAU23gB+9/0WZPrJQl/FWmHHpHo3JOB0GHYiMC7P7S7nZl+xxpg0WS7LZ4+6PbJjYglT4iVlgKaOx0+i+SQ7uwuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pu8AQQlOesqy8qCKYnE5LpKyJKGVwMXwnPedQzvGqYc=; b=wh6H4SYiIUxLCx6HSegPzYIchN2jAE6FX8nzFN4Z+Ti9Y0aCvcST1nsJqJNdK20DbjFOziWM35fWWKlUbptTmGO/SWD2ka4Bvy43s/VKo/zPjCy0wIcWC+jXqMhxXWCWNIPLGYCBG0rm9QlhImZH6keo7EUtO2EJjrkBwaCTWJPfilgZr2jA1wzSGp215LIo5X9OUZwNYHxlyf6o4A0iBlPjmM+El4XR1/Gui+MJn5cvDaqfAA2ZJ3auTZUAM4yLIx1XT5K2YTWhKgUyQDZQ6gYaR4/NyLlLVN6hzOUNIbV+F+B5ApuMzwK8fNWcSiH6a4mECeZ4hWQL366hYznB0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pu8AQQlOesqy8qCKYnE5LpKyJKGVwMXwnPedQzvGqYc=; b=zk6OIsjBWIgfeGKlczM+SGW2RMhx4QmiSRCRQct0LtPn2nKLr/a//zW7gfPEC9gSPpJzPGBCZ/sGLfNBerKfuvvr+GSc5rVFk4dm1YvCxmC+WkH5S8e+qp3zBrjhsxcWpoax3BIi8njvhOwB3/SmFfYcRv6ZT+u1mA28KvrRM+E= Received: from BYAPR02CA0006.namprd02.prod.outlook.com (2603:10b6:a02:ee::19) by DS0PR12MB8786.namprd12.prod.outlook.com (2603:10b6:8:149::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Tue, 22 Oct 2024 19:42:34 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a02:ee:cafe::80) by BYAPR02CA0006.outlook.office365.com (2603:10b6:a02:ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 19:42:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 19:42:33 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 22 Oct 2024 14:42:32 -0500 From: Avadhut Naik To: , , CC: , , , , , , , , , , Subject: [PATCH v7 2/5] tracing: Add __print_dynamic_array() helper Date: Tue, 22 Oct 2024 19:36:28 +0000 Message-ID: <20241022194158.110073-3-avadhut.naik@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022194158.110073-1-avadhut.naik@amd.com> References: <20241022194158.110073-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|DS0PR12MB8786:EE_ X-MS-Office365-Filtering-Correlation-Id: 507c4a33-8f90-4066-f703-08dcf2d1ac96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: WIBdB9AbH28Kso6UwvaLh1UyhkZ8wyALygAa9GNwCQtdG0k858MAW8L/Ac8pcbxeCiI6hWX0AQmBcYUm9+Gp2qWdtG6jskFczyqxiFN1crH9fl9Zj0X+e/HU/XWoY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6QZ7tERQ9plfSJxBliO+NqKWcAuFXUCK90vt85fQwNC+lkxMkDR8xRYG5rn9CFyO9caEuPjOHK63x82L98kbLUfmio2wju4JZ4I+H4xmNseC6KvlrFOMIOExqLDj5V5s04nU9UOLanux9I/HK8qWYZLfFIsENDsXOe6APIryWjmJ2SR2zwtaV3zTDYETQWMRWRPd80j/oz1ZtPwL5gxZffENwmQjFCaHK6Hw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 19:42:33.5866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 507c4a33-8f90-4066-f703-08dcf2d1ac96 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8786 From: Steven Rostedt When printing a dynamic array in a trace event, the method is rather ugly. It has the format of: __print_array(__get_dynamic_array(array), __get_dynmaic_array_len(array) / el_size, el_size) Since dynamic arrays are known to the tracing infrastructure, create a helper macro that does the above for you. __print_dynamic_array(array, el_size) Which would expand to the same output. Signed-off-by: Steven Rostedt (Google) Reviewed-by: Qiuxu Zhuo Signed-off-by: Avadhut Naik --- Changes in v5: Patch introduced in the series. Changes in v6: No changes other than rebasing on top of tip/master. Changes in v7: 1. Rebase on top of tip/master. 2. Added parenthesis around el_size parameter in macro. 3. Remove Cc (to Avadhut Naik) tag. 4. Add Reviewed-by: Qiuxu Zhuo tag. --- include/trace/stages/stage3_trace_output.h | 8 ++++++++ include/trace/stages/stage7_class_define.h | 1 + samples/trace_events/trace-events-sample.h | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index c1fb1355d309..1e7b0bef95f5 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -119,6 +119,14 @@ trace_print_array_seq(p, array, count, el_size); \ }) +#undef __print_dynamic_array +#define __print_dynamic_array(array, el_size) \ + ({ \ + __print_array(__get_dynamic_array(array), \ + __get_dynamic_array_len(array) / (el_size), \ + (el_size)); \ + }) + #undef __print_hex_dump #define __print_hex_dump(prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) \ diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index bcb960d16fc0..fcd564a590f4 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -22,6 +22,7 @@ #undef __get_rel_cpumask #undef __get_rel_sockaddr #undef __print_array +#undef __print_dynamic_array #undef __print_hex_dump #undef __get_buf diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 55f9a3da92d5..999f78d380ae 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -319,7 +319,7 @@ TRACE_EVENT(foo_bar, __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -363,6 +363,11 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), + +/* A shortcut is to use __print_dynamic_array for dynamic arrays */ + + __print_dynamic_array(list, sizeof(int)), + __get_str(str), __get_str(lstr), __get_bitmask(cpus), __get_cpumask(cpum), __get_str(vstr))