Re: [PATCH v4 5/6] drm: Add fdinfo memory stats

From: Tvrtko Ursulin
Date: Fri Apr 21 2023 - 08:00:08 EST



On 21/04/2023 12:45, Emil Velikov wrote:
On Fri, 21 Apr 2023 at 12:23, Tvrtko Ursulin
<tvrtko.ursulin@xxxxxxxxxxxxxxx> wrote:

On 21/04/2023 11:26, Emil Velikov wrote:
On Wed, 12 Apr 2023 at 23:43, Rob Clark <robdclark@xxxxxxxxx> wrote:

+/**
+ * enum drm_gem_object_status - bitmask of object state for fdinfo reporting
+ * @DRM_GEM_OBJECT_RESIDENT: object is resident in memory (ie. not unpinned)
+ * @DRM_GEM_OBJECT_PURGEABLE: object marked as purgeable by userspace
+ *
+ * Bitmask of status used for fdinfo memory stats, see &drm_gem_object_funcs.status
+ * and drm_show_fdinfo(). Note that an object can DRM_GEM_OBJECT_PURGEABLE if
+ * it still active or not resident, in which case drm_show_fdinfo() will not

nit: s/can/can be/;s/if it still/if it is still/

+ * account for it as purgeable. So drivers do not need to check if the buffer
+ * is idle and resident to return this bit. (Ie. userspace can mark a buffer
+ * as purgeable even while it is still busy on the GPU.. it does not _actually_
+ * become puregeable until it becomes idle. The status gem object func does

nit: s/puregeable/purgeable/


I think we want a similar note in the drm-usage-stats.rst file.

With the above the whole series is:
Reviewed-by: Emil Velikov <emil.l.velikov@xxxxxxxxx>

Have you maybe noticed my slightly alternative proposal? (*) I am not a
fan of putting this flavour of accounting into the core with no way to
opt out. I think it leaves no option but to add more keys in the future
for any driver which will not be happy with the core accounting.

*) https://patchwork.freedesktop.org/series/116581/


Indeed I saw it. Not a fan of it, I'm afraid.

Hard to guess the reasons. :)

Anyway, at a minimum I suggest that if the no opt out version has to go in, it is clearly documented drm-*-memory-* is *not* about the full memory use of the client, but about memory belonging to user visible buffer objects *only*. Possibly going as far as naming the keys as drm-user-bo-memory-... That way there is a way to implement proper drm-*-memory- in the future.

Regards,

Tvrtko

Fwiw: Keeping the i915 patch as part of this series would be great.
Sure i915_drm_client->id becomes dead code, but it's a piece one can
live with for a release or two. Then again it's not my call to make.

Rob can take the i915 patch from my RFC too.


Indeed.

-Emil