Date: Sat, 11 Jan 2003 22:15:00 +0100 From: Thomas Moestl <tmoestl@gmx.net> To: Matthew Dillon <dillon@apollo.backplane.com> Cc: hackers@freebsd.org, "Alan L. Cox" <alc@imimic.com>, Tor.Egge@cvsup.no.freebsd.org Subject: Re: vmapbuf/vunmapbuf consolidation -- need alpha/ia64 review. Message-ID: <20030111211500.GA278@crow.dom2ip.de> In-Reply-To: <200301112051.h0BKpiWr047795@apollo.backplane.com> 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>
index | next in thread | previous in thread | raw e-mail
On Sat, 2003/01/11 at 12:51:44 -0800, Matthew Dillon wrote:
> This patch consolidates all the vmapbuf()/vunmapbuf() implementations
> into kern/vfs_bio.c, removing them from */*/vm_machdep.c.
>
> All the implmentations appeared to be the same. The alpha and Ia64
> implementations appeared to be older versions of the i386 implementation.
>
> I would like people associated with the alpha and ia64 work to review
> the change. Basically the alpha and ia64 were using individual
> pmap_kenter() calls while all the other implementations use a
> single pmap_qenter() call (and appeared to be exactly identical to
> the i386 vmapbuf() and vunmapbuf()).
This common version is not going to work on sparc64; you cannot use
pmap_kextract() there to look up user pages since kernel and user
address space are completely separate. The sparc64 version has the
following changes (the non-'>'-prefixed lines):
> +void
> +vmapbuf(struct buf *bp)
> +{
> + caddr_t addr, kva;
> + vm_offset_t pa;
> + int pidx;
> + struct vm_page *m;
pmap_t pmap;
> +
> + GIANT_REQUIRED;
> +
> + if ((bp->b_flags & B_PHYS) == 0)
> + panic("vmapbuf");
> +
/* XXX: Should probably use vmspace_pmap() here. */
pmap = &curproc->p_vmspace->vm_pmap;
> + 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_extract(pmap, (vm_offset_t)addr));
> + if (pa == 0)
> + panic("vmapbuf: page not present");
> + m = PHYS_TO_VM_PAGE(pa);
> + vm_page_hold(m);
> + bp->b_pages[pidx] = m;
> + }
> + if (pidx > btoc(MAXPHYS))
> + panic("vmapbuf: mapped more than MAXPHYS");
> + pmap_qenter((vm_offset_t)bp->b_saveaddr, bp->b_pages, pidx);
> +
> + kva = bp->b_saveaddr;
> + bp->b_npages = pidx;
> + bp->b_saveaddr = bp->b_data;
> + bp->b_data = kva + (((vm_offset_t) bp->b_data) & PAGE_MASK);
> +}
This version should work on all platforms, so I guess it should be
made the common one.
- Thomas
--
Thomas Moestl <tmoestl@gmx.net> http://www.tu-bs.de/~y0015675/
<tmm@FreeBSD.org> http://people.FreeBSD.org/~tmm/
PGP fingerprint: 1C97 A604 2BD0 E492 51D0 9C0F 1FE6 4F1D 419C 776C
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111211500.GA278>
