All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Aakash Deep Sarkar <aakash.deep.sarkar@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <jeevaka.badrappan@intel.com>,
	<carlos.santa@intel.com>, <matthew.brost@intel.com>
Subject: Re: [PATCH v2 1/8] [ANDROID]: Add a new xe_user structure
Date: Fri, 22 Aug 2025 11:48:54 -0400	[thread overview]
Message-ID: <aKiRZkk2CV3bJjOO@intel.com> (raw)
In-Reply-To: <20250822085932.2221054-2-aakash.deep.sarkar@intel.com>

On Fri, Aug 22, 2025 at 08:59:23AM +0000, Aakash Deep Sarkar wrote:
> For Android GPU work period event we need to track the runtime
> on the GPU for each user id. This means we can have multiple
> xe files opened by different processes/threads belonging to
> the same user id. All these xe files need to be grouped together
> so that one can easily identify these while calculating the
> run time for the given user id.
> 
> Currently, the xe driver doesn't record the user id of the
> calling process. Also, all the xe files created using open
> call are clubbed together inside the xe device structure
> with no way to distinguish between them based on the user id
> of the calling process.

I thought I had already given this feedback, but I'm not sure if
I forgot or if I was just ignored. I'm sorry either way.

Android is not a justification. Please keep 'Android' mentions
and ralated 'Android' justifications in the cover letter ONLY!

The patch needs to make sense by itself. The patch needs to make
sense in the currently linux upstream.

This also means no --subject-prefix=ANDROID.

Please!

> 
> To remedy these limitations we are adding another layer of
> indirection between xe device and xe file. xe device will
> now have a list of xe users each with a given user id; and each
> xe user will have a list of xe files each of which is created
> by a process that is associated with this user id.
> 
> The lifetime of the xe user structure should be between when
> a process with a new user id has opened the xe device; and when
> the last xe file belonging to this user id is closed.
> 
> Signed-off-by: Aakash Deep Sarkar <aakash.deep.sarkar@intel.com>
> ---
>  drivers/gpu/drm/xe/Makefile  |  2 +
>  drivers/gpu/drm/xe/xe_user.c | 59 ++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_user.h | 81 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 142 insertions(+)
>  create mode 100644 drivers/gpu/drm/xe/xe_user.c
>  create mode 100644 drivers/gpu/drm/xe/xe_user.h
> 
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index 8e0c3412a757..89212fc7ef44 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -325,6 +325,8 @@ ifeq ($(CONFIG_DEBUG_FS),y)
>  
>  	xe-$(CONFIG_PCI_IOV) += xe_gt_sriov_pf_debugfs.o
>  
> +	xe-y += xe_user.o
> +
>  	xe-$(CONFIG_DRM_XE_DISPLAY) += \
>  		i915-display/intel_display_debugfs.o \
>  		i915-display/intel_display_debugfs_params.o \
> diff --git a/drivers/gpu/drm/xe/xe_user.c b/drivers/gpu/drm/xe/xe_user.c
> new file mode 100644
> index 000000000000..8c285a68115a
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_user.c
> @@ -0,0 +1,59 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#include <linux/slab.h>
> +
> +#include "xe_user.h"
> +
> +/**
> + * worker thread to emit gpu work period event for this xe user
> + * @work: work instance for this xe user
> + *
> + * Return: void
> + */
> +static inline void work_period_worker(struct work_struct *work)
> +{
> +	//TODO: Implement this worker
> +}
> +
> +/**
> + * xe_user_alloc() - Allocate xe user
> + * @void: No arg
> + *
> + * Allocate xe user struct to track activity on the gpu
> + * by the application. Call this API whenever a new app
> + * has opened xe device.
> + *
> + * Return: pointer to user struct or NULL if can't allocate
> + */
> +struct xe_user *xe_user_alloc(void)
> +{
> +	struct xe_user *user;
> +
> +	user = kzalloc(sizeof(*user), GFP_KERNEL);
> +	if (!user)
> +		return NULL;
> +
> +	kref_init(&user->refcount);
> +	mutex_init(&user->filelist_lock);
> +	INIT_LIST_HEAD(&user->filelist);
> +	//TODO: Add a hook into xe device
> +	INIT_WORK(&user->work, work_period_worker);
> +	return user;
> +}
> +
> +/**
> + * __xe_user_free() - Free user struct
> + * @kref: The reference
> + *
> + * Return: void
> + */
> +void __xe_user_free(struct kref *kref)
> +{
> +	struct xe_user *user =
> +		container_of(kref, struct xe_user, refcount);
> +
> +	kfree(user);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_user.h b/drivers/gpu/drm/xe/xe_user.h
> new file mode 100644
> index 000000000000..e52f66d3f3b0
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_user.h
> @@ -0,0 +1,81 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#ifndef _XE_USER_H_
> +#define _XE_USER_H_
> +
> +#include <linux/kref.h>
> +#include <linux/list.h>
> +#include <linux/workqueue.h>
> +
> +/**
> + * This is a per process/user id structure for a xe device
> + * client. It is allocated when a new process/app opens the
> + * xe device and destroyed when the last xe file belonging
> + * to this user id is destroyed.
> + */
> +struct xe_user {
> +	/**
> +	 * @refcount: reference count
> +	 */
> +	struct kref refcount;
> +
> +	/**
> +	 * @xe: pointer to the xe_device
> +	 */
> +	struct xe_device *xe;
> +
> +	/**
> +	 * @filelist_lock: lock protecting the filelist
> +	 */
> +	struct mutex filelist_lock;
> +
> +	/**
> +	 * @filelist: list of xe files belonging to this xe user
> +	 */
> +	struct list_head filelist;
> +
> +	/**
> +	 * @work: work to emit the gpu work period event for this
> +	 * xe user
> +	 */
> +	struct work_struct work;
> +
> +	/**
> +	 * @uid: user id for this xe_user
> +	 */
> +	u32 uid;
> +
> +	/**
> +	 * @active_duration_ns: sum total of xe_file.active_duration_ns
> +	 * for all xe files belonging to this xe user
> +	 */
> +	u64 active_duration_ns;
> +
> +	/**
> +	 * @last_timestamp_ns: timestamp in ns when we last emitted event
> +	 * for this xe user
> +	 */
> +	u64 last_timestamp_ns;
> +};
> +
> +struct xe_user *xe_user_alloc(void);
> +
> +static inline struct xe_user *
> +xe_user_get(struct xe_user *user)
> +{
> +	kref_get(&user->refcount);
> +	return user;
> +}
> +
> +void __xe_user_free(struct kref *kref);
> +
> +static inline void xe_user_put(struct xe_user *user)
> +{
> +	kref_put(&user->refcount, __xe_user_free);
> +}
> +
> +#endif // _XE_USER_H_
> +
> -- 
> 2.49.0
> 

  reply	other threads:[~2025-08-22 15:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  8:59 [PATCH v2 0/8] [ANDROID]: Add GPU work period support for Xe driver Aakash Deep Sarkar
2025-08-22  8:59 ` [PATCH v2 1/8] [ANDROID]: Add a new xe_user structure Aakash Deep Sarkar
2025-08-22 15:48   ` Rodrigo Vivi [this message]
2025-08-22 17:01     ` Matthew Brost
2025-08-22 20:09       ` Rodrigo Vivi
2025-08-23  1:57         ` Dixit, Ashutosh
2025-08-22  8:59 ` [PATCH v2 2/8] [ANDROID]: Add xe_gt_clock_interval_to_ns function Aakash Deep Sarkar
2025-08-22  8:59 ` [PATCH v2 3/8] [ANDROID]: Add a trace point for GPU work period Aakash Deep Sarkar
2025-08-22 19:57   ` Rodrigo Vivi
2025-08-22  8:59 ` [PATCH v2 4/8] [ANDROID]: Modify xe_exec_queue_update_run_ticks Aakash Deep Sarkar
2025-08-22  8:59 ` [PATCH v2 5/8] [ANDROID]: Handle xe_user creation and removal Aakash Deep Sarkar
2025-08-22  8:59 ` [PATCH v2 6/8] [ANDROID]: Implement xe_work_period_worker Aakash Deep Sarkar
2025-08-22 11:00   ` Matthew Auld
2025-08-22 16:58     ` Matthew Brost
2025-08-22  8:59 ` [PATCH v2 7/8] [ANDROID]: Add a Kconfig option for GPU work period Aakash Deep Sarkar
2025-08-22  8:59 ` [PATCH v2 8/8] [ANDROID]: Handle xe_work_period destruction Aakash Deep Sarkar
2025-08-22  9:39 ` ✗ CI.checkpatch: warning for : Add GPU work period support for Xe driver Patchwork
2025-08-22  9:40 ` ✓ CI.KUnit: success " Patchwork
2025-08-22 10:44 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-23  3:50 ` ✗ Xe.CI.Full: failure " 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=aKiRZkk2CV3bJjOO@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=aakash.deep.sarkar@intel.com \
    --cc=carlos.santa@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jeevaka.badrappan@intel.com \
    --cc=matthew.brost@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.