From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 9BB1BCA0FE7 for ; Mon, 25 Aug 2025 17:18:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FBE510E267; Mon, 25 Aug 2025 17:18:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CrFrH5FX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id F0DE610E267 for ; Mon, 25 Aug 2025 17:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756142305; x=1787678305; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=JTonnHRwvslim/z+VxxfYQ4iTX7b8jL3NWne8PEiAuA=; b=CrFrH5FXDGP03y1O+kUwf0BYXU9+Pdgc/Jk/IdvH0MDuU32ORgFL1nx4 biwCFsjZbF1rUlk9vw99z3MofDGFWomDCCwt31TOXVzixtT2Te784wPQe 7mtDQgpagpCZmvecuqqrk6Ukm9424jZZqyeO6S5wuwDaVgCihnj5tZMY+ ld2cfuEXes3vcUayF2hY8kRtgy7zdkg3mBl1I7KUn9hQJioq+Tm9tfCsV 2v2ehMY7cxwUktXbMjnnYKIr34Hx92llyS5X8IcLXG3QjmtvxbykQTxpm gmSz1Kyu4REAFmUZT7W0N8vgxvVzbGtRtnmCJ88/Jr5sRg6T0oQyxCGxG w==; X-CSE-ConnectionGUID: BTGLfa+qSyC8Lq7Fxf5Nvg== X-CSE-MsgGUID: 9UsSFcQBQUC2dZMUbySfxw== X-IronPort-AV: E=McAfee;i="6800,10657,11533"; a="62008574" X-IronPort-AV: E=Sophos;i="6.18,213,1751266800"; d="scan'208";a="62008574" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 10:18:15 -0700 X-CSE-ConnectionGUID: a3bXWadrT6Wtyb15aaGVTQ== X-CSE-MsgGUID: KbAaRIkuSKetxFcDkw6vSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,213,1751266800"; d="scan'208";a="193020086" Received: from lmrodriq-mobl1.amr.corp.intel.com (HELO adixit-MOBL3.intel.com) ([10.246.169.244]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2025 10:18:13 -0700 Date: Mon, 25 Aug 2025 10:18:12 -0700 Message-ID: <87ldn7miaz.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa Cc: Subject: Re: [PATCH i-g-t 4/4] tests/intel/xe_oa: Add an option to capture ftrace In-Reply-To: <87qzx1yia3.wl-ashutosh.dixit@intel.com> References: <20250823003401.109978-6-umesh.nerlige.ramappa@intel.com> <20250823003401.109978-10-umesh.nerlige.ramappa@intel.com> <87qzx1yia3.wl-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" On Sat, 23 Aug 2025 12:01:08 -0700, Dixit, Ashutosh wrote: > > On Fri, 22 Aug 2025 17:34:06 -0700, Umesh Nerlige Ramappa wrote: > > > > Capture ftrace with the --trace option when needed. This is not intended > > to run as default, but more of a debug functionality when manually > > running individual tests. > > Maybe mention here or in the commit title that we are capturing register > read/writes in ftrace. > > > > > In addition configure the ftrace buffer using the --trace_buf_size_mb > > > > Signed-off-by: Umesh Nerlige Ramappa > > --- > > tests/intel/xe_oa.c | 58 ++++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 57 insertions(+), 1 deletion(-) > > > > diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c > > index 7381e7b9bd44..e5473a5ff70f 100644 > > --- a/tests/intel/xe_oa.c > > +++ b/tests/intel/xe_oa.c > > @@ -307,6 +307,8 @@ static struct oa_format lnl_oa_formats[XE_OA_FORMAT_MAX] = { > > .bc_report = 0 }, > > }; > > > > +static bool oa_trace = false; > > +static uint32_t oa_trace_buf_mb = 20; > > static int drm_fd = -1; > > static int sysfs = -1; > > static int pm_fd = -1; > > @@ -389,6 +391,31 @@ static u32 get_stream_status(int fd) > > return status.oa_status; > > } > > > > +static void enable_trace_log(void) > > +{ > > + char cmd[64] = {0}; > > + > > + if (!oa_trace || oa_trace_buf_mb > 20) Actually, why is this oa_trace_buf_mb condition there in enable/disable? If we don't want the trace buf to be > 20 MB, maybe return an error in opt_handler? Also, do we really need this oa_trace_buf_mb option? Maybe just select a size and hardcode it? Or we need the option because we don't know the hardcoded value? Since we are only tracing xe_reg_rw, maybe even the default size is ok? How many reg r/w's are there for an OA IGT? Maybe not that many? Since the reg r/w's done by batches won't be captured here anyway, just the direct mmio r/w's? When we generate lots of ftrace, I have previously found the default ftrace buffer size is not sufficient and printf's get dropped. Previously I used 512 KB (the largest size which worked in those old kernels) and that seemed sufficient. But anyway even larger values are ok. Anyway, ok to leave as is too. Just some ideas. > > + return; > > + > > + snprintf(cmd, sizeof(cmd) - 1, "echo %d > /sys/kernel/debug/tracing/buffer_size_kb", oa_trace_buf_mb * 1000); Maybe * 1024 instead? > > + system(cmd); > > + system("echo 0 > /sys/kernel/debug/tracing/tracing_on"); > > + system("echo > /sys/kernel/debug/tracing/trace"); > > + system("echo 1 > /sys/kernel/debug/tracing/events/xe/enable"); > > + system("echo 1 > /sys/kernel/debug/tracing/events/xe/xe_reg_rw/enable"); > > + system("echo 1 > /sys/kernel/debug/tracing/tracing_on"); > > +} > > + > > +static void disable_trace_log(void) > > +{ > > + if (!oa_trace || oa_trace_buf_mb > 20) > > + return; > > + > > + system("echo 0 > /sys/kernel/debug/tracing/tracing_on"); > > + system("cat /sys/kernel/debug/tracing/trace"); > > +} > > + > > static void > > dump_report(const uint32_t *report, uint32_t size, const char *message) { > > uint32_t i; > > @@ -4937,7 +4964,34 @@ static const char *xe_engine_class_name(uint32_t engine_class) > > igt_require_f(hwe, "no render engine\n"); \ > > igt_dynamic_f("rcs-%d", hwe->engine_instance) > > > > -igt_main > > +static int opt_handler(int opt, int opt_index, void *data) > > +{ > > + switch (opt) { > > + case 'b': > > + oa_trace_buf_mb = strtoul(optarg, NULL, 0); > > + igt_debug("Trace buffer %d Mb\n", oa_trace_buf_mb); > > + break; > > + case 't': > > + oa_trace = true; > > + igt_debug("Trace enabled\n"); > > + break; > > + default: > > + return IGT_OPT_HANDLER_ERROR; > > + } > > + > > + return IGT_OPT_HANDLER_SUCCESS; > > +} > > + > > +static const char *help_str = " --trace | -t\t\tEnable ftrace\n" > > + " --trace_buf_size_mb | -b\t\tSet ftrace buffer size in Mb (default = 0, max = 20)\n"; s/Mb/MB/ ? Thanks. -- Ashutosh > > + > > +static struct option long_options[] = { > > + {"trace", 0, 0, 't'}, > > + {"trace_buf_size_mb", 0, 0, 'b'}, > > + { NULL, 0, 0, 0 } > > +}; > > + > > +igt_main_args("b:t", long_options, help_str, opt_handler, NULL) > > { > > const struct sync_section { > > const char *name; > > @@ -4981,6 +5035,7 @@ igt_main > > */ > > igt_assert_eq(drm_fd, -1); > > > > + enable_trace_log(); > > drm_fd = drm_open_driver(DRIVER_XE); > > xe_dev = xe_device_get(drm_fd); > > > > @@ -5210,5 +5265,6 @@ igt_main > > intel_xe_perf_free(intel_xe_perf); > > > > drm_close_driver(drm_fd); > > + disable_trace_log(); > > Does this get disabled even if the test crashes? Anyway since it is for > debug and not enabled by default, this is: > > Reviewed-by: Ashutosh Dixit > > > } > > } > > -- > > 2.43.0 > >