[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db60bb1d-51b6-6830-5a4c-100ba38a2dbc@linux.intel.com>
Date: Tue, 17 Jan 2023 16:25:09 +0000
From: Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>
To: Stanislaw Gruszka <stanislaw.gruszka@...ux.intel.com>
Cc: Intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
Rob Clark <robdclark@...omium.org>,
Brian Welty <brian.welty@...el.com>, Kenny.Ho@....com,
Tvrtko Ursulin <tvrtko.ursulin@...el.com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Johannes Weiner <hannes@...xchg.org>,
linux-kernel@...r.kernel.org,
Stéphane Marchesin <marcheu@...omium.org>,
Christian König <christian.koenig@....com>,
Zefan Li <lizefan.x@...edance.com>,
Dave Airlie <airlied@...hat.com>, Tejun Heo <tj@...nel.org>,
cgroups@...r.kernel.org, "T . J . Mercier" <tjmercier@...gle.com>
Subject: Re: [RFC 04/12] drm/cgroup: Track clients per owning process
On 17/01/2023 16:03, Stanislaw Gruszka wrote:
> Hi
>
> On Thu, Jan 12, 2023 at 04:56:01PM +0000, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@...el.com>
>>
>> To enable propagation of settings from the cgroup drm controller to drm we
>> need to start tracking which processes own which drm clients.
>>
>> Implement that by tracking the struct pid pointer of the owning process in
>> a new XArray, pointing to a structure containing a list of associated
>> struct drm_file pointers.
>>
>> Clients are added and removed under the filelist mutex and RCU list
>> operations are used below it to allow for lockless lookup.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@...el.com>
>
> <snip>
>
>> +int drm_clients_open(struct drm_file *file_priv)
>> +{
>> + struct drm_device *dev = file_priv->minor->dev;
>> + struct drm_pid_clients *clients;
>> + bool new_client = false;
>> + unsigned long pid;
>> +
>> + lockdep_assert_held(&dev->filelist_mutex);
>> +
>> + pid = (unsigned long)rcu_access_pointer(file_priv->pid);
>> + clients = xa_load(&drm_pid_clients, pid);
>> + if (!clients) {
>> + clients = __alloc_clients();
>> + if (!clients)
>> + return -ENOMEM;
>> + new_client = true;
>> + }
>> + atomic_inc(&clients->num);
>> + list_add_tail_rcu(&file_priv->clink, &clients->file_list);
>> + if (new_client) {
>> + void *xret;
>> +
>> + xret = xa_store(&drm_pid_clients, pid, clients, GFP_KERNEL);
>> + if (xa_err(xret)) {
>> + list_del_init(&file_priv->clink);
>> + kfree(clients);
>> + return PTR_ERR(clients);
>
> This looks incorrect, rather xa_err(xret) should be returned.
Thanks, looks like a copy & paste error. Noted to correct before next
public post.
Regards,
Tvrtko
Powered by blists - more mailing lists