NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-amd64/59361: paging up in less(1) under qemu vga console is slow
> Date: Sun, 26 Oct 2025 22:35:24 +0000 (UTC)
> From: RVP <rvp%SDF.ORG@localhost>
>
> Scrolling up (erasure of 1st line, followed by moving the rest of the lines up)
> seems to do a backwards copy. Use plain memmove(3) instead:
>
> @@ -1168,10 +1168,15 @@
> scr->pcs.cursorrow, scr->pcs.cursorcol);
> #endif
> } else {
> + bus_space_handle_t dst = memh + scr->pcs.dispoffset + dstoff * 2;
> + bus_space_handle_t src = memh + scr->pcs.dispoffset + srcoff * 2;
> + memmove((void* )dst, (void* )src, nrows * ncols * 2);
> +#if 0
> bus_space_copy_region_2(memt, memh,
> scr->pcs.dispoffset + srcoff * 2,
> memh, scr->pcs.dispoffset + dstoff * 2,
> nrows * ncols);
> +#endif
Thanks, I bet bus_space_copy_region_2 is slow under nvmm because it
has to do a VM exit for every pair of bytes copied, and VM exits are
costly:
811 if (x86_bus_space_is_io(t)) {
812 if (addr1 >= addr2) {
813 /* src after dest: copy forward */
814 for (; c != 0; c--, addr1 += 2, addr2 += 2)
815 outw(addr2, inw(addr1));
816 } else {
817 /* dest after src: copy backwards */
818 for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1);
819 c != 0; c--, addr1 -= 2, addr2 -= 2)
820 outw(addr2, inw(addr1));
821 }
https://nxr.netbsd.org/xref/src/sys/arch/x86/x86/bus_space.c?r=1.47#811
I don't think there's any I/O port equivalent of REP MOV, so there
might not be a better way to do this properly (and still support VGA
in I/O space rather than memory-mapped, as well as machines where
access must be 2-bytes-at-a-time) other than a larger temporary
buffer.
Home |
Main Index |
Thread Index |
Old Index