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: <CAMuHMdUmPfahsnZwx2iB5yfh8rjjW25LNcnYujNBgcKotUXBNg@mail.gmail.com>
Date: Tue, 14 Jan 2025 11:16:43 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Maarten Lankhorst <dev@...khorst.se>
Cc: linux-kernel@...r.kernel.org, intel-xe@...ts.freedesktop.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>, Friedrich Vock <friedrich.vock@....de>, 
	Maxime Ripard <mripard@...nel.org>, cgroups@...r.kernel.org, linux-mm@...ck.org, 
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
Subject: Re: [PATCH v2.1 1/1] kernel/cgroup: Add "dmem" memory accounting cgroup

Hi Maarten,

On Wed, Dec 4, 2024 at 3:32 PM Maarten Lankhorst <dev@...khorst.se> wrote:
> This code is based on the RDMA and misc cgroup initially, but now
> uses page_counter. It uses the same min/low/max semantics as the memory
> cgroup as a result.
>
> There's a small mismatch as TTM uses u64, and page_counter long pages.
> In practice it's not a problem. 32-bits systems don't really come with
> >=4GB cards and as long as we're consistently wrong with units, it's
> fine. The device page size may not be in the same units as kernel page
> size, and each region might also have a different page size (VRAM vs GART
> for example).
>
> The interface is simple:
> - Call dmem_cgroup_register_region()
> - Use dmem_cgroup_try_charge to check if you can allocate a chunk of memory,
>   use dmem_cgroup__uncharge when freeing it. This may return an error code,
>   or -EAGAIN when the cgroup limit is reached. In that case a reference
>   to the limiting pool is returned.
> - The limiting cs can be used as compare function for
>   dmem_cgroup_state_evict_valuable.
> - After having evicted enough, drop reference to limiting cs with
>   dmem_cgroup_pool_state_put.
>
> This API allows you to limit device resources with cgroups.
> You can see the supported cards in /sys/fs/cgroup/dmem.capacity
> You need to echo +dmem to cgroup.subtree_control, and then you can
> partition device memory.
>
> Co-developed-by: Friedrich Vock <friedrich.vock@....de>
> Signed-off-by: Friedrich Vock <friedrich.vock@....de>
> Co-developed-by: Maxime Ripard <mripard@...nel.org>
> Signed-off-by: Maxime Ripard <mripard@...nel.org>
> Signed-off-by: Maarten Lankhorst <dev@...khorst.se>

Thanks for your patch, which is now commit b168ed458ddecc17
("kernel/cgroup: Add "dmem" memory accounting cgroup") in drm/drm-next.

> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1128,6 +1128,7 @@ config CGROUP_PIDS
>
>  config CGROUP_RDMA
>         bool "RDMA controller"
> +       select PAGE_COUNTER

This change looks unrelated?

Oh, reading your response to the build error, this should have been below?

>         help
>           Provides enforcement of RDMA resources defined by IB stack.
>           It is fairly easy for consumers to exhaust RDMA resources, which
> @@ -1136,6 +1137,15 @@ config CGROUP_RDMA
>           Attaching processes with active RDMA resources to the cgroup
>           hierarchy is allowed even if can cross the hierarchy's limit.
>
> +config CGROUP_DMEM
> +       bool "Device memory controller (DMEM)"
> +       help
> +         The DMEM controller allows compatible devices to restrict device
> +         memory usage based on the cgroup hierarchy.
> +
> +         As an example, it allows you to restrict VRAM usage for applications
> +         in the DRM subsystem.
> +

Do you envision other users than DRM?
Perhaps this should depend on DRM for now?

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ