ラベル virtio の投稿を表示しています。 すべての投稿を表示
ラベル virtio の投稿を表示しています。 すべての投稿を表示

2013年1月14日月曜日

DragonflyBSDでvirtioを利用する

DragonflyBSDのGENERICにvirtioが入ったと聞いて早速ビルドして試してみたのだが、 残念ながらネットワークのvirtioサポートはまだらしい(そもそもソースがツ リーに含まれていない感じ)。 virtio_blk.koは存在して利用できるようなので、とりあえず書き込み性能だ け簡単に比較してみた。

ホスト

  • Linux hachune.local 3.6.11-1-ARCH #1 SMP PREEMPT Tue Dec 18 08:57:15 CET 2012 x86_64 GNU/Linux
  • QEMU emulator version 1.2.1, Copyright (c) 2003-2008 Fabrice Bellard

Virtioあり

QEMUの構成

qemu-system-x86_64 -enable-kvm -smp 2 -m 2048 \
  -drive file=/dev/vg0/Dragonfly,if=virtio \
  -net nic,model=virtio,macaddr=52:54:00:43:23:11 \
  -net tap,ifname=tap0,script=/home/miku/kvm/ifup_br0.sh \
  -serial pty \
  -cdrom /home/miku/Image/dfly-x86_64-3.3-current.iso -boot d

HAMMER

29895208.6 bytes/sec

# newfs_hammer -L TEST /dev/vbd0s1b
Volume 0 DEVICE /dev/vbd0s1b    size  11.25GB
initialize freemap volume 0
initializing the undo map (504 MB)
---------------------------------------------
1 volume total size  11.25GB version 6
boot-area-size:       32.00MB
memory-log-size:      32.00MB
undo-buffer-size:    504.00MB
total-pre-allocated:   0.51GB
fsid:                95359a72-5dc9-11e2-a6d0-e915af5f7f28

NOTE: Please remember that you may have to manually set up a
cron(8) job to prune and reblock the filesystem regularly.
By default, the system automatically runs 'hammer cleanup'
on a nightly basis.  The periodic.conf(5) variable
'daily_clean_hammer_enable' can be unset to disable this.
Also see 'man hammer' and 'man HAMMER' for more information.

WARNING: HAMMER filesystems less than 50GB are not recommended!
You may have to run 'hammer prune-everything' and 'hammer reblock'
quite often, even if using a nohistory mount.
# mount_hammer /dev/vbd0s1b /mnt
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 37.101394 secs (28262442 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 32.183600 secs (32581066 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 38.717169 secs (27082972 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 34.504874 secs (30389214 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 33.650971 secs (31160349 bytes/sec)

UFS

51055029.6 bytes/sec

# newfs /dev/vbd0s1b
/dev/vbd0s1b: media size 11515.96MB
Warning: Block size and bytes per inode restrict cylinders per group to 89.
Warning: 80 sector(s) in last cylinder unallocated
/dev/vbd0s1b:   23584688 sectors in 5758 cylinders of 1 tracks, 4096 sectors
        11516.0MB in 65 cyl groups (89 c/g, 178.00MB/g, 22400 i/g)
super-block backups (for fsck -b #) at:
 32, 364576, 729120, 1093664, 1458208, 1822752, 2187296, 2551840, 2916384,
 3280928, 3645472, 4010016, 4374560, 4739104, 5103648, 5468192, 5832736,
 6197280, 6561824, 6926368, 7290912, 7655456, 8020000, 8384544, 8749088,
 9113632, 9478176, 9842720, 10207264, 10571808, 10936352, 11300896, 11665440,
 12029984, 12394528, 12759072, 13123616, 13488160, 13852704, 14217248,
 14581792, 14946336, 15310880, 15675424, 16039968, 16404512, 16769056,
 17133600, 17498144, 17862688, 18227232, 18591776, 18956320, 19320864,
 19685408, 20049952, 20414496, 20779040, 21143584, 21508128, 21872672,
 22237216, 22601760, 22966304, 23330848
# mount_ufs /dev/vbd0s1b /mnt
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 19.852371 secs (52818678 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 19.631861 secs (53411951 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 21.491887 secs (48789388 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 22.926797 secs (45735826 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 19.233114 secs (54519305 bytes/sec)

Virtioなし

QEMUの構成

qemu-system-x86_64 -enable-kvm -smp 2 -m 2048 \
  -hda /dev/vg0/Dragonfly \
  -net nic,model=e1000,macaddr=52:54:00:43:23:11 \
  -net tap,ifname=tap0,script=/home/miku/kvm/ifup_br0.sh \
  -serial pty \
  -cdrom /home/miku/Image/dfly-x86_64-3.3-current.iso -boot d

HAMMER

17620950.4 bytes/sec

# newfs_hammer -L TEST /dev/ad1s1b
Volume 0 DEVICE /dev/ad1s1b     size  11.25GB
initialize freemap volume 0
initializing the undo map (504 MB)
---------------------------------------------
1 volume total size  11.25GB version 6
boot-area-size:       32.00MB
memory-log-size:      32.00MB
undo-buffer-size:    504.00MB
total-pre-allocated:   0.51GB
fsid:                ff28dca3-5dcb-11e2-b2ce-535400432311

NOTE: Please remember that you may have to manually set up a
cron(8) job to prune and reblock the filesystem regularly.
By default, the system automatically runs 'hammer cleanup'
on a nightly basis.  The periodic.conf(5) variable
'daily_clean_hammer_enable' can be unset to disable this.
Also see 'man hammer' and 'man HAMMER' for more information.

WARNING: HAMMER filesystems less than 50GB are not recommended!
You may have to run 'hammer prune-everything' and 'hammer reblock'
quite often, even if using a nohistory mount.
# mount_hammer /dev/ad1s1b /mnt
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 59.103703 secs (17741291 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 57.336238 secs (18288190 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 57.117314 secs (18358286 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 62.101431 secs (16884893 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 62.296237 secs (16832092 bytes/sec)

UFS

28662327.0 bytes/sec

# newfs /dev/ad1s1b
/dev/ad1s1b: media size 11515.96MB
Warning: Block size and bytes per inode restrict cylinders per group to 89.
Warning: 80 sector(s) in last cylinder unallocated
/dev/ad1s1b:    23584688 sectors in 5758 cylinders of 1 tracks, 4096 sectors
        11516.0MB in 65 cyl groups (89 c/g, 178.00MB/g, 22400 i/g)
super-block backups (for fsck -b #) at:
 32, 364576, 729120, 1093664, 1458208, 1822752, 2187296, 2551840, 2916384,
 3280928, 3645472, 4010016, 4374560, 4739104, 5103648, 5468192, 5832736,
 6197280, 6561824, 6926368, 7290912, 7655456, 8020000, 8384544, 8749088,
 9113632, 9478176, 9842720, 10207264, 10571808, 10936352, 11300896, 11665440,
 12029984, 12394528, 12759072, 13123616, 13488160, 13852704, 14217248,
 14581792, 14946336, 15310880, 15675424, 16039968, 16404512, 16769056,
 17133600, 17498144, 17862688, 18227232, 18591776, 18956320, 19320864,
 19685408, 20049952, 20414496, 20779040, 21143584, 21508128, 21872672,
 22237216, 22601760, 22966304, 23330848
# mount_ufs /dev/ad1s1b /mnt
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 37.872868 secs (27686733 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 38.206654 secs (27444853 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 32.039132 secs (32727978 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 40.281541 secs (26031179 bytes/sec)
# dd if=/dev/zero of=/mnt/test.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes transferred in 35.640524 secs (29420892 bytes/sec)

結果

virtioを利用した場合のほうが書き込み性能は2倍近く高くなることが分かっ た。読み込みは測るのをうっかり忘れてて途中で気が付いた。

HAMMER(virtio)HAMMERUFS(virtio)UFS
128262442177412915281867827686733
232581066182881905341195127444853
327082972183582864878938832727978
430389214168848934573582626031179
531160349168320925451930529420892
平均29895209176209505105503028662327

おまけのdmesg

# dmesg
Copyright (c) 2003-2013 The DragonFly Project.
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
DragonFly v3.3.0.942.gfa75bf-DEVELOPMENT #0: Mon Jan 14 04:04:37 JST 2013
    root@vy1.hachune.local:/usr/obj/usr/src/sys/X86_64_GENERIC
TSC clock: 1646507109 Hz, i8254 clock: 1193192 Hz
CPU: QEMU Virtual CPU version 1.2.1 (1646.52-MHz K8-class CPU)
  Origin = "AuthenticAMD"  Id = 0x623  Stepping = 3
  Features=0x783fbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
  Features2=0x80802001<SSE3,CX16,POPCNT,VMM>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x65<LAHF,SVM,ABM,SSE4A>
real memory  = 2147081216 (2047 MB)
avail memory = 1964879872 (1873 MB)
lapic: divisor index 0, frequency 500010320 Hz
Initialize MI interrupts
FQ scheduler policy version 1.1 loaded
wdog: In-kernel automatic watchdog reset enabled
kbd1 at kbdmux0
disk scheduler: set policy of md0 to noop
md0: Malloc disk
ACPI: RSDP 0xfd950 00014 (v00 BOCHS )
ACPI: RSDT 0x7fffe3d0 00038 (v01 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
ACPI: FACP 0x7fffff80 00074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
ACPI: DSDT 0x7fffe410 0124A (v01   BXPC   BXDSDT 00000001 INTL 20121018)
ACPI: FACS 0x7fffff40 00040
ACPI: SSDT 0x7ffffe30 00110 (v01 BOCHS  BXPCSSDT 00000001 BXPC 00000001)
ACPI: APIC 0x7ffffd10 00080 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
ACPI: HPET 0x7ffffcd0 00038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)
ACPI: SSDT 0x7ffff660 0066E (v01   BXPC BXSSDTPC 00000001 INTL 20121018)
cryptosoft0: <software crypto> on motherboard
acpi0: <BOCHS BXPCRSDT> on motherboard
ACPI FADT: SCI testing interrupt mode ...
ACPI FADT: SCI select level/low
objcache_reclaimlist
objcache_reclaimlist
objcache_reclaimlist
objcache_reclaimlist
acpi0: Power Button (fixed)
Warning: ACPI is disabling APM's device.  You can't run both
acpi_timer0: <24-bit timer at 3.579545MHz> port 0xb008-0xb00b on acpi0
acpi_hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
acpi_hpet0: frequency 100000000
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pci_link4: Unable to route IRQs: AE_NOT_FOUND
isab0: <PCI-ISA bridge> at device 1.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel PIIX3 WDMA2 controller> port 0xc060-0xc06f,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 1.1 on pci0
ata0: <ATA channel 0> on atapci0
ata1: <ATA channel 1> on atapci0
disk scheduler: set policy of acd0 to noop
acd0: DVDROM <QEMU DVD-ROM/1.2.1> at ata1-master WDMA2
pci0: <bridge> (vendor 0x8086, dev 0x7113) at device 1.3 irq 9
vgapci0: <VGA-compatible display> mem 0xfebf0000-0xfebf0fff,0xfc000000-0xfdffffff at device 2.0 on pci0
virtio_pci0: <VirtIO PCI Network adapter> port 0xc040-0xc05f mem 0xfebf1000-0xfebf1fff irq 11 at device 3.0 on pci0
virtio_pci1: <VirtIO PCI Block adapter> port 0xc000-0xc03f mem 0xfebf2000-0xfebf2fff irq 11 at device 4.0 on pci0
virtio_pci1: host features: 0x710006d4 <EventIdx,0x10000000,NotifyOnEmpty,Topology,FlushCmd,SCSICmds,BlockSize,DiskGeometry,MaxNumSegs>
virtio_pci1: negotiated features: 0x254 <FlushCmd,BlockSize,DiskGeometry,MaxNumSegs>
disk scheduler: set policy of vbd0 to noop
atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model IntelliMouse Explorer, device ID 4
cpu0: <ACPI CPU> on acpi0
cpu_cst0: <ACPI CPU C-State> on cpu0
cpu1: <ACPI CPU> on acpi0
cpu_cst1: <ACPI CPU C-State> on cpu1
orm0: <Option ROM> at iomem 0xed000-0xeffff on isa0
pmtimer0 on isa0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1: can't drain, serial port might not exist, disabling
ppc0: cannot reserve I/O port range
hpt27xx: no controller detected.
CAM: Configuring 2 busses
CAM: finished configuring all busses
disk scheduler: set policy of cd0 to noop
no B_DEVMAGIC (bootdev=0)
Device Mapper version 4.16.0 loaded
dm_target_error: Successfully initialized
dm_target_zero: Successfully initialized
cd0 at ata1 bus 0 target 0 lun 0
cd0: <QEMU QEMU DVD-ROM 1.2.> Removable CD-ROM SCSI-0 device
cd0: 16.000MB/s transfers
cd0: cd present [347187 x 2048 byte records]
Mounting root from cd9660:cd0
DMA space used: 152k, remaining available: 16384k
Mounting devfs

2012年10月9日火曜日

お名前.comのVPS(メモリ4GBプラン)にFreeBSD(virtio)を導入

お名前.comのVPS(メモリ4GBプラン)をmikutterユーザ会として1年間無償で借りることができたので、 早速いろいろ試してみた。

今回はVPS上で「コミュニティーでいろいろ共用できるサーバ」にするので、コンテナ型の仮想化が一番 よさそうと考え、とりあえずFreeBSDを導入することにした。ただ、 FreeBSD9.1-RC1の時点ではまだvirtioが利用できないため、 virtioがbaseのGENERICに入った9-STABLEをビルドし導入する。

今回テストしたバージョンは以下の通り。
FreeBSD 9.1-PRERELEASE #0 r241139: Wed Oct 3 04:26:52 JST 2012

CentOS 6.2(linux-2.6.32, virtio)
dd if=/dev/zero of=test.img bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 3.63471 s, 288 MB/s 
FreeBSD 9-stable(not virtio)
% dd if=/dev/zero of=test.img bs=1M count=1000
1048576000 bytes transferred in 7.655223 secs (136975241 bytes/sec)
FreeBSD 9-stable(virtio)
% dd if=/dev/zero of=test.img bs=1M count=1000
1048576000 bytes transferred in 3.158812 secs (331952641 bytes/sec)

ホストは共用なので細かい速度はあてにならないかもしれないが、 virtioを有効にしたFreeBSDはそれなりに速度が出ている模様。やはりvirtio無しは遅い。 CentOSは何度か試したところ、試したタイミングが悪かった可能性があるのでなんとも言えないものの、 速度にFreeBSDより大きなばらつきがあった。

試しに安鯖で有名なML110G7でも同様の処理をしてみた。

FreeBSD 9-stable(ML110G7)
% dd if=/dev/zero of=test.img bs=1M count=1000
 1048576000 bytes transferred in 11.833178 secs (88613221 bytes/sec)

VPSのほうがDisk I/Oは圧倒的に速いようだ。かなしい。

dmesgは以下の通り。

Copyright (c) 1992-2012 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.1-PRERELEASE #0 r241139: Wed Oct  3 04:26:52 JST 2012
    root@vps.m.hachune.net:/usr/obj/usr/src/sys/GENERIC amd64
CPU: Intel(R) Core(TM)2 Duo CPU     T7700  @ 2.40GHz (2533.48-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x6fb  Family = 0x6  Model = 0xf  Stepping = 11
  Features=0xf8bf3ff
  Features2=0x80002201
  AMD Features=0x20100800
  AMD Features2=0x1
  TSC: P-state invariant
real memory  = 4294967296 (4096 MB)
avail memory = 4101722112 (3911 MB)
Event timer "LAPIC" quality 400
ACPI APIC Table: 
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 4 package(s) x 1 core(s)
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  2
 cpu3 (AP): APIC ID:  3
ioapic0: Changing APIC ID to 4
ioapic0  irqs 0-23 on motherboard
kbd1 at kbdmux0
acpi0:  on motherboard
acpi0: Power Button (fixed)
cpu0:  on acpi0
cpu1:  on acpi0
cpu2:  on acpi0
cpu3:  on acpi0
atrtc0:  port 0x70-0x71,0x72-0x77 irq 8 on acpi0
Event timer "RTC" frequency 32768 Hz quality 0
hpet0:  iomem 0xfed00000-0xfed003ff on acpi0                                     [46/403]
Timecounter "HPET" frequency 100000000 Hz quality 950
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <24-bit timer at 3.579545MHz> port 0xb008-0xb00b on acpi0
pcib0:  port 0xcf8-0xcff on acpi0
pci0:  on pcib0
pci_link4: Unable to route IRQs: AE_NOT_FOUND
isab0:  at device 1.0 on pci0
isa0:  on isab0
atapci0:  port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xc000-0xc00f at device 1.1 on pci0
ata0:  at channel 0 on atapci0
ata1:  at channel 1 on atapci0
uhci0:  port 0xc020-0xc03f irq 11 at device 1.2 on pci0
usbus0: controller did not stop
usbus0 on uhci0
pci0:  at device 1.3 (no driver attached)
vgapci0:  mem 0xf0000000-0xf1ffffff,0xf2000000-0xf2000fff at device 2.0 on pci0
virtio_pci0:  port 0xc040-0xc05f mem 0xf2020000-0xf2020fff irq 11 at device 3.0 on pci0
vtnet0:  on virtio_pci0
virtio_pci0: host features: 0x711fffe3 
virtio_pci0: negotiated features: 0x110fbba3 
vtnet0: Ethernet address: 02:16:3e:68:9f:e5
virtio_pci1:  port 0xc080-0xc0bf mem 0xf2040000-0xf2040fff irq 11 at device 4.0 on pci0
vtblk0:  on virtio_pci1
virtio_pci1: host features: 0x710006d4 
virtio_pci1: negotiated features: 0x10000254 
vtblk0: 81920MB (167772160 512 byte sectors)
virtio_pci2:  port 0xc0c0-0xc0ff mem 0xf2041000-0xf2041fff irq 10 at device 5.0 on pci0
vtblk1:  on virtio_pci2
virtio_pci2: host features: 0x710006d4 
virtio_pci2: negotiated features: 0x10000254 
vtblk1: 327680MB (671088640 512 byte sectors)
virtio_pci3:  port 0xc100-0xc11f irq 10 at device 6.0 on pci0
vtballoon0:  on virtio_pci3
virtio_pci3: host features: 0x71000002 
virtio_pci3: negotiated features: 0x0                                                                         [7/403]
atkbdc0:  port 0x60,0x64 irq 1 on acpi0
atkbd0:  irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
psm0:  irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model IntelliMouse Explorer, device ID 4
fdc0:  port 0x3f2-0x3f5,0x3f7 irq 6 drq 2 on acpi0
fdc0: does not respond
device_attach: fdc0 attach returned 6
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (9600,n,8,1)
orm0:  at iomem 0xc9000-0xc97ff on isa0
sc0:  at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x100>
vga0:  at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
attimer0:  at port 0x40 on isa0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
fdc0: No FDOUT register!
ppc0: cannot reserve I/O port range
ctl: CAM Target Layer loaded
Timecounters tick every 1.000 msec
usbus0: 12Mbps Full Speed USB v1.0
ugen0.1:  at usbus0
uhub0:  on usbus0
GEOM: vtbd1: corrupt or invalid GPT detected.
GEOM: vtbd1: GPT rejected -- may not be recoverable.
uhub0: 2 ports with 2 removable, self powered
ugen0.2:  at usbus0
uhid0:  on usbus0
cd0 at ata0 bus 0 scbus0 target 0 lun 0
cd0:  Removable CD-ROM SCSI-0 device 
cd0: 16.700MB/s transfers (WDMA2, ATAPI 12bytes, PIO 65534bytes)
cd0: Attempt to query device size failed: NOT READY, Medium not present
SMP: AP CPU #1 Launched!
SMP: AP CPU #3 Launched!
SMP: AP CPU #2 Launched!
Timecounter "TSC-low" frequency 9896395 Hz quality 1000
Trying to mount root from ufs:/dev/vtbd0p3 [rw]...

試しにメモリ1GBプラン(60日体験版)も試してみたところ、CentOS6.2(linux-2.6.32, virtio有効)で だいたい100〜130MB/sだった。どうやら容量だけでなく速度の面でも4GBプランはメリットがある模様。

余談

いつものようにファイアウォールはpfでいこうとしたところ、pfctl -eした瞬間 何故かダウンロードのみ激遅(10KB/sぐらい)になったりと散々だったので、ipfwを覚えることに。 VIMAGEもいろいろと不具合があってハマりまくったので今回は見送り。

2012年10月8日月曜日

OpenBSDでvirtioを利用する

OpenBSDにvirtioが入ったようなので、早速使ってみる。
今のところ5.2には無く-currentにのみ入っているようなので、素直に-currentをビルド。 -currentならGENERICにvirtioが入っているので、特別な設定は要らない。 ビルド手順については、 公式のドキュメント通りに行った。

…がしかし、 sys/arch/amd64/amd64/cpu.cのコンパイルが失敗する。

{standard input}: Assembler messages: 
{standard input}:198: Error: no such instruction: `rdrand %rbx'
*** Error code 1

どうやらインラインアセンブラでこけているようだが、rdrandなんて見たこと無いのでググってみた。
http://en.wikipedia.org/wiki/RdRand
どうやら、インなんとかさんのIvy Bridgeで追加された乱数生成命令らしい。 そんなものうちのAMD E-450には無いので、rdrand()の中を全部さくっとコメントアウト。 ついでにrdrandでgrepして引っかかったidentcpu.cのhas_rdrand = 1をhas_rdrand = 0に変更。
rdrand()自体がr1.51で最近追加されたばかりの関数のようなので、 たぶんこれで大丈夫じゃないかなーと思いビルドしなおしたらあっさり通った。 そしてユーザランドも問題なくコンパイルできた。
dmesgは以下の通り。

OpenBSD 5.2-current (HACHUNE.MP) #0: Mon Oct  8 17:23:02 JST 2012
    root@obsd.k.hachune.net:/usr/src/sys/arch/amd64/compile/HACHUNE.MP
real mem = 1072685056 (1022MB)
avail mem = 1024802816 (977MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xfd980 (11 entries)
bios0: vendor Bochs version "Bochs" date 01/01/2007
bios0: Bochs Bochs
acpi0 at bios0: rev 0
acpi0: sleep states S3 S4 S5
acpi0: tables DSDT FACP SSDT APIC HPET SSDT
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
acpihpet0 at acpi0: 100000000 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
mpbios0 at bios0: Intel MP Specification 1.4
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: QEMU Virtual CPU version 1.2.0, 1646.91 MHz
cpu0: FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,CX16,POPCNT,NXE,LONG,LAHF,SVM,ABM,SSE4A
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache
cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: apic clock running at 1009MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: QEMU Virtual CPU version 1.2.0, 1663.20 MHz
cpu1: FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,CX16,POPCNT,NXE,LONG,LAHF,SVM,ABM,SSE4A
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache
cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
mpbios0: bus 0 is type PCI   
mpbios0: bus 1 is type ISA   
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 11, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
pciide0: channel 0 disabled (no drives)
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0:  ATAPI 5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, DMA mode 2
piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: apic 2 int 9
iic0 at piixpm0
iic0: addr 0x4c 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
iic0: addr 0x4e 48=00 words 00=0000 01=0000 02=0000 03=0000 04=0000 05=0000 06=0000 07=0000
vga1 at pci0 dev 2 function 0 "Cirrus Logic CL-GD5446" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
virtio0 at pci0 dev 3 function 0 "Qumranet Virtio Network" rev 0x00: Virtio Network Device
vio0 at virtio0: address 52:54:00:12:34:56
virtio0: apic 2 int 11
virtio1 at pci0 dev 4 function 0 "Qumranet Virtio Storage" rev 0x00: Virtio Block Device
vioblk0 at virtio1
scsibus1 at vioblk0: 2 targets
sd0 at scsibus1 targ 0 lun 0:  SCSI3 0/direct fixed
sd0: 5000MB, 512 bytes/sector, 10240000 sectors
virtio1: apic 2 int 11
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
fd1 at fdc0 drive 1: density unknown
nvram: invalid checksum
mtrr: Pentium Pro MTRR support
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (cf20ab2e3b470529.a) swap on sd0b dump on sd0b
clock: unknown CMOS layout

肝心のディスク読み書き速度は以下の通り。

  • virtioなし: read 29767487 bytes/sec, write 21957414 bytes/sec
  • virtioあり: read 53455607 bytes/sec, write 46648054 bytes/sec

virtioを有効にするとだいたい2倍ぐらい速くなるようだ。 これでOpenBSDのBHyVe上への導入も捗る…?

追記: 先にユーザランド更新しとけばrdrandで文句言われなくなるんじゃね?と教えていただいたので、やりなおしてみます。
-> 無事できましたヾ(@⌒ー⌒@)ノ