[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220321174530.GB9640@blackbody.suse.cz>
Date: Mon, 21 Mar 2022 18:45:30 +0100
From: Michal Koutný <mkoutny@...e.com>
To: "T.J. Mercier" <tjmercier@...gle.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Jonathan Corbet <corbet@....net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>,
Martijn Coenen <maco@...roid.com>,
Joel Fernandes <joel@...lfernandes.org>,
Christian Brauner <brauner@...nel.org>,
Hridya Valsaraju <hridya@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Christian König <christian.koenig@....com>,
Benjamin Gaignard <benjamin.gaignard@...aro.org>,
Liam Mark <lmark@...eaurora.org>,
Laura Abbott <labbott@...hat.com>,
Brian Starkey <Brian.Starkey@....com>,
John Stultz <john.stultz@...aro.org>,
Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Shuah Khan <shuah@...nel.org>, kaleshsingh@...gle.com,
Kenny.Ho@....com, dri-devel@...ts.freedesktop.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org,
cgroups@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [RFC v3 5/8] dmabuf: Add gpu cgroup charge transfer function
Hello.
On Wed, Mar 09, 2022 at 04:52:15PM +0000, "T.J. Mercier" <tjmercier@...gle.com> wrote:
> +int dma_buf_charge_transfer(struct dma_buf *dmabuf, struct gpucg *gpucg)
> +{
> +#ifdef CONFIG_CGROUP_GPU
> + struct gpucg *current_gpucg;
> + int ret = 0;
> +
> + /*
> + * Verify that the cgroup of the process requesting the transfer is the
> + * same as the one the buffer is currently charged to.
> + */
> + current_gpucg = gpucg_get(current);
> + mutex_lock(&dmabuf->lock);
> + if (current_gpucg != dmabuf->gpucg) {
> + ret = -EPERM;
> + goto err;
> + }
Add a shortcut for gpucg == current_gpucg?
> +
> + ret = gpucg_try_charge(gpucg, dmabuf->gpucg_dev, dmabuf->size);
> + if (ret)
> + goto err;
> +
> + dmabuf->gpucg = gpucg;
> +
> + /* uncharge the buffer from the cgroup it's currently charged to. */
> + gpucg_uncharge(current_gpucg, dmabuf->gpucg_dev, dmabuf->size);
I think gpucg_* API would need to cater for such transfers too since
possibly transitional breach of a limit during the transfer may
unnecessarily fail the operation.
My 0.02€,
Michal
Powered by blists - more mailing lists