Skip to content

Instantly share code, notes, and snippets.

@akiradeveloper
Created October 12, 2017 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akiradeveloper/283d0e6d093d7437248de1bfdc110474 to your computer and use it in GitHub Desktop.
Save akiradeveloper/283d0e6d093d7437248de1bfdc110474 to your computer and use it in GitHub Desktop.
ライトブーストのregressionがおかしい
JavaからIOを発行するとRMWしたりバッファリングしたりしてカーネルへのIOが思惑どおりにならないため
ddを使っているがこれが仇となっている可能性がある
// デバイスを作る
$ sudo sh script.sh
[sudo] password for akira:
1+0 records in
1+0 records out
512 bytes copied, 0.00111281 s, 460 kB/s
// ステイタスを整形表示する
// この時点で謎のreadが4KB*259発生している.
// dmsetupがデバイスのチェックのために発行したものと思われる
$ sudo dmsetup status wbdev | wbstatus
cursor pos = 0
# of cache blocks = 5201666
# of segments = 40958
current id = 1
last flushed id = 0
last writeback id = 0
# of dirty cache blocks = 0
# of partial flushes = 0
write? hit? on_buffer? fullsize?
0 0 0 0 0
0 0 0 1 259
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0 "Hercules" 20:04 12-Oct-17
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
// 4KBリードする
$ sudo dd if=/dev/mapper/wbdev of=/tmp/o iflag=direct bs=4k count=1
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.00118255 s, 3.5 MB/s
// 思ったとおり. 259->260で1増えてる
$ sudo dmsetup status wbdev | wbstatus
cursor pos = 0
# of cache blocks = 5201666
# of segments = 40958
current id = 1
last flushed id = 0
last writeback id = 0
# of dirty cache blocks = 0
# of partial flushes = 0
write? hit? on_buffer? fullsize?
0 0 0 0 0
0 0 0 1 260
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
// 4KBライトしてみる
$ sudo dd if=/dev/urandom of=/dev/mapper/wbdev oflag=direct bs=4k count=1
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.000637861 s, 6.4 MB/s
// write(1,0,0,1)が1つは思惑どおり
// しかしなぜかreadが出まくってる(260->518)
// (0,1,1,1)のreadが出てるのは, writeしたやつにヒットしたから?
$ sudo dmsetup status wbdev | wbstatus
cursor pos = 128
# of cache blocks = 5201666
# of segments = 40958
current id = 2
last flushed id = 1
last writeback id = 1
# of dirty cache blocks = 1
# of partial flushes = 0
write? hit? on_buffer? fullsize?
0 0 0 0 0
0 0 0 1 518
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment