Dave, On Mon, 18 Aug 2003, David S. Miller wrote: > On Sun, 17 Aug 2003 22:36:40 +0530 (IST) > Nagendra Singh Tomar <nagendra_tomar@adaptec.com> wrote: > > > But in the case of the user making a temp file, mmaping it, > > writing to the mmaped area and then using sendfile, we are not saving > any > > copy. > > Yes we are. How and where ?? > > > Is'nt this the same like, user passing a buffer to sendmsg(). > > Nope, it's totally different. > > > This buffer gets copied to an skbuff > > Nope, sendfile() will merely hang a reference to the page in > the filesystem cache holding this data, no copies will be made. > The card will DMA directly from memory and checksum the packet. My statement, that buffer gets copied to an skbuff, is not for the senfile(), but for sendmsg() case. The counterpart for this in the case of sendfile() (using mmaped temp file) is the copy from the user buffer to the file's page cache, when we write to the pointer returned by mmap() on the temp file. I can not see any difference in number of copies. sendmsg case: ------------ s= socket(); send(s, buff, 1000..); -->> here the buff contents get copied from the user space buffer to the kernel skbuff <<--- sendfile case: ------------- s=socket(); f=open("/tmp/randfile"..) write(f,buff, 1000); -->> here the buff contents get copied from the user space buffer to the kernel space page cache <<-- sendfile(s,f,0, 1000); My point is that the overhead is the same in both cases, as depicted in the above pseudo code. > > Franks a lot, > David S. Miller > davem@redhat.com > Thanx tomar - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html