On 9 Jan 2023 21:38:06 +0000 T.J. Mercier <tjmerc...@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 via email to