Turning On NCQ Queing On ICH7 Chipsets With Linux

Posted by Alexey Kovyrin under Admin-tips · русский

Recently we’ve got critical load on one of our new free web hosting servers that handles millions of hits per day. When I’ve tried to analyze how to get more performance from that servers, I noted that these servers has ICH7 chipsets and Seagate SATA drives with NCQ support… But in closer view I noticed, that NCQ support is not enabled on our servers with ata_piix IDE driver. So, I decided that it would be great to enable NCQ and take a look what will happen with performance (it was obvious, that performance should increase)…

Fast research showed, that first thing I need is to enable AHCI-compatibility more in server’s BIOS to be able to use ahci SATA driver from latest version of Linux 2.6 kernel. After AHCI has been enabled, I saw following info in dmesg log:

ahci 0000:00:1f.2: AHCI 0001.0100 32 slots 4 ports 3 Gbps 0xf impl SATA mode
ahci 0000:00:1f.2: flags: 64bit ncq pm led clo pio slum part
ata1: SATA max UDMA/133 cmd 0xFFFFC20000022500 ctl 0x0 bmdma 0x0 irq 66
ata2: SATA max UDMA/133 cmd 0xFFFFC20000022580 ctl 0x0 bmdma 0x0 irq 66
ata3: SATA max UDMA/133 cmd 0xFFFFC20000022600 ctl 0x0 bmdma 0x0 irq 66
ata4: SATA max UDMA/133 cmd 0xFFFFC20000022680 ctl 0x0 bmdma 0x0 irq 66
scsi0 : ahci
ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata1.00: ATA-7, max UDMA/133, 586072368 sectors: LBA48
ata1.00: ata1: dev 0 multi count 16
ata1.00: configured for UDMA/133
scsi1 : ahci
......
  Vendor: ATA       Model: ST3300622AS       Rev: 3.AA
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: ATA       Model: ST3300622AS       Rev: 3.AA
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: ATA       Model: ST3300622AS       Rev: 3.AA
  Type:   Direct-Access                      ANSI SCSI revision: 05
  Vendor: ATA       Model: ST3300622AS       Rev: 3.AA
  Type:   Direct-Access                      ANSI SCSI revision: 05
......

As you can see, there is no NCQ support for SATA drives… But official libata site said, that it should be there!

More deep research showed, that libata in linux 2.6 kernel has no NCQ support for AHCI. :-( So, I decided to find out how to get more recent libata in linux 2.6…Unfortunately, official libata site has only outdated patches for linux 2.6. And after long search I found site with libata patches for latest 2.6 kernels that brings latest libata library and allows me to enable NCQ on my drives! This site is home page of Tejun Heo – Korean kernel hacker, that maintains libata-tj-stable patch set.

After applying these patches and rebooting I’ve got following messages for sata channels:

...
ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata1.00: ATA-7, max UDMA/133, 586072368 sectors: LBA48 NCQ (depth 31/32)
ata1.00: ata1: dev 0 multi count 16
ata1.00: configured for UDMA/133
...

So, now I have NCQ enabled on my drives and it gabe me some 15-30% of additional performance (I see it from traffic graphs, so I don’t need any deep performance test – it’s obvious) and if you have ICH controller and want to get NCQ queing enabled on your drives, try these patches – they are really stable.


Related posts:

  1. Unofficial Debian GNU/Linux Repositories Overview
  2. Tuning and Optimizing Red Hat Enterprise Linux for Oracle 9i and 10g Databases
  3. How to create IP-IP tunnel between FreeBSD and Linux
  4. 5 Minutes Guide To Linux Traffic Shaping
  5. Let’s help girl-administrator to win trip to Bali

9 Responses to this entry

_Andrey_ says:

Подскажите, что может быть в моем случае – 2.6.17 с патчами от gentoo (патчи на drm i810 и i830).
При работе с диском жудкие тормоза в системе. А уж если в своп полезем, то ждать реакции системы на пользовательский запрос придется долго.
Файл размером 600-700Мб на ext3 удаляется секунд 5-10. На ReiserFS ситуация не лучше.
Мамка интеловская на i915, диск samsung s-ata.
Пропускная по hdparam на уровне s-ata2.
Но при интенсивной работе приложения с диском вся система в глубоком ступоре.
Что это может быть?

_Andrey_ says:

Пставил ядро 2.6.16-rc3-git7. Появилась запись в логе LBA48 NCQ (depth 0/32).
Что означает запись “(depth 0/32)”, и почему у меня “0″, а не “31″?
Но при копировании файла внутри одного раздела (из каталога в каталог) процессор загружается на 100%

Scoundrel says:

SATA Native Command Queueing support

This is automatically enabled if both the controller and device
support NCQ. libata supports maximum of 31 concurrent commands. If
NCQ is enabled you should be able to see a message like the following
during device initialization.

ata1.00: ATA-7, max UDMA7, 312581808 sectors: LBA48 NCQ (depth 31/32)

If the device supports NCQ but the host doesn’t, you’ll get

ata8.00: ATA-7, max UDMA7, 312581808 sectors: LBA48 NCQ (depth 0/32)

Queue depth can be adjusted by

# echo 16 > /sys/class/scsi_device/0:0:0:0/device/queue_depth

But, there aren’t many good reasons to mess with queue depth.

Anatoly says:

а сами графики производительности где?

Scoundrel says:

Графиков нету. Единственными графиками для меня являются данные MRTG, который показывал умирающую тачку при определенной нагрузке, а теперь даже при нагрузке на 50% больше ему значительно легче :-)

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

infotage.net » Blog Archive » No NCQ on older nvidia chipsets says:

[...] On the Intel side a techreport review lists the Intel ICH7R and ICH8R as the only chipsets with ahci support and that none of the nVidia chipsets (5xx and 6xx series) do so.  Though other reports have listed the 570 as having ahci.  Intel’s ICH8, ICH7, ICH6, ICH5, ICH5R all do not support AHCI but the ICH7DH does according to Intel relayed on the linux-ide mailing list (which also links to a blog post about getting NCQ to work in linux) The ATI SB600 supports AHCI. [...]