[PATCH i-g-t 1/2] lib/xe/xe_trace: Added code related to trace

Kumar, Janga Rahul janga.rahul.kumar at intel.com
Thu Oct 3 14:27:48 UTC 2024



> -----Original Message-----
> From: Dandamudi, Priyanka <priyanka.dandamudi at intel.com>
> Sent: Monday, September 30, 2024 9:08 PM
> To: Kumar, Janga Rahul <janga.rahul.kumar at intel.com>; igt-
> dev at lists.freedesktop.org; Singh, Apoorva <apoorva.singh at intel.com>;
> Dandamudi, Priyanka <priyanka.dandamudi at intel.com>
> Subject: [PATCH i-g-t 1/2] lib/xe/xe_trace: Added code related to trace
> 
> From: Priyanka Dandamudi <priyanka.dandamudi at intel.com>
> 
> Trace related code has been added which will start tracing, stop tracing and
> validate migration.
> 
> Cc: Brian Welty <brian.welty at intel.com>
> Cc: Oak Zeng <oak.zeng at intel.com>
> Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi at intel.com>
> ---
>  lib/meson.build   |  1 +
>  lib/xe/xe_trace.c | 61
> +++++++++++++++++++++++++++++++++++++++++++++++
>  lib/xe/xe_trace.h | 12 ++++++++++
>  3 files changed, 74 insertions(+)
>  create mode 100644 lib/xe/xe_trace.c
>  create mode 100644 lib/xe/xe_trace.h
> 
> diff --git a/lib/meson.build b/lib/meson.build index c3556a921..5dd49872b
> 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -116,6 +116,7 @@ lib_sources = [
>  	'xe/xe_mmio.c',
>  	'xe/xe_query.c',
>  	'xe/xe_spin.c',
> +        'xe/xe_trace.c',
>  	'xe/xe_util.c',
>  ]
> 
> diff --git a/lib/xe/xe_trace.c b/lib/xe/xe_trace.c new file mode 100644 index
> 000000000..290ac91fa
> --- /dev/null
> +++ b/lib/xe/xe_trace.c
> @@ -0,0 +1,61 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2024 Intel Corporation
> + */
> +
> +#include <errno.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/ioctl.h>
> +#include "igt.h"
> +#include "igt_types.h"
> +#include "igt_sysfs.h"
> +#include "xe_trace.h"
> +
> +const char *xe_migration_trace_path =
> +
> 	"/sys/kernel/tracing/events/xe/xe_bo_move/enable";
> +const char *xe_acc_counter =
> +"/sys/kernel/tracing/events/xe/xe_vma_acc/enable";
> +const char *trace_on_path = "/sys/kernel/tracing/tracing_on"; const
> +char *trace_path = "/sys/kernel/tracing/trace";
> +
> +void xe_validate_acc_trace(int xe, int flag) {
> +	igt_assert_eq(igt_debugfs_search(xe,
> +		      trace_path, "migrate object"), flag);
> +	igt_assert_eq(igt_debugfs_search(xe,
> +		      trace_path, "xe_vma_acc"), flag); }
> +
> +bool xe_sysfs_trace_write(const char *file, const char *value) {
> +	FILE *fp;
> +
> +	fp = fopen(file, "w");
> +	if (!fp)
> +		return false;
> +
> +	igt_assert_f(fwrite(value, 1, strlen(value), fp) == strlen(value),
> +			"failed to update sysfs tracing node %s\n", file);
> +	fclose(fp);
> +	return true;
> +}
> +
> +void xe_start_tracing(void)
> +{
> +	bool success = true;
> +
> +	success &= xe_sysfs_trace_write(xe_acc_counter, "1");
> +	success &= xe_sysfs_trace_write(xe_migration_trace_path, "1");
> +	success &= xe_sysfs_trace_write(trace_path, "1");
> +	success &= xe_sysfs_trace_write(trace_on_path, "1");
> +
> +	igt_assert(success);
> +}
> +
> +void xe_stop_tracing(void)
> +{
> +	xe_sysfs_trace_write(xe_acc_counter, "0");
> +	xe_sysfs_trace_write(xe_migration_trace_path, "0");
> +	xe_sysfs_trace_write(trace_on_path, "0");
> +	xe_sysfs_trace_write(trace_path, "0"); }
> diff --git a/lib/xe/xe_trace.h b/lib/xe/xe_trace.h new file mode 100644 index
> 000000000..430710d65
> --- /dev/null
> +++ b/lib/xe/xe_trace.h
> @@ -0,0 +1,12 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2022 Intel Corporation
> + */
> +#include <stdio.h>
> +#include <string.h>
> +#include "igt.h"
> +
> +void xe_validate_acc_trace(int xe, int flag); bool
> +xe_sysfs_trace_write(const char *file, const char *value); void
> +xe_start_tracing(void); void xe_stop_tracing(void);
> --
> 2.34.1


LGTM
Reviewed-by: Janga Rahul Kumar <janga.rahul.kumar at intel.com>


More information about the igt-dev mailing list