From owner-freebsd-hackers Sat Jan 11 13:18:59 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4081937B401 for ; Sat, 11 Jan 2003 13:18:57 -0800 (PST) Received: from k6.locore.ca (k6.locore.ca [198.96.117.170]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACD8343F6B for ; Sat, 11 Jan 2003 13:18:54 -0800 (PST) (envelope-from jake@k6.locore.ca) Received: from k6.locore.ca (jake@localhost.locore.ca [127.0.0.1]) by k6.locore.ca (8.12.6/8.12.6) with ESMTP id h0BLIojb000591; Sat, 11 Jan 2003 16:18:50 -0500 (EST) (envelope-from jake@k6.locore.ca) Received: (from jake@localhost) by k6.locore.ca (8.12.6/8.12.6/Submit) id h0BLIofG000590; Sat, 11 Jan 2003 16:18:50 -0500 (EST) Date: Sat, 11 Jan 2003 16:18:50 -0500 From: Jake Burkholder To: Matthew Dillon Cc: hackers@FreeBSD.ORG, "Alan L. Cox" , Tor.Egge@cvsup.no.freebsd.org Subject: Re: vmapbuf/vunmapbuf consolidation -- need alpha/ia64 review. Message-ID: <20030111161850.C212@locore.ca> References: <20021102171534X.tegge@cvsup.no.freebsd.org> <3DCD7F3A.DE013857@imimic.com> <200301092137.h09Lbo0E005483@apollo.backplane.com> <3E1DF369.81ADB566@imimic.com> <200301100058.h0A0wiqo000380@apollo.backplane.com> <3E1FF17B.455C2A71@imimic.com> <200301112051.h0BKpiWr047795@apollo.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200301112051.h0BKpiWr047795@apollo.backplane.com>; from dillon@apollo.backplane.com on Sat, Jan 11, 2003 at 12:51:44PM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Apparently, On Sat, Jan 11, 2003 at 12:51:44PM -0800, Matthew Dillon said words to the effect of; > This patch consolidates all the vmapbuf()/vunmapbuf() implementations > into kern/vfs_bio.c, removing them from */*/vm_machdep.c. Cool. I was planning to do this myself just for general cleanup. > Index: kern/vfs_bio.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/vfs_bio.c,v > retrieving revision 1.352 > diff -u -r1.352 vfs_bio.c > --- kern/vfs_bio.c 7 Jan 2003 19:55:08 -0000 1.352 > +++ kern/vfs_bio.c 11 Jan 2003 20:42:03 -0000 > @@ -3540,6 +3540,77 @@ > bp->b_npages = newnpages; > } > > +/* > + * Map an IO request into kernel virtual address space. > + * > + * All requests are (re)mapped into kernel VA space. > + * Notice that we use b_bufsize for the size of the buffer > + * to be mapped. b_bcount might be modified by the driver. > + */ > +void > +vmapbuf(struct buf *bp) > +{ > + caddr_t addr, kva; > + vm_offset_t pa; > + int pidx; > + struct vm_page *m; > + > + GIANT_REQUIRED; > + > + if ((bp->b_flags & B_PHYS) == 0) > + panic("vmapbuf"); > + > + for (addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data), pidx = 0; > + addr < bp->b_data + bp->b_bufsize; > + addr += PAGE_SIZE, pidx++) { > + /* > + * Do the vm_fault if needed; do the copy-on-write thing > + * when reading stuff off device into memory. > + */ > + vm_fault_quick((addr >= bp->b_data) ? addr : bp->b_data, > + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); > + pa = trunc_page(pmap_kextract((vm_offset_t) addr)); The sparc64 version is subtely different here. You need use pmap_extract with the pmap of the current process, pmap_kextract won't work even for the current address space because kva is not mapped into each process's pmap. ... pmap = &curproc->p_vmspace->vm_pmap; ... pa = trunc_page(pmap_extract(pmap, (vm_offset_t)addr)); ... This should work for all platforms. The rest looks fine apart from style bugs. Jake To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message