All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Purkait, Soham" <soham.purkait@intel.com>
To: Riana Tauro <riana.tauro@intel.com>, <igt-dev@lists.freedesktop.org>
Cc: <anshuman.gupta@intel.com>, <umesh.nerlige.ramappa@intel.com>,
	<vinay.belgaumkar@intel.com>
Subject: Re: [PATCH i-g-t 1/3] lib/igt_perf: Add utils to extract PMU event info
Date: Sun, 16 Feb 2025 16:56:16 +0530	[thread overview]
Message-ID: <c7a585e9-7bd5-4767-96b2-51e4b611ccde@intel.com> (raw)
In-Reply-To: <20250212095834.384508-2-riana.tauro@intel.com>

Hi Riana,

On 12-02-2025 15:28, Riana Tauro wrote:
> From: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
>
> Functions to parse event ID and GT bit shift for PMU events.
>
> v2: Review comments (Riana)
> v3: Review comments (Lucas)
>
> Cc: Riana Tauro <riana.tauro@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Reviewed-by: Riana Tauro <riana.tauro@intel.com>
> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
> ---
>   lib/igt_perf.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_perf.h |  2 ++
>   2 files changed, 72 insertions(+)
>
> diff --git a/lib/igt_perf.c b/lib/igt_perf.c
> index 3866c6d77..f021fc3ec 100644
> --- a/lib/igt_perf.c
> +++ b/lib/igt_perf.c
> @@ -92,6 +92,76 @@ const char *xe_perf_device(int xe, char *buf, int buflen)
>   	return buf;
>   }
>   
> +/**
> + * perf_event_format: Returns the start/end positions of an event format param
> + * @device: PMU device
> + * @param: Parameter for which you need the format start/end bits
> + * Returns: 0 on success or negative error code
> + */
> +int perf_event_format(const char *device, const char *param, uint32_t *start, uint32_t *end)
> +{
> +	char buf[NAME_MAX];
> +	ssize_t bytes;
> +	int ret;
> +	int fd;
> +
> +	snprintf(buf, sizeof(buf),
> +		 "/sys/bus/event_source/devices/%s/format/%s",
> +		 device, param);
> +
> +	fd = open(buf, O_RDONLY | O_CLOEXEC);
> +	if (fd < 0)
> +		return -EINVAL;
> +
> +	bytes = read(fd, buf, sizeof(buf) - 1);
> +	close(fd);
> +	if (bytes < 1)
> +		return -EINVAL;
> +
> +	buf[bytes] = '\0';
> +	ret = sscanf(buf, "config:%u-%u", start, end);
> +	if (ret != 2)
> +		return -EINVAL;
> +
> +	return ret;
As per the function description it should return 0 on success.

Thanks,
Soham
> +}
> +
> +/**
> + * perf_event_config:
> + * @device: Device string in driver:pci format
> + * @event: The event name
> + * @config: Pointer to the config
> + * Returns: 0 for success, negative value on error
> + */
> +int perf_event_config(const char *device, const char *event, uint64_t *config)
> +{
> +	char buf[NAME_MAX];
> +	ssize_t bytes;
> +	int ret;
> +	int fd;
> +
> +	snprintf(buf, sizeof(buf),
> +		 "/sys/bus/event_source/devices/%s/events/%s",
> +		 device,
> +		 event);
> +
> +	fd = open(buf, O_RDONLY);
> +	if (fd < 0)
> +		return -EINVAL;
> +
> +	bytes = read(fd, buf, sizeof(buf) - 1);
> +	close(fd);
> +	if (bytes < 1)
> +		return ret;
> +
> +	buf[bytes] = '\0';
> +	ret = sscanf(buf, "event=0x%lx", config);
> +	if (ret != 1)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
>   uint64_t xe_perf_type_id(int xe)
>   {
>   	char buf[80];
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h
> index 3d9ba2917..69f7a3d74 100644
> --- a/lib/igt_perf.h
> +++ b/lib/igt_perf.h
> @@ -71,5 +71,7 @@ int perf_i915_open(int i915, uint64_t config);
>   int perf_i915_open_group(int i915, uint64_t config, int group);
>   
>   int perf_xe_open(int xe, uint64_t config);
> +int perf_event_config(const char *device, const char *event, uint64_t *config);
> +int perf_event_format(const char *device, const char *param, uint32_t *start, uint32_t *end);
>   
>   #endif /* I915_PERF_H */

  parent reply	other threads:[~2025-02-16 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12  9:58 [PATCH i-g-t 0/3] Add PMU tests to validate engine activity Riana Tauro
2025-02-12  9:58 ` [PATCH i-g-t 1/3] lib/igt_perf: Add utils to extract PMU event info Riana Tauro
2025-02-13 14:30   ` Kamil Konieczny
2025-02-16 11:26   ` Purkait, Soham [this message]
2025-02-12  9:58 ` [PATCH i-g-t 2/3] tests/intel/xe_pmu: Add PMU test to validate engine activity stats Riana Tauro
2025-02-14 18:55   ` Umesh Nerlige Ramappa
2025-02-14 19:01     ` Umesh Nerlige Ramappa
2025-02-12  9:58 ` [PATCH i-g-t 3/3] tests/intel/xe_pmu: Add idle engine activity test Riana Tauro
2025-02-14 19:08   ` Umesh Nerlige Ramappa
2025-02-17  6:58     ` Riana Tauro
2025-02-13  1:07 ` ✓ Xe.CI.BAT: success for Add PMU tests to validate engine activity Patchwork
2025-02-13  1:20 ` ✓ i915.CI.BAT: " Patchwork
2025-02-13 10:04 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-13 12:03 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7a585e9-7bd5-4767-96b2-51e4b611ccde@intel.com \
    --to=soham.purkait@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    --cc=vinay.belgaumkar@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.