From owner-freebsd-current Mon Aug 19 9:49:38 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF22837B400; Mon, 19 Aug 2002 09:49:34 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5710643E84; Mon, 19 Aug 2002 09:49:34 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.5/8.12.4) with ESMTP id g7JGnXdc077529; Mon, 19 Aug 2002 09:49:33 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.5/8.12.4/Submit) id g7JGnXIR077528; Mon, 19 Aug 2002 09:49:33 -0700 (PDT) (envelope-from dillon) Date: Mon, 19 Aug 2002 09:49:33 -0700 (PDT) From: Matthew Dillon Message-Id: <200208191649.g7JGnXIR077528@apollo.backplane.com> To: "Semen A. Ustimenko" Cc: Bruce Evans , freebsd-current@FreeBSD.ORG, Maxim Konovalov , Robert Watson , Subject: Re: sendfile() change (Was: Re: cvs commit: src/sys/kern uipc_syscalls.c) References: <20020819231230.S678-100000@main.the.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :Hi! : :Why can't we get rid of VOP_READ(.. UIO_NOCOPY...) call in sendfile()? :Me, I can't quite understand what UIO_NOCOPY means... As long as :sendfile() function already plays around pages, it can use VOP_GETPAGES(). :The following patch looks works for me. Could anybody said if it has any :benefits or not? : :Index: uipc_syscalls.c :=================================================================== :RCS file: /home/ncvs/src/sys/kern/uipc_syscalls.c,v :retrieving revision 1.110 :diff -u -r1.110 uipc_syscalls.c :--- uipc_syscalls.c 20 May 2002 05:41:03 -0000 1.110 :+++ uipc_syscalls.c 13 Aug 2002 17:54:33 -0000 :@@ -1820,10 +1820,7 @@ : */ : bsize = vp->v_mount->mnt_stat.f_iosize; : vn_lock(vp, LK_SHARED | LK_NOPAUSE | LK_RETRY, td); :- error = vn_rdwr(UIO_READ, vp, NULL, MAXBSIZE, :- trunc_page(off), UIO_NOCOPY, IO_NODELOCKED | :- IO_VMIO | ((MAXBSIZE / bsize) << 16), :- td->td_ucred, NULL, td); :+ error = VOP_GETPAGES(vp, &pg, PAGE_SIZE, 0, 0); : VOP_UNLOCK(vp, 0, td); : vm_page_flag_clear(pg, PG_ZERO); : vm_page_io_finish(pg); : :Bye! UIO_NOCOPY tells the filesystem to not bother copying the data into the passed buffer but to instead simply load it into the buffer cache / VM backing store. While this adds buffer cache management overhead, it ought to yield far greater performance over doing a VOP_GETPAGES() at this point because the filesystem will be able to do clustered reads and read-ahead (potentially a 64K I/O) instead of a 4K I/O. An alternative would be to cluster the VM pages in sendfile() and call VOP_GETPAGES() on a block of pages instead of just one. I'm guessing that is not being done because it's about 100 lines of code to do it right. It's easier just to call vn_rdwr() and let the system do the clustering. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message