dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "sunnanyong@huawei.com" <sunnanyong@huawei.com>,
	"Ho, Kenny" <Kenny.Ho@amd.com>,
	"Welty, Brian" <brian.welty@intel.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	Kenny Ho <y2kenny@gmail.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	Tejun Heo <tj@kernel.org>,
	"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>
Subject: Re: [RFC PATCH v2 4/5] drm, cgroup: Add total GEM buffer allocation limit
Date: Thu, 16 May 2019 14:08:38 +0000	[thread overview]
Message-ID: <65075485-3c94-41cf-d39a-1fd451ecc430@amd.com> (raw)
In-Reply-To: <20190516122858.GB3851@phenom.ffwll.local>

Am 16.05.19 um 14:28 schrieb Daniel Vetter:
> [CAUTION: External Email]
>
> On Thu, May 16, 2019 at 09:25:31AM +0200, Christian König wrote:
>> Am 16.05.19 um 09:16 schrieb Koenig, Christian:
>>> Am 16.05.19 um 04:29 schrieb Kenny Ho:
>>>> [CAUTION: External Email]
>>>>
>>>> On Wed, May 15, 2019 at 5:26 PM Welty, Brian <brian.welty@intel.com> wrote:
>>>>> On 5/9/2019 2:04 PM, Kenny Ho wrote:
>>>>>> There are four control file types,
>>>>>> stats (ro) - display current measured values for a resource
>>>>>> max (rw) - limits for a resource
>>>>>> default (ro, root cgroup only) - default values for a resource
>>>>>> help (ro, root cgroup only) - help string for a resource
>>>>>>
>>>>>> Each file is multi-lined with one entry/line per drm device.
>>>>> Multi-line is correct for multiple devices, but I believe you need
>>>>> to use a KEY to denote device for both your set and get routines.
>>>>> I didn't see your set functions reading a key, or the get functions
>>>>> printing the key in output.
>>>>> cgroups-v2 conventions mention using KEY of major:minor, but I think
>>>>> you can use drm_minor as key?
>>>> Given this controller is specific to the drm kernel subsystem which
>>>> uses minor to identify drm device,
>>> Wait a second, using the DRM minor is a good idea in the first place.
>> Well that should have read "is not a good idea"..
> What else should we use?

Well what does for example udev uses to identify a device?

>> Christian.
>>
>>> I have a test system with a Vega10 and a Vega20. Which device gets which
>>> minor is not stable, but rather defined by the scan order of the PCIe bus.
>>>
>>> Normally the scan order is always the same, but adding or removing
>>> devices or delaying things just a little bit during init is enough to
>>> change this.
>>>
>>> We need something like the Linux sysfs location or similar to have a
>>> stable implementation.
> You can go from sysfs location to drm class directory (in sysfs) and back.
> That means if you care you need to walk sysfs yourself a bit, but using
> the drm minor isn't a blocker itself.

Yeah, agreed that userspace could do this. But I think if there is an of 
hand alternative we should use this instead.

> One downside with the drm minor is that it's pretty good nonsense once you
> have more than 64 gpus though, due to how we space render and legacy nodes
> in the minor ids :-)

Ok, another good reason to at least not use the minor=linenum approach.

Christian.

> -Daniel
>>> Regards,
>>> Christian.
>>>
>>>>     I don't see a need to complicate
>>>> the interfaces more by having major and a key.  As you can see in the
>>>> examples below, the drm device minor corresponds to the line number.
>>>> I am not sure how strict cgroup upstream is about the convention but I
>>>> am hoping there are flexibility here to allow for what I have
>>>> implemented.  There are a couple of other things I have done that is
>>>> not described in the convention: 1) inclusion of read-only *.help file
>>>> at the root cgroup, 2) use read-only (which I can potentially make rw)
>>>> *.default file instead of having a default entries (since the default
>>>> can be different for different devices) inside the control files (this
>>>> way, the resetting of cgroup values for all the drm devices, can be
>>>> done by a simple 'cp'.)
>>>>
>>>>>> Usage examples:
>>>>>> // set limit for card1 to 1GB
>>>>>> sed -i '2s/.*/1073741824/' /sys/fs/cgroup/<cgroup>/drm.buffer.total.max
>>>>>>
>>>>>> // set limit for card0 to 512MB
>>>>>> sed -i '1s/.*/536870912/' /sys/fs/cgroup/<cgroup>/drm.buffer.total.max
>>>>>>     /** @file drm_gem.c
>>>>>> @@ -154,6 +156,9 @@ void drm_gem_private_object_init(struct drm_device *dev,
>>>>>>          obj->handle_count = 0;
>>>>>>          obj->size = size;
>>>>>>          drm_vma_node_reset(&obj->vma_node);
>>>>>> +
>>>>>> +     obj->drmcgrp = get_drmcgrp(current);
>>>>>> +     drmcgrp_chg_bo_alloc(obj->drmcgrp, dev, size);
>>>>> Why do the charging here?
>>>>> There is no backing store yet for the buffer, so this is really tracking something akin to allowed virtual memory for GEM objects?
>>>>> Is this really useful for an administrator to control?
>>>>> Isn't the resource we want to control actually the physical backing store?
>>>> That's correct.  This is just the first level of control since the
>>>> backing store can be backed by different type of memory.  I am in the
>>>> process of adding at least two more resources.  Stay tuned.  I am
>>>> doing the charge here to enforce the idea of "creator is deemed owner"
>>>> at a place where the code is shared by all (the init function.)
>>>>
>>>>>> +     while (i <= max_minor && limits != NULL) {
>>>>>> +             sval =  strsep(&limits, "\n");
>>>>>> +             rc = kstrtoll(sval, 0, &val);
>>>>> Input should be "KEY VALUE", so KEY will determine device to apply this to.
>>>>> Also, per cgroups-v2 documentation of limits, I believe need to parse and handle the special "max" input value.
>>>>>
>>>>> parse_resources() in rdma controller is example for both of above.
>>>> Please see my previous reply for the rationale of my hope to not need
>>>> a key.  I can certainly add handling of "max" and "default".
>>>>
>>>>
>>>>>> +void drmcgrp_chg_bo_alloc(struct drmcgrp *drmcgrp, struct drm_device *dev,
>>>>>> +             size_t size)
>>>>> Shouldn't this return an error and be implemented with same semantics as the
>>>>> try_charge() functions of other controllers?
>>>>> Below will allow stats_total_allocated to overrun limits_total_allocated.
>>>> This is because I am charging the buffer at the init of the buffer
>>>> which does not fail so the "try" (drmcgrp_bo_can_allocate) is separate
>>>> and placed earlier and nearer other condition where gem object
>>>> allocation may fail.  In other words, there are multiple possibilities
>>>> for which gem allocation may fail (cgroup limit being one of them) and
>>>> satisfying cgroup limit does not mean a charge is needed.  I can
>>>> certainly combine the two functions to have an additional try_charge
>>>> semantic as well if that is really needed.
>>>>
>>>> Regards,
>>>> Kenny
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-05-16 14:08 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 18:58 [PATCH RFC 0/5] DRM cgroup controller Kenny Ho
2018-11-20 18:58 ` [PATCH RFC 1/5] cgroup: Introduce cgroup for drm subsystem Kenny Ho
     [not found] ` <20181120185814.13362-1-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2018-11-20 18:58   ` [PATCH RFC 2/5] cgroup: Add mechanism to register vendor specific DRM devices Kenny Ho
     [not found]     ` <20181120185814.13362-3-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2018-11-20 20:21       ` Tejun Heo
     [not found]         ` <20181120202141.GA2509588-LpCCV3molIbIZ9tKgghJQw2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2018-11-20 22:21           ` Ho, Kenny
     [not found]             ` <DM5PR12MB1226E972538A45325114ADF683D90-2J9CzHegvk+lTFawYev2gQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-11-20 22:30               ` Tejun Heo
     [not found]                 ` <20181120223018.GB2509588-LpCCV3molIbIZ9tKgghJQw2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2018-11-21 22:07                   ` Ho, Kenny
2018-11-21 22:12                   ` Ho, Kenny
2018-11-26 20:59                   ` Kasiviswanathan, Harish
2018-11-27  9:38                     ` Koenig, Christian
2018-11-27  9:46                     ` [Intel-gfx] " Joonas Lahtinen
2018-11-27 15:41                       ` Ho, Kenny
2018-11-28  9:14                         ` Joonas Lahtinen
2018-11-28 19:46                           ` Ho, Kenny
2018-11-30 22:22                             ` Matt Roper
     [not found]                               ` <20181130222228.GE31345-b/RNqDZ/lqH1fpGqjiHozbKMmGWinSIL2HeeBUIffwg@public.gmane.org>
2018-12-03  6:46                                 ` [Intel-gfx] " Ho, Kenny
2018-12-03 18:58                                   ` Matt Roper
     [not found]                           ` <154339645444.5339.6291298808444340104-zzJjBcU1GAT9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2018-12-03 20:55                             ` Kuehling, Felix
     [not found]                               ` <219f8754-3e14-05ad-07a3-6cddb8bb74aa-5C7GfCeVMHo@public.gmane.org>
2018-12-05 14:20                                 ` Joonas Lahtinen
2018-11-21  9:53       ` Christian König
2018-11-20 18:58   ` [PATCH RFC 3/5] drm/amdgpu: Add DRM cgroup support for AMD devices Kenny Ho
     [not found]     ` <20181120185814.13362-4-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2018-11-21  9:55       ` Christian König
2018-11-20 18:58   ` [PATCH RFC 4/5] drm/amdgpu: Add accounting of command submission via DRM cgroup Kenny Ho
2018-11-20 20:57     ` Eric Anholt
     [not found]       ` <87r2ff79he.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2018-11-21 10:03         ` Christian König
2018-11-23 17:36           ` Eric Anholt
     [not found]             ` <871s7b7l2b.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2018-11-23 18:13               ` Koenig, Christian
     [not found]                 ` <095e010c-e3b8-ec79-c87b-a05ce1d95e10-5C7GfCeVMHo@public.gmane.org>
2018-11-23 19:09                   ` Ho, Kenny
2018-11-21  9:58     ` Christian König
2018-11-20 18:58 ` [PATCH RFC 5/5] drm/amdgpu: Add accounting of buffer object creation request " Kenny Ho
     [not found]   ` <20181120185814.13362-6-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2018-11-20 20:56     ` Eric Anholt
2018-11-21 10:00     ` Christian König
2018-11-27 18:15       ` Kenny Ho
     [not found]         ` <CAOWid-fMFUvT_XQijRd34+cUOxM=zbbf+HwWv_NbqO-rBo2d_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-11-27 20:31           ` Christian König
     [not found]             ` <3299d9d6-e272-0459-8f63-0c81d11cde1e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-11-27 20:36               ` Kenny Ho
2019-05-09 21:04 ` [RFC PATCH v2 0/5] new cgroup controller for gpu/drm subsystem Kenny Ho
2019-05-09 21:04   ` [RFC PATCH v2 3/5] drm/amdgpu: Register AMD devices for DRM cgroup Kenny Ho
2019-05-09 21:04   ` [RFC PATCH v2 4/5] drm, cgroup: Add total GEM buffer allocation limit Kenny Ho
     [not found]     ` <20190509210410.5471-5-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2019-05-10 12:28       ` Christian König
     [not found]         ` <f63c8d6b-92a4-2977-d062-7e0b7036834e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-05-10 14:57           ` Kenny Ho
2019-05-10 15:08             ` Koenig, Christian
     [not found]               ` <1ca1363e-b39c-c299-1d24-098b1059f7ff-5C7GfCeVMHo@public.gmane.org>
2019-05-10 15:25                 ` Kenny Ho
2019-05-10 17:48                   ` Koenig, Christian
2019-05-10 18:50                     ` Kenny Ho
     [not found]                       ` <CAOWid-es+C_iStQUkM52mO3TeP8eS9MX+emZDQNH2PyZCf=RHQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-13 15:10                         ` Daniel Vetter
2019-05-15 21:26     ` Welty, Brian
     [not found]       ` <d81e8f55-9602-818e-0f9c-1d9d150133b1-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2019-05-16  2:29         ` Kenny Ho
     [not found]           ` <CAOWid-ftUrVVWPu9KuS8xpWKNQT6_FtxB8gEyEAn9nLD6qxb5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-16  7:16             ` Koenig, Christian
2019-05-16  7:25               ` Christian König
     [not found]                 ` <6e124f5e-f83f-5ca1-4616-92538f202653-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-05-16 12:28                   ` Daniel Vetter
2019-05-16 14:08                     ` Koenig, Christian [this message]
2019-05-16 14:03                   ` Kenny Ho
     [not found]                     ` <CAOWid-fQgah16ycz-V-ymsm7yKUnFTeTSBaW4MK=2mqUHhCcmw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-16 14:12                       ` Christian König
2019-05-16 14:28                         ` Kenny Ho
2019-05-16 14:10             ` Tejun Heo
2019-05-16 14:58               ` Kenny Ho
     [not found]   ` <20190509210410.5471-1-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2019-05-09 21:04     ` [RFC PATCH v2 1/5] cgroup: Introduce cgroup for drm subsystem Kenny Ho
2019-05-09 21:04     ` [RFC PATCH v2 2/5] cgroup: Add mechanism to register DRM devices Kenny Ho
2019-05-09 21:04     ` [RFC PATCH v2 5/5] drm, cgroup: Add peak GEM buffer allocation limit Kenny Ho
     [not found]       ` <20190509210410.5471-6-Kenny.Ho-5C7GfCeVMHo@public.gmane.org>
2019-05-10 12:29         ` Christian König
2019-05-10 12:31     ` [RFC PATCH v2 0/5] new cgroup controller for gpu/drm subsystem Christian König
2019-05-10 15:07       ` Kenny Ho
     [not found]         ` <CAOWid-dJZrnAifFYByh4p9x-jA1o_5YWkoNVAVbdRUaxzdPbGA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-10 17:46           ` Koenig, Christian

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=65075485-3c94-41cf-d39a-1fd451ecc430@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Kenny.Ho@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=brian.welty@intel.com \
    --cc=cgroups@vger.kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sunnanyong@huawei.com \
    --cc=tj@kernel.org \
    --cc=y2kenny@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox