lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qufus10.fsf@intel.com>
Date: Wed, 23 Oct 2024 11:45:15 +0300
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 intel-xe@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
 dri-devel@...ts.freedesktop.org, Tejun Heo <tj@...nel.org>, Zefan Li
 <lizefan.x@...edance.com>, Johannes Weiner <hannes@...xchg.org>, Andrew
 Morton <akpm@...ux-foundation.org>
Cc: Friedrich Vock <friedrich.vock@....de>, cgroups@...r.kernel.org,
 linux-mm@...ck.org, Maxime Ripard <mripard@...nel.org>, Maarten Lankhorst
 <maarten.lankhorst@...ux.intel.com>
Subject: Re: [PATCH 2/7] drm/drv: Add drmm cgroup registration for dev cgroups.

On Wed, 23 Oct 2024, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com> wrote:
> From: Maxime Ripard <mripard@...nel.org>
>
> Drivers will need to register a cgroup device at probe time, so let's
> give them a drm-managed helper.
>
> Signed-off-by: Maxime Ripard <mripard@...nel.org>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
> ---
>  drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++
>  include/drm/drm_drv.h     |  4 ++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index c2c172eb25df7..251d1d69b09c5 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -26,6 +26,7 @@
>   * DEALINGS IN THE SOFTWARE.
>   */
>  
> +#include <linux/cgroup_dev.h>
>  #include <linux/debugfs.h>
>  #include <linux/fs.h>
>  #include <linux/module.h>
> @@ -820,6 +821,26 @@ void drm_dev_put(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_dev_put);
>  
> +static inline void drmm_cg_unregister_device(struct drm_device *dev, void *arg)

Nitpick, inline in .c files is mostly useless, just use static and let
the compiler do its job.

BR,
Jani.

> +{
> +	dev_cgroup_unregister_device(arg);
> +}
> +
> +int drmm_cgroup_register_device(struct drm_device *dev,
> +				struct dev_cgroup_device *cgdev)
> +{
> +	int ret;
> +	char dev_name[32];
> +
> +	snprintf(dev_name, sizeof(dev_name), "drm/%s", dev->unique);
> +	ret = dev_cgroup_register_device(cgdev, dev_name);
> +	if (ret)
> +		return ret;
> +
> +	return drmm_add_action_or_reset(dev, drmm_cg_unregister_device, cgdev);
> +}
> +EXPORT_SYMBOL_GPL(drmm_cgroup_register_device);
> +
>  static int create_compat_control_link(struct drm_device *dev)
>  {
>  	struct drm_minor *minor;
> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
> index 1bbbcb8e2d231..3e83c7ce7f2d0 100644
> --- a/include/drm/drm_drv.h
> +++ b/include/drm/drm_drv.h
> @@ -34,6 +34,7 @@
>  
>  #include <drm/drm_device.h>
>  
> +struct dev_cgroup_device;
>  struct drm_fb_helper;
>  struct drm_fb_helper_surface_size;
>  struct drm_file;
> @@ -438,6 +439,9 @@ void *__devm_drm_dev_alloc(struct device *parent,
>  			   const struct drm_driver *driver,
>  			   size_t size, size_t offset);
>  
> +int drmm_cgroup_register_device(struct drm_device *dev,
> +				struct dev_cgroup_device *cgdev);
> +
>  /**
>   * devm_drm_dev_alloc - Resource managed allocation of a &drm_device instance
>   * @parent: Parent device object

-- 
Jani Nikula, Intel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ