# VERY slow read HD performance (Timing buffered disk reads)

## Lucero del Alba

Hello people, I'm a new Gentoo user and this is my first post.  I would like to solve a little problem with the performance of my hard disk, perhaps you could help me. 

I realized that my system gets VERY slow when performs an aggressive reading or writing to my hard disk.  I couldn't find the reason for I while, but take these examples: if I watch a video from my HD the system gets slower, if a watch it from the CD-ROM the systems works normally; when burning a CD (from an ISO or whatever, from my HD) everything gets **so** irritating slow unit burning finished; when copy a big file from a partition to another... and so on.  By the way, I don't have this particular problem under MS Windows. 

Before Gentoo I was using SuSE 8.0 and then switched.  I build it from stage1, and the system itself is now much faster than before (applications, etc), I mean, everything else works correctly but this issue.  I was seeking the forum for a possible solution but didn't find it although I found 2 related posts (Slow CP speeds across HD and slow second ide device).

Alright, this is my box: 

HD: 40 GB Maxtor.

CPU: 1 GHz AMD Duron.

RAM: 256 MB DDR.More info? 

```
bash-2.05b$ dmesg | grep hda

Kernel command line: root=/dev/hda7 hdc=ide-scsi hdd=ide-scsi

    ide0: BM-DMA at 0xd400-0xd407, BIOS settings: hda:DMA, hdb:pio

hda: Maxtor 5T040H4, ATA DISK drive

hda: 80043264 sectors (40982 MB) w/2048KiB Cache, CHS=4982/255/6
```

 And the most important:

```
bash-2.05b# hdparm -tT /dev/hda

/dev/hda:

 Timing buffer-cache reads:   128 MB in  0.66 seconds =195.42 MB/sec

 Timing buffered disk reads:  64 MB in 33.44 seconds =  1.91 MB/sec
```

As you can see, the "buffered disk reads" is extremely slow!  And an except from my /etc/fstab:

```
/dev/hda1           /mnt/c          vfat    defaults,uid=1000,gid=100  0 0

/dev/hda2           /mnt/e          ntfs    defaults,uid=1000,gid=100  0 0

/dev/hda7           /               reiser  noatime,notail             0 1

/dev/hda6           none            swap    sw                         0 0

/dev/cdroms/cdrom0  /mnt/cdrecorder iso9660 user,noauto,ro             0 0

/dev/cdroms/cdrom1  /mnt/cdrom      iso9660 user,noauto,ro             0 0
```

... by the way, my boot is also on /dev/hda7 (that's way "notail" option is enabled).  My only HD is alone as primary master, and my CD-RW / CD-ROM are on secondary IDE

So, that's it.  Any suggestion, clue, comment... anything? 

Thanks in advance, people!

----------

## NeddySeagoon

Lucero del Alba,

It looks like a serious case of not using DMA on the hard drive.

What does using_dma say at the bottom of  less /proc/ide/hda/settings?

If its not a 1, read man hdparm and learn how to set it.

If dma is always safe on your chip set, turn it on in the kernel, which I think you can do with a parameter on the kerenl command line.

Regards,

NeddySeagoon

----------

## Caffeine

Yeah, sounds like you haven't enabled DMA.

You can check it either as per NeddySeagoon's suggestion, or use hdparm so:

```
espresso root # hdparm -d /dev/hda

/dev/hda:

 using_dma    =  1 (on)
```

To enable DMA:

```
espresso root # hdparm -d1 /dev/hda

/dev/hda:

 setting using_dma to 1 (on)

 using_dma    =  1 (on)
```

There are other paramaters you can tune with hdparm also but I cann't find the thread as the search page seems to have died.

----------

## Lucero del Alba

Hello again.  You both were right, DMA was disabled for my first IDE. 

As NeddySeagoon indicated, using_dma in /proc/ide/hda/settings was in '0', and  I could enable it with hdparm, as Caffeine pointed (with "hdparm -d1 /dev/hda") and things were better immediately:

```
bash-2.05b# hdparm -tT /dev/hda 

 

/dev/hda: 

 Timing buffer-cache reads:   128 MB in  0.70 seconds =181.56 MB/sec 

 Timing buffered disk reads:  64 MB in  1.84 seconds = 34.78 MB/sec
```

I had some troubles trying to parsing the necessary options to the kernel, at boot-time 'til I finally catched it: 

```
ide0=ata66 ide0=dma
```

Firstly, this was confusing to me because my HD is an ATA100, but 'ata66' option seems to be valid to ATA 66 and ATA100 drives (ATA133??). 

Thanks very much for your comments, people!!

By the way.  If someone else out there had this same problem, the options "ide0=ata66 ide0=dma" (which worked to me) can be parsed to the kernel easily.  If you had Grub as boot manager (my case), edit /boot/grub/grub.conf (or /boot/grub/menu.lst) and find something like "kernel (hd0,6)/boot/bzImage" and add " ide0=ata66 ide0=dma" in that same line.  Then, should get something like: 

```
title=Gentoo Linux

root (hd0,6)

kernel (hd0,6)/boot/bzImage root=/dev/hda7 ide0=ata66 ide0=dma
```

If you had LILO as boot-manager you should add append="ide0=ata66 ide0=dma", like this: 

```
image=/boot/bzImage 

         label=Gentoo 

         (...) 

         append="ide0=ata66 ide0=dma"
```

You need also to have enabled some flags on your kernel under "ATA/IDE/MFM/RLL support" and "IDE, ATA and ATAPI Block devices": 

```
[*]     Generic PCI bus-master DMA support 

[*]       Use PCI DMA by default when available
```

More info at the The Linux Ultra-DMA Mini-Howto (see Activating and Deactivating UDMA section).

See ya!

----------

