# Slow hd (sata) transfer rates, dma enabled..

## cv01302

Ok, I have been using gentoo for quite some months now, but whatever I have done (a lot of research on forums, properly configuring everything), it seems that my transfer rate (either to same partition, or another partition, or even disk) sucks.

```

hdparm -tT /dev/sda

/dev/sda:

 Timing cached reads:   3784 MB in  2.00 seconds = 1890.40 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

 Timing buffered disk reads:  164 MB in  3.01 seconds =  54.49 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

```

```

hdparm -tT /dev/sdb

/dev/sdb:

 Timing cached reads:   3748 MB in  2.00 seconds = 1874.28 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

 Timing buffered disk reads:  176 MB in  3.02 seconds =  58.25 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

```

As you can see, the disk reads are high (dma enabled) + in bios, DMA *is* enabled (windowz can verify it, because I used to have the disk for storage puproses in windowz, and the disk was **really** flying). So the logical thing is that the disks would be really fast.

The problem:

Whenever I want to copy e.g. a divx file from a folder to another folder (same partition), the copy starts by a high number of transfer (30 MB/s, but should be more), then *instantly* drops to around 5 MB/s. Just did a copy (divx 350MB file, timed it with clock, it was done with an average 5 MB/s).

CPU utilization is very low, so there is not a problem in cpu (or something).

Whenever I burn a cd/dvd in k3b, I can't do ANYTHING else (except surfing), due to hd "lag" (don't know how to express it), yet CPU utilization very low, but in windowz, I can burn AND play a game in background (e.g. World of Warcraft, full screen, full graphics etc etc), and no hd "lag".

Configuration in kernel is proper, and I have tried with different versions of gentoo-(dev)-sources from 2.6.X up to the latest stable.

Compiled into kernel:

```

generic/default IDE chipset support

PCI IDE chipset support

Generic PCI IDE Chipset Support

Generic PCI bus-master DMA support

Use PCI DMA by default when available

and ofc, Intel PIIXn chipsets support

More, legacy /proc/scsi/ support

SCSI disk support

SCSI generic support

iSCSI Transport Attributes

Serial ATA (SATA) support

and ofc, Intel PIIX/ICH SATA support

```

I have asus p4p800 deluxe with 2.4GHz Northwood. I have tried many diffent config combos, but no veil. I even bought a second sata disk (/dev/sdb), WD 80GB, to see if there was something wrong (blacklisted perhaps?) with seagate 7200.7 120GB (dev/sda).

I even did a fresh stage1 install two days ago, with reiserfs, again no veil...

Now I am using everywhere reiserfs (as the difference in huge amount of small files is obvious), but the problem still exists (same as ext3).

In my /etc/fstab , I use dump/pass  0 1 (if there is something important to this).

As you can see, this is most irritating, having a whole linux ownage system (gentoo rulez!), but the disk speed holding you back.. and believe me, this is quite a good reason to revert back to **blah blah** winblows...

HELP!  :Sad: 

----------

## NeddySeagoon

cv01302,

Check your kernel preemption settings with 

```
$ grep EMPT /usr/src/linux/.config

CONFIG_PREEMPT=y

CONFIG_PREEMPT_BKL=y

# CONFIG_DEBUG_PREEMPT is not set
```

and your I/O scheduler with 

```
$ grep SCHED /usr/src/linux/.config

CONFIG_IOSCHED_NOOP=y

CONFIG_IOSCHED_AS=y

CONFIG_IOSCHED_DEADLINE=y
```

I find the default scheduler OK.

If X seems unresposive, you can renice it to -10. Thats a hack - better to find and fix the problem.

----------

## cv01302

```

grep EMPT /usr/src/linux/.config

CONFIG_PREEMPT=y

CONFIG_PREEMPT_BKL=y

```

```

grep SCHED /usr/src/linux/.config

CONFIG_SCHED_SMT=y

CONFIG_IOSCHED_NOOP=y

CONFIG_IOSCHED_AS=y

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

# CONFIG_NET_SCHED is not set

```

As you can see, everything is enabled (and I have more options enabled than you), so what is the next step?

"renice -10 X" ?

I shall try and see it, but only if there is no other solution..

Arg, I am playing WoW right now (with cedega), I get instant low fps due to hd function, and then back to normal fps... Nothing else is currently running now...

----------

## NeddySeagoon

cv01302,

Try the different I/O schedulers. I know you can switch by fiddlin with something in /proc but I don't know what.

----------

## Kabuto

Off the top of my head, I think I read somewhere here that had a similar problem and disabled some the generic IDE stuff and just had the Manufacturer specific and that helped them.

----------

## jesse_kahtava

To change I/O schedulers make sure you have them compiled then run

```
cat /sys/block/sdX/queue/scheduler
```

to see what schedulers are available. The one currently selected will have square brackets [] around it.

To change to the anticipatory scheduler run:

```
echo anticipatory > /sys/block/sdX/queue/scheduler
```

replace anticipatory with whatever you want to try

As a side note:

I'm also having speed issues with my sata drive, but haven't yet found a solution. I'm suspecting driver issues.

----------

## NeddySeagoon

jesse_kahtava, cv01302,

Some combinations of chip set and drive are 'blacklisted' in the kernel driver.

They are known to cause data loss/corruption issues when used with all the speed enhancements.

To see if you are affected, grep the kernel source for your drive type and see if it appears in a blacklist.

In some cases there are firmware updates to the drives that fix these issues. You may need to edit the kernel source manually to remove your drive from the blacklist. You can do that anyway but your data loss/corruption is then your problem.

If you post your drive part number, I'll post back the steps in a worked example.

----------

## jesse_kahtava

Here's a lspci dump:

```
0000:00:00.0 Host bridge: VIA Technologies, Inc. VT8377 [KT400/KT600 AGP] Host Bridge (rev 80)

0000:00:01.0 PCI bridge: VIA Technologies, Inc. VT8237 PCI Bridge

0000:00:0d.0 Multimedia audio controller: Creative Labs SB0400 Audigy2 Value

0000:00:0f.0 RAID bus controller: VIA Technologies, Inc. VIA VT6420 SATA RAID Controller (rev 80)

0000:00:0f.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)

0000:00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)

0000:00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)

0000:00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)

0000:00:10.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)

0000:00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86)

0000:00:11.0 ISA bridge: VIA Technologies, Inc. VT8237 ISA bridge [KT600/K8T800/K8T890 South]

0000:00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60)

0000:00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 78)

0000:01:00.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5500] (rev a1)

```

What device is relative to SATA? The only one I can see is the VT6420 SATA RAID Controller, but I'm not using RAID and as such don't have anything 

compiled for it. Other than that, the closest thing is the IDE interface.

Here's my hdd info:

```

Model Number:       Maxtor 6Y080M0

Firmware Revision:  YAR51KW0

```

I'll take a look around and see if I'm blacklisted. Help would be appreciated...

----------

## cv01302

Ok, first I tried removing generic support to IDE/SATA, leaving only enabled into kernel then pIIXn support (both for IDE/SATA). No veil.

(As I said in my first post, I have tried many different combinations, but again back then, I couldn't see any difference - the problem remained).

After checking that I have all 4 I/O schedulers compiled into kernel, I gave it a try, and I saw that with cfq scheduler, things were a bit faster (it was obvious, yet still slow).

Now what remains is to see if my chipset and/or hard disk(s) are blacklisted.

My /dev/sda is a Seagate 120GB, model number is ST3120026AS

I don't know the model number of /dev/sdb, but I know it is WD 80GB, SATA (not sata2), bought relatively recently.

Also, I don't know how I post my hd info, the hdparm -i /dev/sdX doesn't work for sata  :Smile: 

More, posting my USE flag, just in any case..

```

USE="X a52 aac acpi alsa apm arts audiofile avi bluetooth bzip2 cdr cups dedicated divx4linux dv dvd dvdr dvdread encode ffmpeg foomaticdb gif -gnome gpm -gtk -gtk2 hal icc ipv6 java javascript joystick jpeg kde mikmod mmx -mozilla mp3 mpeg msn nptl ogg opengl pda php png posix ppds qt quicktime samba scanner spell sse ssl svg threads tiff truetype unicode usb v4l vcd vorbis win32codecs xine xmms xv xvid zlib"

```

```

lspci:

0000:00:00.0 Host bridge: Intel Corporation 82865G/PE/P DRAM Controller/Host-Hub Interface (rev 02)

0000:00:01.0 PCI bridge: Intel Corporation 82865G/PE/P PCI to AGP Controller (rev 02)

0000:00:1d.0 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 (rev 02)

0000:00:1d.1 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2 (rev 02)

0000:00:1d.2 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI #3 (rev 02)

0000:00:1d.3 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #4 (rev 02)

0000:00:1d.7 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller (rev 02)

0000:00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c2)

0000:00:1f.0 ISA bridge: Intel Corporation 82801EB/ER (ICH5/ICH5R) LPC Interface Bridge (rev 02)

0000:00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02)

0000:00:1f.2 IDE interface: Intel Corporation 82801EB (ICH5) SATA Controller (rev 02)

0000:00:1f.3 SMBus: Intel Corporation 82801EB/ER (ICH5/ICH5R) SMBus Controller (rev 02)

0000:01:00.0 VGA compatible controller: nVidia Corporation NV35 [GeForce FX 5900] (rev a1)

0000:02:05.0 Ethernet controller: 3Com Corporation 3c940 10/100/1000Base-T [Marvell] (rev 12)

0000:02:0b.0 Multimedia audio controller: Creative Labs SB Live! EMU10k1 (rev 07)

0000:02:0b.1 Input device controller: Creative Labs SB Live! MIDI/Game Port (rev 07)

```

----------

## jesse_kahtava

if you run hdparm -I /dev/sdX it should give you some info. It does for me

----------

## NeddySeagoon

jesse_kahtava,

This site http://www.dealtime.co.uk/xPF-Maxtor_DiamondMax_Plus_9_80_GB_6Y080M0 says your drive is SATA.

You have 3 options for using it:-

Your BIOS fakes it to look like the old IDE, in which case it appears as /dev/hd...

You use the obsolete IDE SATA driver in the kernel, so its /dev/hd...

You use the SATA driver under the SCSI section of the kernel and its /dev/sd...

The latter is preferred, which one are you using?

The reference to RAID is just sales patter. The BIOS for the SATA provides 'fake raid', which you are not using.  

```
/usr/src/linux $ grep -R 6Y080M0 ./*
```

returns nothing, so you do not have a blacklisted drive.

Even dropping the 80M0 still returns nothing.

----------

## cv01302

Ok, I am going crazy right now...

Just logged to my fresh install stage1 gentoo on /dev/sda, tried to copy the same file from the same dir to same destination (same partition always), it did around 8 MB/s. I then copied the same file into a new directory inside the same folder, it did it with 45 MB/s !!!!

I then deleted the source file, and copied from the new dir back to the previous source. It did it with 50 MB/s !!

I deleted everything, and tried the very first step, the copy was done AGAIN with 8 MB/s. This is irratating!

If I run hdparm -I /dev/sda , it doesn't give info for me..

----------

## jesse_kahtava

 *Quote:*   

> Your BIOS fakes it to look like the old IDE, in which case it appears as /dev/hd...
> 
> You use the obsolete IDE SATA driver in the kernel, so its /dev/hd...
> 
> You use the SATA driver under the SCSI section of the kernel and its /dev/sd... 

 

I'm using the third option. I've been told to stay away from the second option, and I can't remember seeing the first option in my BIOS settings.

----------

## NeddySeagoon

cv01302,

Here you go ...

```
 /usr/src/linux $ grep -B10 -R ST3120026AS ./*

Binary file ./arch/i386/boot/compressed/vmlinux.bin matches

--

./drivers/scsi/sata_sil.c-      unsigned int quirk;

./drivers/scsi/sata_sil.c-} sil_blacklist [] = {

./drivers/scsi/sata_sil.c-      { "ST320012AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST330013AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST340017AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST360015AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST380013AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST380023AS",         SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST3120023AS",        SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c-      { "ST3160023AS",        SIL_QUIRK_MOD15WRITE },

./drivers/scsi/sata_sil.c:      { "ST3120026AS",        SIL_QUIRK_MOD15WRITE },
```

Do you understand the code (in the file) to determine exactly what this means for you or do you need me to look into a bit deeper?

----------

## NeddySeagoon

jesse_kahtava,

Thats the right answer, your drive is not blacklisted and there is no DMA tuning to be done for SATA, its part of the specification, not grafted on as it was with the old IDE interface.

Do you have a lot of swap in use?

Is swapping taking priority for the use of the HDD ?

----------

## NeddySeagoon

cv01302,

Thats because the kernel never throws anything away unless its forced to.

After the first copy, the source is buffered in memory, so the second copy goes much faster. There is no read operation.

Use the 

```
sync 
```

command to flush the buffers, several times if you are paranoid.

That will force a reread for the second copy.

----------

## cv01302

NeddySeagoon,

What I don't understand is why after all that copying, and most importantly, if I try again the copy from the same source to same destination (as first time!), the transfer reverts back to 8 MB/S. From what you told me, this shouldn't happen.

Oh, and the wierd thing is that I copied it to the original source dir now (overwriting it), now it gives tremendous high speeds everywhere I copy it to**.

Also, to your previous (not last) msg, I saw that my Seagate drive is blacklisted (somewhat expected), so yes I have a problem with bottlenecked drive (I won't be uncommenting anything, as a corrupted fs would be catastrophic right now).

Perhaps I will try to RMA it..

** The partition that has the file is /dev/sdb2 (storage) on WD, so I wouldn't be having low speeds. Except if the WD is blacklisted too (will check later on, but something tells me it's ok)

----------

## NeddySeagoon

cv01302,

The kernel only throws things out of memory when the memory is needed for something else, hence the kernel uses all of memory which causes alarm to some users.

If you copy a file from one place to another, and it all fits into memory, its still there when the copy completes.

If you then copy from the same file, the memory image will used as the source, providing its still there.

Should the memory be needed for something else, the kernel will use it for the new purpose.

To time read only operations try 

```
cat <file> /dev/null 
```

 and write only 

```
cat /dev/zero > <file>
```

Some drives have a nose reduction option, which slows down head movements, makeing reading/writing take longer.

It can be changed with hdparm on IDE drives but we need pass through in satalib (libsata?) before it works for SATA drives.

----------

## koroumel

cv01302, I guess I don't have to introduce my self to you  :Smile: 

I don't remember you paying the hard disk! (just teasing ya, you live too close to my house to try to avoid it  :Laughing:  , but still It could be my bad memory).

I have a 120GB toshiba sata hard disk, and by grepping the kernel sources I found nothing mentioning it blacklisted (I use via-sata). Since I'm in x86_64 arch, I had preemption not set, but after this thread I enabled it and now I have been puzzled for some time.

When I copy a file between folders of the same partition, I get 25MB/sec average. It is too late here so my brain cannot funcition clearly, but if UDMA 133 is supposed to have a transfer rate of 133 MBits/s, then I get a way to fast hard disk operation! If it is 133Mbytes/s, then it is still too slow..  :Sad:  . Still it is better that the 8Mbytes/s I had before.

I use ext3, because I kinda doubt that REISER or XFS are faster, and I strongly doubt that they are safer.

any help? (if it is 133Mbytes/s, which I guess it is)

thanks!

P.S. I have not tweaked ext3 in my system, so this is with the default settings.

----------

## nunogt

 *koroumel wrote:*   

> I use ext3, because I kinda doubt that REISER or XFS are faster, and I strongly doubt that they are safer.

 

Although it's probably insignificant for the problem here, ReiserFS was benchmarked against ext2 and ext3 and it was determined to be faster, Don't know about safety, though.

----------

## koroumel

While it is insignificant _and_ offtopic, here is an analysis of the ext2,ext3,reiser,xfs from Daniel Robbins on IBM's website.

http://www-128.ibm.com/developerworks/linux/library/l-fs8.html#4

Clearly, if you enable the journaling mode of ext3, the performance gain is stunning! This is also described in the following thread:

https://forums.gentoo.org/viewtopic-t-305871.html

As for safety... in amd64 is very buggy, and either way, ext3 is being tested by IBM for ages, while reiser has a few spikes. The metadata journaling that reiserfs is providing is definately not safe for your recently changed files.

Sorry for the off topic, and no, I don't have ext3 journaling anabled... just yet!

----------

## sman

I only read this thread briefly since it came up in a search and I quickly noticed that it didn't contain the info I was looking for but what I did notice, however, was that somebody gave the advice to renice X to -10 in case performance is bad and thought I should say that it only applies to 2.4 kernels and several guides state that you shouldn't do that with 2.6 kernels.

----------

