Author: cperciva
Date: Tue Aug  7 08:33:40 2018
New Revision: 337411
URL: https://svnweb.freebsd.org/changeset/base/337411

Log:
  Replace a pair of 8-bit writes to VGA memory with a single 16-bit write.
  
  The VGA "text mode" buffer has a pair of bytes for each character: One
  byte for the character symbol, and an "attribute" byte encoding the
  foreground and background colours.  When updating the screen, we were
  writing these two bytes separately.
  
  On some virtualized systems, every write results in a glyph being redrawn
  into a (graphical) virtual screen; writing these two bytes separately
  results in twice as much work being done to draw characters, whereas if
  we perform a single 16-bit write instead, the character only needs to be
  redrawn once.
  
  On an EC2 c5.4xlarge instance, this change cuts 1.30s from the kernel boot,
  speeding it up from 8.90s to 7.60s.
  
  MFC after:    1 week

Modified:
  head/sys/dev/vt/hw/vga/vt_vga.c

Modified: head/sys/dev/vt/hw/vga/vt_vga.c
==============================================================================
--- head/sys/dev/vt/hw/vga/vt_vga.c     Tue Aug  7 07:12:59 2018        
(r337410)
+++ head/sys/dev/vt/hw/vga/vt_vga.c     Tue Aug  7 08:33:40 2018        
(r337411)
@@ -68,6 +68,8 @@ struct vga_softc {
        bus_space_read_1(sc->vga_fb_tag, sc->vga_fb_handle, ofs)
 #define        MEM_WRITE1(sc, ofs, val) \
        bus_space_write_1(sc->vga_fb_tag, sc->vga_fb_handle, ofs, val)
+#define        MEM_WRITE2(sc, ofs, val) \
+       bus_space_write_2(sc->vga_fb_tag, sc->vga_fb_handle, ofs, val)
 #define        REG_READ1(sc, reg) \
        bus_space_read_1(sc->vga_reg_tag, sc->vga_reg_handle, reg)
 #define        REG_WRITE1(sc, reg, val) \
@@ -894,10 +896,8 @@ vga_bitblt_text_txtmode(struct vt_device *vd, const st
                            cons_to_vga_colors[bg] << 4 |
                            cons_to_vga_colors[fg];
 
-                       MEM_WRITE1(sc, (row * 80 + col) * 2 + 0,
-                           ch);
-                       MEM_WRITE1(sc, (row * 80 + col) * 2 + 1,
-                           attr);
+                       MEM_WRITE2(sc, (row * 80 + col) * 2 + 0,
+                           ch + ((uint16_t)(attr) << 8));
                }
        }
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to