dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: "T.J. Mercier" <tjmercier@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	daniel.vetter@ffwll.ch, Tejun Heo <tj@kernel.org>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 3/4] binder: Add flags to relinquish ownership of fds
Date: Tue, 10 Jan 2023 09:47:20 +0800	[thread overview]
Message-ID: <20230110014720.281-1-hdanton@sina.com> (raw)
In-Reply-To: <20230109213809.418135-4-tjmercier@google.com>

On 9 Jan 2023 21:38:06 +0000 T.J. Mercier <tjmercier@google.com>
>  
> @@ -2275,6 +2276,26 @@ static int binder_translate_fd(u32 fd, binder_size_t fd_offset,
>  		goto err_security;
>  	}
>  
> +	if (IS_ENABLED(CONFIG_MEMCG) && (flags & BINDER_FD_FLAG_XFER_CHARGE)) {
> +		struct dma_buf *dmabuf;
> +
> +		if (unlikely(!is_dma_buf_file(file))) {
> +			binder_user_error(
> +				"%d:%d got transaction with XFER_CHARGE for non-dmabuf fd, %d\n",
> +				proc->pid, thread->pid, fd);
> +			ret = -EINVAL;
> +			goto err_dmabuf;
> +		}

It barely makes sense to expose is_dma_buf_file() only for this.
> +
> +		dmabuf = file->private_data;
> +		ret = dma_buf_transfer_charge(dmabuf, target_proc->tsk);
> +		if (ret) {
> +			pr_warn("%d:%d Unable to transfer DMA-BUF fd charge to %d\n",
> +				proc->pid, thread->pid, target_proc->pid);
> +			goto err_xfer;
> +		}
> +	}
> +

This whole hunk should go to dma-buf instead by adding change to
dma_buf_transfer_charge() for instance.

  reply	other threads:[~2023-01-10  2:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 21:38 [PATCH 0/4] Track exported dma-buffers with memcg T.J. Mercier
2023-01-09 21:38 ` [PATCH 1/4] memcg: Track exported dma-buffers T.J. Mercier
2023-01-10  8:58   ` Michal Hocko
2023-01-10 19:08     ` T.J. Mercier
2023-01-09 21:38 ` [PATCH 2/4] dmabuf: Add cgroup charge transfer function T.J. Mercier
2023-01-09 21:38 ` [PATCH 3/4] binder: Add flags to relinquish ownership of fds T.J. Mercier
2023-01-10  1:47   ` Hillf Danton [this message]
2023-01-10 21:20     ` T.J. Mercier
2023-01-20 21:25   ` Carlos Llamas
2023-01-20 21:52     ` T.J. Mercier
2023-01-10  0:18 ` [PATCH 0/4] Track exported dma-buffers with memcg Shakeel Butt
2023-01-11 22:56   ` Daniel Vetter
2023-01-12  0:49     ` T.J. Mercier
2023-01-12  8:13       ` Shakeel Butt
2023-01-12  8:17         ` Christian König
2023-01-12  7:56     ` Shakeel Butt
2023-01-12 10:25       ` Michal Hocko

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=20230110014720.281-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tjmercier@google.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