mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wangtao <tao.wangtao@honor.com>
To: "Christian König" <christian.koenig@amd.com>,
	"sumit.semwal@linaro.org" <sumit.semwal@linaro.org>,
	"benjamin.gaignard@collabora.com"
	<benjamin.gaignard@collabora.com>,
	"Brian.Starkey@arm.com" <Brian.Starkey@arm.com>,
	"jstultz@google.com" <jstultz@google.com>,
	"tjmercier@google.com" <tjmercier@google.com>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wangbintian(BintianWang)" <bintian.wang@honor.com>,
	yipengxiang <yipengxiang@honor.com>,
	liulu 00013167 <liulu.liu@honor.com>,
	"hanfeng 00012985" <feng.han@honor.com>
Subject: RE: [PATCH 2/2] dmabuf/heaps: implement DMA_BUF_IOCTL_RW_FILE for system_heap
Date: Mon, 19 May 2025 04:08:17 +0000	[thread overview]
Message-ID: <3d098b2109824738a5d1316bd1a516c1@honor.com> (raw)
In-Reply-To: <772d694e-706a-4d98-a236-43d59094e8d6@amd.com>



> -----Original Message-----
> From: Christian König <christian.koenig@amd.com>
> Sent: Friday, May 16, 2025 6:29 PM
> To: wangtao <tao.wangtao@honor.com>; sumit.semwal@linaro.org;
> benjamin.gaignard@collabora.com; Brian.Starkey@arm.com;
> jstultz@google.com; tjmercier@google.com
> Cc: linux-media@vger.kernel.org; dri-devel@lists.freedesktop.org; linaro-
> mm-sig@lists.linaro.org; linux-kernel@vger.kernel.org;
> wangbintian(BintianWang) <bintian.wang@honor.com>; yipengxiang
> <yipengxiang@honor.com>; liulu <liulu.liu@honor.com>; hanfeng
> <feng.han@honor.com>
> Subject: Re: [PATCH 2/2] dmabuf/heaps: implement
> DMA_BUF_IOCTL_RW_FILE for system_heap
> 
> On 5/16/25 11:49, wangtao wrote:
> >>>> Please try using udmabuf with sendfile() as confirmed to be working
> >>>> by
> >> T.J.
> >>> [wangtao] Using buffer IO with dmabuf file read/write requires one
> >> memory copy.
> >>> Direct IO removes this copy to enable zero-copy. The sendfile system
> >>> call reduces memory copies from two (read/write) to one. However,
> >>> with udmabuf, sendfile still keeps at least one copy, failing zero-copy.
> >>
> >>
> >> Then please work on fixing this.
> > [wangtao] What needs fixing? Does sendfile achieve zero-copy?
> > sendfile reduces memory copies (from 2 to 1) for network sockets, but
> > still requires one copy and cannot achieve zero copies.
> 
> Well why not? See sendfile() is the designated Linux uAPI for moving data
> between two files, maybe splice() is also appropriate.
> 
> The memory file descriptor and your destination file are both a files. So those
> uAPIs apply.
[wangtao] I realize our disagreement lies here:  
You believe sendfile enables zero-copy for regular file → socket/file:  
sendfile(dst_socket, src_disk)  
[disk] --DMA--> [page buffer] --DMA--> [NIC]  
sendfile(dst_disk, src_disk)  
[disk] --DMA--> [page buffer] --DMA--> [DISK]  

But for regular file → memory file (e.g., tmpfs/shmem), a CPU copy is unavoidable:  
sendfile(dst_memfile, src_disk)  
[disk] --DMA--> [page buffer] --CPU copy--> [DISK]  
Without memory-to-memory DMA, this wastes CPU/power — critical for embedded devices.  

> 
> Now what you suggest is to add a new IOCTL to do this in a very specific
> manner just for the system DMA-buf heap. And as far as I can see that is in
> general a complete no-go.
> 
> I mean I understand why you do this. Instead of improving the existing
> functionality you're just hacking something together because it is simple for
> you.
> 
> It might be possible to implement that generic for DMA-buf heaps if
> udmabuf allocation overhead can't be reduced, but that is then just the
> second step.
[wangtao] On dmabuf:  
- DMABUF lacks Direct I/O support, hence our proposal.  
- memfd supports Direct I/O but doesn’t fit our use case.  
- udmabuf via memfd works but needs systemic changes (low ROI) and has slow allocation.  

Your objections:  
1. Adding an IOCTL? This targets dmabuf specifically, and our fix is simple.  
   sendfile doesn’t resolve it.
2. Accessing sgtable pages in the exporter? As the dmabuf creator, the exporter  
   fully controls sgtable/page data. We can restrict access to cases with no  
   external users.

Could you clarify which point you oppose?

> 
> Regards,
> Christian.

  reply	other threads:[~2025-05-19  4:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13  9:28 wangtao
2025-05-13 11:32 ` Christian König
2025-05-13 12:30   ` wangtao
2025-05-13 13:17     ` Christian König
2025-05-14 11:02       ` wangtao
2025-05-14 12:00         ` Christian König
2025-05-15 14:03           ` wangtao
2025-05-15 14:26             ` Christian König
2025-05-16  7:40               ` wangtao
2025-05-16  8:36                 ` Christian König
2025-05-16  9:49                   ` wangtao
2025-05-16 10:29                     ` Christian König
2025-05-19  4:08                       ` wangtao [this message]
2025-05-19  7:47                         ` Christian König
2025-05-16 18:37                   ` T.J. Mercier
2025-05-19  4:37                     ` wangtao
2025-05-19 12:03                     ` wangtao
2025-05-20  4:06                       ` wangtao
2025-05-21  2:00                         ` T.J. Mercier
2025-05-21  4:17                           ` wangtao
2025-05-21  7:35                             ` Christian König
2025-05-21 10:25                               ` wangtao
2025-05-21 11:56                                 ` Christian König
2025-05-22  8:02                                   ` wangtao
2025-05-22 11:57                                     ` Christian König
2025-05-22 12:29                                       ` wangtao
2025-05-27 14:35                                       ` wangtao
2025-05-27 15:10                                         ` Christian König

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=3d098b2109824738a5d1316bd1a516c1@honor.com \
    --to=tao.wangtao@honor.com \
    --cc=Brian.Starkey@arm.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=bintian.wang@honor.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=feng.han@honor.com \
    --cc=jstultz@google.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=liulu.liu@honor.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tjmercier@google.com \
    --cc=yipengxiang@honor.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

all inboxes | Powered by JetHome®