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



The following reply was made to PR port-amd64/59361; it has been noted by GNATS.

From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: RVP <rvp%SDF.ORG@localhost>
Cc: gnats-bugs%NetBSD.org@localhost, netbsd-bugs%NetBSD.org@localhost
Subject: Re: port-amd64/59361: paging up in less(1) under qemu vga console
	is slow
Date: Sun, 26 Oct 2025 23:55:09 +0000

 > Date: Sun, 26 Oct 2025 22:35:24 +0000 (UTC)
 > From: RVP <rvp%SDF.ORG@localhost>
 >=20
 > Scrolling up (erasure of 1st line, followed by moving the rest of the lin=
 es up)
 > seems to do a backwards copy. Use plain memmove(3) instead:
 > =20
 > @@ -1168,10 +1168,15 @@
 >   				    scr->pcs.cursorrow, scr->pcs.cursorcol);
 >   #endif
 >   		} else {
 > +			bus_space_handle_t dst =3D memh + scr->pcs.dispoffset + dstoff * 2;
 > +			bus_space_handle_t src =3D 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 >=3D addr2) {
     813 			/* src after dest: copy forward */
     814 			for (; c !=3D 0; c--, addr1 +=3D 2, addr2 +=3D 2)
     815 				outw(addr2, inw(addr1));
     816 		} else {
     817 			/* dest after src: copy backwards */
     818 			for (addr1 +=3D 2 * (c - 1), addr2 +=3D 2 * (c - 1);
     819 			    c !=3D 0; c--, addr1 -=3D 2, addr2 -=3D 2)
     820 				outw(addr2, inw(addr1));
     821 		}
 
 https://nxr.netbsd.org/xref/src/sys/arch/x86/x86/bus_space.c?r=3D1.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