Hatred's Log Place

DON'T PANIC!

Mar 1, 2009 - 12 minute read - Comments - linux

nForce4 (CK804) и NCQ решение проблемы

Включаем

В продолжении ранее поднятой темы

Покумекав по форумам нашел информацию, что на моём чипсете NCQ должен включаться параметром adma=1 модулю sata_nv, в первую очередь смутило то, что спросив modinfo sata_nv, мне было сказано, что опция включена по дефолту. Но мы обычно не верим, и проверяем.

Сделал файлик, /etc/modprobe.d/sata_nv со следующим содержимым: options sata_nv adma=1

перезагрузился (ага… сначала попробывал на рабочей системе сделать rmmod -f sata_nv, попробуйте - понравится :)), смотрю dmesg…. 0/31…. пля…. не включилось. Почему? Подумал, походил, полежал… Гм… а ведь у меня используется initrd, а ведь может такое быть, что модуль там подгружается, а про мои параметры никак не догадывается? Открываю на редактирование файл /etc/mkinitcpio.conf, к переменной FILES добаляю /etc/modprobe.d/sata_nv, у меня получилось такое: FILES=“/etc/modprobe.d/sata_nv”

Перестраиваю initrd: /sbin/mkinitcpio -p kernel26

команда верна для ArchLinux, в другом дистрибутиве может отличаться незначительно.

После отстройки initrd, будет полезно проверить, что нужные файлы там появились: cd /boot gzip -dc kernel26.img | cpio -t | grep sata_nv

у меня дало такой результат: /etc/modprobe.d/sata_nv /lib/modules/2.6.28-ARCH/kernel/drivers/ata/sata_nv.ko

перезагружаемся, и смотрим вывод такой команды: dmesg | grep NCQ

у меня она дала такой результат: ata3.00: 1465149168 sectors, multi 1: LBA48 NCQ (depth 31/32)

всё, завелось! :)

Тестируем

Ну вот, нужно же посмотреть на тесты. Решил прогнать тесты hdparm и bonnie++ на всех планировщиках IO с включенным и выключенным NCQ. Для подспорья написал три скриптика:

  • hdparm_test.sh ```bash #!/bin/bash

dev=/dev/sda

rm -f hdparm.txt
for i in 1 2 3 4 5
do
sync
hdparm -tT $dev >> hdparm.txt
done

  * **bonnie_test.sh**
```bash
#!/bin/bash                                                                                                                                         
                                                                                                                                                    
bonnie++ -d ./ -u root -s 2000 -q -x 5 > bonnie.csv                                                                                                 
bon_csv2html < bonnie.csv > bonnie.html                                                                                                             
bon_csv2txt < bonnie.csv > bonnie.txt
  • start_test.sh ```bash #!/bin/bash

bon=sum_bonnie.txt
hdp=sum_hdparm.txt

rm -f $hdp
rm -f $bon

[ x”dmesg | grep NCQ | grep 0/32” = x”” ] && ncq=“ncq” || ncq=“noncq”

echo “NCQ: $ncq”

for sched in noop cfq anticipatory deadline
do
echo “Test for scheduler: $sched”

echo ${sched} > /sys/block/sda/queue/scheduler                                                                                                  
mkdir ${sched}_${ncq} >/dev/null 2>&1                                                                                                           
cd ${sched}_${ncq}                                                                                                                              
../hdparm_test.sh                                                                                                                               
../bonnie_test.sh                                                                                                                               
cd ..                                                                                                                                           

echo "-----------"   >> $hdp                                                                                                                    
echo ${sched}_${ncq} >> $hdp                                                                                                                    
echo "-----------"   >> $hdp                                                                                                                    
cat ${sched}_${ncq}/hdparm.txt >> $hdp                                                                                                          
echo >> $hdp                                                                                                                                    

echo "-----------"   >> $bon                                                                                                                    
echo ${sched}_${ncq} >> $bon                                                                                                                    
echo "-----------"   >> $bon                                                                                                                    
cat ${sched}_${ncq}/bonnie.txt >> $bon                                                                                                          
echo >> $bon                                                                                                                                    

done

Не забыть сделать эти файлы запускаемыми:
  chmod +x start_test.sh hdparm_test.sh bonnie_test.sh

Тесты запускаются командой ./start_test.sh, она дергает остальное.

Результаты на моём железе такие:

**NCQ выключен**
  * hdparm

noop_noncq

/dev/sda:
Timing cached reads: 1602 MB in 2.00 seconds = 801.56 MB/sec
Timing buffered disk reads: 232 MB in 3.02 seconds = 76.88 MB/sec

/dev/sda:
Timing cached reads: 1606 MB in 2.00 seconds = 803.25 MB/sec
Timing buffered disk reads: 230 MB in 3.01 seconds = 76.44 MB/sec

/dev/sda:
Timing cached reads: 1608 MB in 2.00 seconds = 803.81 MB/sec
Timing buffered disk reads: 228 MB in 3.01 seconds = 75.64 MB/sec

/dev/sda:
Timing cached reads: 1602 MB in 2.00 seconds = 801.55 MB/sec
Timing buffered disk reads: 224 MB in 3.00 seconds = 74.63 MB/sec

/dev/sda:
Timing cached reads: 1618 MB in 2.01 seconds = 803.01 MB/sec
Timing buffered disk reads: 218 MB in 3.01 seconds = 72.31 MB/sec


cfq_noncq

/dev/sda:
Timing cached reads: 1384 MB in 2.00 seconds = 691.84 MB/sec
Timing buffered disk reads: 218 MB in 3.00 seconds = 72.56 MB/sec

/dev/sda:
Timing cached reads: 1458 MB in 2.00 seconds = 729.39 MB/sec
Timing buffered disk reads: 200 MB in 3.02 seconds = 66.20 MB/sec

/dev/sda:
Timing cached reads: 1348 MB in 2.00 seconds = 674.28 MB/sec
Timing buffered disk reads: 224 MB in 3.00 seconds = 74.54 MB/sec

/dev/sda:
Timing cached reads: 1632 MB in 2.00 seconds = 816.43 MB/sec
Timing buffered disk reads: 230 MB in 3.02 seconds = 76.15 MB/sec

/dev/sda:
Timing cached reads: 1548 MB in 2.00 seconds = 774.59 MB/sec
Timing buffered disk reads: 232 MB in 3.02 seconds = 76.81 MB/sec


anticipatory_noncq

/dev/sda:
Timing cached reads: 1368 MB in 2.00 seconds = 683.74 MB/sec
Timing buffered disk reads: 224 MB in 3.02 seconds = 74.12 MB/sec

/dev/sda:
Timing cached reads: 1450 MB in 2.00 seconds = 724.83 MB/sec
Timing buffered disk reads: 184 MB in 3.03 seconds = 60.81 MB/sec

/dev/sda:
Timing cached reads: 1568 MB in 2.00 seconds = 783.85 MB/sec
Timing buffered disk reads: 232 MB in 3.02 seconds = 76.72 MB/sec

/dev/sda:
Timing cached reads: 1612 MB in 2.00 seconds = 805.95 MB/sec
Timing buffered disk reads: 224 MB in 3.02 seconds = 74.21 MB/sec

/dev/sda:
Timing cached reads: 1486 MB in 2.00 seconds = 743.44 MB/sec
Timing buffered disk reads: 212 MB in 3.02 seconds = 70.20 MB/sec


deadline_noncq

/dev/sda:
Timing cached reads: 1644 MB in 2.00 seconds = 822.56 MB/sec
Timing buffered disk reads: 224 MB in 3.05 seconds = 73.37 MB/sec

/dev/sda:
Timing cached reads: 1638 MB in 2.00 seconds = 819.22 MB/sec
Timing buffered disk reads: 232 MB in 3.01 seconds = 77.00 MB/sec

/dev/sda:
Timing cached reads: 1600 MB in 2.00 seconds = 799.98 MB/sec
Timing buffered disk reads: 228 MB in 3.00 seconds = 75.93 MB/sec

/dev/sda:
Timing cached reads: 1622 MB in 2.00 seconds = 811.11 MB/sec
Timing buffered disk reads: 226 MB in 3.01 seconds = 75.07 MB/sec

/dev/sda:
Timing cached reads: 1408 MB in 2.00 seconds = 704.00 MB/sec
Timing buffered disk reads: 202 MB in 3.00 seconds = 67.31 MB/sec

  * bonnie++

noop_noncq

Version 1.03b ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 45499 87 54665 19 27385 5 33288 61 70614 6 191.8 0
gaz.hm 2000M 45874 88 54671 19 27249 5 38750 70 70981 6 194.1 0
gaz.hm 2000M 45551 88 52317 19 25239 5 38610 70 70986 7 198.7 0
gaz.hm 2000M 45572 88 51048 19 24506 5 25502 46 70222 7 198.1 0
gaz.hm 2000M 45252 87 53697 20 26225 5 41717 75 68254 6 195.9 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


cfq_noncq

Version 1.03b ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 47352 89 55923 18 29652 6 45797 86 71825 6 211.0 0
gaz.hm 2000M 47456 89 55034 18 29343 6 44096 83 71698 6 212.7 0
gaz.hm 2000M 46858 88 57128 18 29574 6 44274 83 70485 6 211.3 0
gaz.hm 2000M 47217 89 45011 14 28700 6 44137 83 72244 6 210.8 0
gaz.hm 2000M 45751 86 42176 13 28894 6 38222 72 54850 5 210.8 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


anticipatory_noncq

Version 1.03b ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 46465 89 54986 19 29968 7 43727 80 70364 7 197.9 0
gaz.hm 2000M 47074 89 56252 19 29388 7 41524 76 65507 6 194.9 0
gaz.hm 2000M 44377 85 53607 19 29377 7 41594 77 70254 6 195.0 0
gaz.hm 2000M 46743 89 49154 17 29652 7 42644 78 70767 6 199.3 0
gaz.hm 2000M 46882 89 53358 19 26812 6 43332 80 69654 6 199.0 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


deadline_noncq

Version 1.03b ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 47175 89 57395 17 26149 5 25466 46 65936 5 191.6 0
gaz.hm 2000M 46779 88 56285 17 26605 5 41736 76 68591 6 192.3 0
gaz.hm 2000M 47521 89 55864 18 26369 5 41663 76 70438 6 186.0 0
gaz.hm 2000M 46316 87 47777 15 26262 5 40952 75 70995 6 174.0 0
gaz.hm 2000M 45114 85 47622 15 24073 4 41062 75 70485 6 190.9 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP

**NCQ включен**

  * hdparm

noop_ncq

/dev/sda:
Timing cached reads: 288 MB in 2.01 seconds = 143.35 MB/sec
Timing buffered disk reads: 226 MB in 3.01 seconds = 75.15 MB/sec

/dev/sda:
Timing cached reads: 1484 MB in 2.00 seconds = 741.70 MB/sec
Timing buffered disk reads: 220 MB in 3.02 seconds = 72.89 MB/sec

/dev/sda:
Timing cached reads: 1534 MB in 2.00 seconds = 767.28 MB/sec
Timing buffered disk reads: 174 MB in 3.01 seconds = 57.77 MB/sec

/dev/sda:
Timing cached reads: 1528 MB in 2.00 seconds = 763.82 MB/sec
Timing buffered disk reads: 232 MB in 3.02 seconds = 76.73 MB/sec

/dev/sda:
Timing cached reads: 1518 MB in 2.02 seconds = 750.93 MB/sec
Timing buffered disk reads: 206 MB in 3.01 seconds = 68.38 MB/sec


cfq_ncq

/dev/sda:
Timing cached reads: 1322 MB in 2.00 seconds = 660.90 MB/sec
Timing buffered disk reads: 218 MB in 3.00 seconds = 72.65 MB/sec

/dev/sda:
Timing cached reads: 1468 MB in 2.00 seconds = 733.83 MB/sec
Timing buffered disk reads: 198 MB in 3.00 seconds = 65.96 MB/sec

/dev/sda:
Timing cached reads: 1510 MB in 2.00 seconds = 755.44 MB/sec
Timing buffered disk reads: 220 MB in 3.02 seconds = 72.91 MB/sec

/dev/sda:
Timing cached reads: 1508 MB in 2.00 seconds = 753.78 MB/sec
Timing buffered disk reads: 232 MB in 3.01 seconds = 77.01 MB/sec

/dev/sda:
Timing cached reads: 1478 MB in 2.00 seconds = 738.26 MB/sec
Timing buffered disk reads: 186 MB in 3.02 seconds = 61.50 MB/sec


anticipatory_ncq

/dev/sda:
Timing cached reads: 1528 MB in 2.00 seconds = 763.81 MB/sec
Timing buffered disk reads: 224 MB in 3.02 seconds = 74.24 MB/sec

/dev/sda:
Timing cached reads: 1438 MB in 2.00 seconds = 719.39 MB/sec
Timing buffered disk reads: 212 MB in 3.02 seconds = 70.21 MB/sec

/dev/sda:
Timing cached reads: 1514 MB in 2.00 seconds = 757.00 MB/sec
Timing buffered disk reads: 224 MB in 3.02 seconds = 74.13 MB/sec

/dev/sda:
Timing cached reads: 1482 MB in 2.00 seconds = 740.91 MB/sec
Timing buffered disk reads: 232 MB in 3.01 seconds = 77.14 MB/sec

/dev/sda:
Timing cached reads: 1284 MB in 2.00 seconds = 641.90 MB/sec
Timing buffered disk reads: 228 MB in 3.02 seconds = 75.41 MB/sec


deadline_ncq

/dev/sda:
Timing cached reads: 1432 MB in 2.00 seconds = 715.97 MB/sec
Timing buffered disk reads: 228 MB in 3.01 seconds = 75.66 MB/sec

/dev/sda:
Timing cached reads: 1570 MB in 2.00 seconds = 784.75 MB/sec
Timing buffered disk reads: 228 MB in 3.00 seconds = 75.98 MB/sec

/dev/sda:
Timing cached reads: 1308 MB in 2.00 seconds = 654.31 MB/sec
Timing buffered disk reads: 120 MB in 3.15 seconds = 38.16 MB/sec

/dev/sda:
Timing cached reads: 1542 MB in 2.00 seconds = 771.35 MB/sec
Timing buffered disk reads: 222 MB in 3.00 seconds = 73.95 MB/sec

/dev/sda:
Timing cached reads: 1328 MB in 1.99 seconds = 665.72 MB/sec
Timing buffered disk reads: 20 MB in 3.08 seconds = 6.48 MB/sec

  * bonnie++

noop_ncq

Version 1.03e ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 37518 72 54097 19 27447 5 30303 55 52362 4 164.0 0
gaz.hm 2000M 40180 74 49659 11 22405 4 31407 58 45389 4 156.9 0
gaz.hm 2000M 40613 74 54209 12 19132 3 36567 65 61005 5 144.9 0
gaz.hm 2000M 44069 81 47902 11 20125 3 29454 54 48515 4 142.2 0
gaz.hm 2000M 23720 43 50504 13 17069 3 31430 57 31109 2 146.0 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


cfq_ncq

Version 1.03e ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 42450 78 42854 13 26662 6 39393 73 65793 6 150.9 0
gaz.hm 2000M 42654 77 46031 14 24295 5 39668 75 58370 5 154.5 0
gaz.hm 2000M 41442 78 38572 10 26912 6 36976 69 59910 5 161.3 0
gaz.hm 2000M 44573 81 49651 14 23958 5 29693 55 64527 5 158.1 0
gaz.hm 2000M 43713 80 47279 14 26039 5 37661 69 67724 6 146.5 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


anticipatory_ncq

Version 1.03e ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 40004 74 40790 11 26775 4 34375 63 61752 5 157.4 0
gaz.hm 2000M 45122 80 48317 13 27421 5 37972 67 66430 5 128.6 0
gaz.hm 2000M 43501 79 48437 13 24244 4 36538 65 58879 4 150.7 0
gaz.hm 2000M 38956 70 50263 14 25548 4 40434 71 68409 6 155.9 0
gaz.hm 2000M 43571 78 41474 11 25242 4 33914 62 65156 5 133.1 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP


deadline_ncq

Version 1.03e ——Sequential Output—— –Sequential Input- –Random-
-Per Chr- –Block– -Rewrite- -Per Chr- –Block– –Seeks–
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
gaz.hm 2000M 43518 77 56975 14 21886 3 34833 60 66615 5 159.0 0
gaz.hm 2000M 45614 81 53282 13 19252 3 36180 63 55898 4 149.8 0
gaz.hm 2000M 45471 81 49740 13 23995 4 35857 64 55811 4 160.5 0
gaz.hm 2000M 44620 82 54310 13 22732 4 37973 68 57754 5 148.6 0
gaz.hm 2000M 46165 85 55918 15 19391 3 35256 61 58450 5 154.0 0
——Sequential Create—— ——–Random Create——–
-Create– –Read— -Delete– -Create– –Read— -Delete–
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
```