From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Waiman Long <llong@redhat.com>,
intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, Tejun Heo <tj@kernel.org>,
Zefan Li <lizefan.x@bytedance.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Friedrich Vock <friedrich.vock@gmx.de>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
Maxime Ripard <mripard@kernel.org>
Subject: Re: [PATCH 1/7] kernel/cgroup: Add "dev" memory accounting cgroup
Date: Mon, 11 Nov 2024 10:28:11 +0100 [thread overview]
Message-ID: <2ddaf010-ce31-4957-bc4f-7f4c1bfe0826@linux.intel.com> (raw)
In-Reply-To: <813cc1d5-1648-4900-ae56-5405e52926df@redhat.com>
Den 2024-10-23 kl. 17:26, skrev Waiman Long:
> On 10/23/24 3:52 AM, Maarten Lankhorst wrote:
>> The initial version was based roughly on the rdma and misc cgroup
>> controllers, with a lot of the accounting code borrowed from rdma.
>>
>> The current version is a complete rewrite with 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:
>> - populate dev_cgroup_try_charge->regions[..] name and size for each
>> active
>> region, set num_regions accordingly.
>> - Call (dev,drmm)_cgroup_register_device()
>> - Use dev_cgroup_try_charge to check if you can allocate a chunk of
>> memory,
>> use dev_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
>> dev_cgroup_state_evict_valuable.
>> - After having evicted enough, drop reference to limiting cs with
>> dev_cgroup_pool_state_put.
>>
>> This API allows you to limit device resources with cgroups.
>> You can see the supported cards in /sys/fs/cgroup/dev.region.capacity
>> You need to echo +dev to cgroup.subtree_control, and then you can
>> partition memory.
>>
>> Co-developed-by: Friedrich Vock <friedrich.vock@gmx.de>
>> Signed-off-by: Friedrich Vock <friedrich.vock@gmx.de>
>> Co-developed-by: Maxime Ripard <mripard@kernel.org>
>> Signed-off-by: Maxime Ripard <mripard@kernel.org>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>> Documentation/admin-guide/cgroup-v2.rst | 51 ++
>> Documentation/core-api/cgroup.rst | 9 +
>> Documentation/core-api/index.rst | 1 +
>> Documentation/gpu/drm-compute.rst | 54 ++
>> include/linux/cgroup_dev.h | 91 +++
>> include/linux/cgroup_subsys.h | 4 +
>> include/linux/page_counter.h | 2 +-
>> init/Kconfig | 7 +
>> kernel/cgroup/Makefile | 1 +
>> kernel/cgroup/dev.c | 893 ++++++++++++++++++++++++
>> mm/page_counter.c | 4 +-
>> 11 files changed, 1114 insertions(+), 3 deletions(-)
>> create mode 100644 Documentation/core-api/cgroup.rst
>> create mode 100644 Documentation/gpu/drm-compute.rst
>> create mode 100644 include/linux/cgroup_dev.h
>> create mode 100644 kernel/cgroup/dev.c
>
> Just a general comment.
>
> Cgroup v1 has a legacy device controller in security/device_cgroup.c
> which is no longer available in cgroup v2. So if you use the name device
> controller, the documentation must be clear that it is completely
> different and have no relationship from the device controller in cgroup v1.
Hey,
Thanks for noticing. I didn't know there was such a controller. Seems
weird to have one for managing access to opening devnodes instead of a
security module.
I'll update the documentation in the next version to make it more clear.
Cheers,
~Maarten
next prev parent reply other threads:[~2024-11-11 9:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 7:52 [PATCH 0/7] kernel/cgroups: " Maarten Lankhorst
2024-10-23 7:52 ` [PATCH 1/7] kernel/cgroup: " Maarten Lankhorst
2024-10-23 15:26 ` Waiman Long
2024-11-11 9:28 ` Maarten Lankhorst [this message]
2024-10-25 5:44 ` kernel test robot
2024-10-28 14:53 ` Friedrich Vock
2024-11-11 22:53 ` Maarten Lankhorst
2024-11-14 8:45 ` Friedrich Vock
2024-10-23 7:52 ` [PATCH 2/7] drm/drv: Add drmm cgroup registration for dev cgroups Maarten Lankhorst
2024-10-23 8:45 ` Jani Nikula
2024-10-24 10:35 ` kernel test robot
2024-10-24 15:42 ` kernel test robot
2024-10-23 7:52 ` [PATCH 3/7] drm/ttm: Handle cgroup based eviction in TTM Maarten Lankhorst
2024-10-23 7:52 ` [PATCH 4/7] drm/xe: Implement cgroup for vram Maarten Lankhorst
2024-10-23 7:52 ` [PATCH 5/7] drm/amdgpu: Add cgroups implementation Maarten Lankhorst
2024-10-23 7:52 ` [PATCH 6/7] [HACK] drm/xe: Hack to test with mapped pages instead of vram Maarten Lankhorst
2024-10-23 8:52 ` Jani Nikula
2024-10-23 7:53 ` [PATCH 7/7] [DISCUSSION] drm/gem: Add cgroup memory accounting Maarten Lankhorst
2024-10-23 19:40 ` [PATCH 0/7] kernel/cgroups: Add "dev" memory accounting cgroup Tejun Heo
2024-10-24 7:20 ` Maxime Ripard
2024-10-24 17:06 ` Tejun Heo
2024-10-28 10:05 ` Maxime Ripard
2024-10-29 20:38 ` Johannes Weiner
2024-11-06 10:31 ` Maxime Ripard
2024-11-06 18:20 ` Tejun Heo
2024-11-13 14:58 ` Maarten Lankhorst
2024-11-13 18:29 ` Tejun Heo
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=2ddaf010-ce31-4957-bc4f-7f4c1bfe0826@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=friedrich.vock@gmx.de \
--cc=hannes@cmpxchg.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=llong@redhat.com \
--cc=mripard@kernel.org \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox