Re: [PATCH v6 2/6] cgroup: gpu: Add a cgroup controller for allocator attribution of GPU memory
From: Michal Koutný
Date: Wed May 04 2022 - 08:26:05 EST
Hello.
On Mon, May 02, 2022 at 11:19:36PM +0000, "T.J. Mercier" <tjmercier@xxxxxxxxxx> wrote:
> This patch adds APIs to:
> -allow a device to register for memory accounting using the GPU cgroup
> controller.
> -charge and uncharge allocated memory to a cgroup.
Is this API for separately built consumers?
The respective functions should be exported (EXPORT_SYMBOL_GPL) if I
haven't missed anything.
> +#ifdef CONFIG_CGROUP_GPU
> + /* The GPU cgroup controller data structure */
> +struct gpucg {
> + struct cgroup_subsys_state css;
> +
> + /* list of all resource pools that belong to this cgroup */
> + struct list_head rpools;
> +};
> +
> +/* A named entity representing bucket of tracked memory. */
> +struct gpucg_bucket {
> + /* list of various resource pools in various cgroups that the bucket is part of */
> + struct list_head rpools;
> +
> + /* list of all buckets registered for GPU cgroup accounting */
> + struct list_head bucket_node;
> +
> + /* string to be used as identifier for accounting and limit setting */
> + const char *name;
> +};
Do these struct have to be defined "publicly"?
I.e. the driver code could just work with gpucg and gpucg_bucket
pointers.
> +int gpucg_register_bucket(struct gpucg_bucket *bucket, const char *name)
...and the registration function would return a pointer to newly
(internally) allocated gpucg_bucket.
Regards,
Michal