# [Solved] SSD slow according to hdparm

## hoerbe

Hi,

I have a Thinkpad T61 and just installed Gentoo on "Crucial RealSSD C300 128GB". According to hdparm the SSD performs much worse than it should:

```

hdparm  -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  404 MB in  3.00 seconds = 134.63 MB/sec

```

What can I do to achieve better throughput?Last edited by hoerbe on Fri Jan 07, 2011 12:07 am; edited 2 times in total

----------

## aderesch

What kernel are you using, which IO scheduler, and what's the read_ahead_kb value? The latter two values can be read/modified inside /sys/block/sda/queue (replace sda with your device name if different). You might want to try with the deadline or noop scheduler and an increased read_ahead_kb value (up to 8192 seems reasonable). Also, what is the drive's firmware version?

ad

----------

## hoerbe

```

uname -a

Linux odin 2.6.36-gentoo-r5 #19 SMP PREEMPT Thu Jan 6 13:29:18 CET 2011 x86_64 Intel(R) Core(TM)2 Duo CPU T9300 @ 2.50GHz GenuineIntel GNU/Linux

```

```

cat /sys/block/sda/queue/read_ahead_kb 

128

```

almost no improvement with:

```

echo 8192 > /sys/block/sda/queue/read_ahead_kb

hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  412 MB in  3.01 seconds = 136.92 MB/sec

```

shall I set it back to 128?

```

cat /sys/block/sda/queue/scheduler 

[noop] deadline cfq

```

I've the latest firmware - is is called 06 or so.

I just read something about trim and alignment. Can that be a reason too?

Currently I have:

```

fdisk -lu /dev/sda

Disk /dev/sda: 128.0 GB, 128035676160 bytes

255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x26a344a5

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *          63      112454       56196   83  Linux

/dev/sda2          112455     8514449     4200997+  82  Linux swap / Solaris

/dev/sda3         8514450   199366649    95426100   83  Linux

/dev/sda4       199366650   250067789    25350570    b  W95 FAT32

```

----------

## aderesch

 *hoerbe wrote:*   

> shall I set it back to 128?

 

Probably doesn't matter for now. When I got my SSD there was a significant improvement turning this up, but rechecking now I also only see a small difference. Keep this value in mind for further testing, though.

 *hoerbe wrote:*   

> I just read something about trim and alignment. Can that be a reason too?

 

Not for the hdparm read test, I'd say.

Another thing: What SATA controller do you have, and what mode is it running in? (AHCI? What speed?) Your transfer rate is suspiciously close to the theoretical maximum of SATA 1.5 Gb/s.

ad

----------

## hoerbe

Thanks for your quick reply!

I think it is best to come back to the trim and alignment stuff later...

SATA controller from lspci -v

```

00:1f.2 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller (rev 03) (prog-if 01 [AHCI 1.0])

   Subsystem: Lenovo ThinkPad T61

   Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 46

   I/O ports at 1c48 [size=8]

   I/O ports at 1c1c [size=4]

   I/O ports at 1c40 [size=8]

   I/O ports at 1c18 [size=4]

   I/O ports at 1c20 [size=32]

   Memory at fe226000 (32-bit, non-prefetchable) [size=2K]

   Capabilities: [80] MSI: Enable+ Count=1/4 Maskable- 64bit-

   Capabilities: [70] Power Management version 3

   Capabilities: [a8] SATA HBA <?>

   Kernel driver in use: ahci

```

how can I check in what mode it is running?

Edit:

```

hdparm -i /dev/sda

/dev/sda:

 Model=C300-CTFDDAC128MAG, FwRev=0006, SerialNo=00000000104502FF0704

 Config={ Fixed DTR>10Mbs }

 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0

 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16

 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=250069680

 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio3 pio4 

 DMA modes:  mdma0 mdma1 mdma2 

 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 

 AdvancedPM=yes: unknown setting WriteCache=enabled

 Drive conforms to: unknown:  ATA/ATAPI-3,4,5,6,7

```

Edit II:

BIOS is set to AHCI.

----------

## aderesch

 *hoerbe wrote:*   

> how can I check in what mode it is running?

 

All kernel log messages concerning drive and controller would be of interest. Also, your fdisk output shows a FAT partition -- can you get measurements from Windows?

ad

----------

## hoerbe

Hmm, currently I have no Windows installed...

```

dmesg | grep ahci

[    0.383098] ahci 0000:00:1f.2: version 3.0

[    0.383120] ahci 0000:00:1f.2: PCI INT B -> GSI 16 (level, low) -> IRQ 16

[    0.383811] ahci 0000:00:1f.2: irq 46 for MSI/MSI-X

[    0.383904] ahci 0000:00:1f.2: AHCI 0001.0100 32 slots 3 ports 1.5 Gbps 0x1 impl SATA mode

[    0.384729] ahci 0000:00:1f.2: flags: 64bit ncq sntf pm led clo pio slum part ccc 

[    0.385459] ahci 0000:00:1f.2: setting latency timer to 64

[    0.385597] scsi0 : ahci

[    0.386053] scsi1 : ahci

[    0.386495] scsi2 : ahci

```

```

dmesg | grep sda

[    0.000000] Command line: root=/dev/sda3 rw rootfstype=ext4 vga=869

[    0.000000] Kernel command line: root=/dev/sda3 rw rootfstype=ext4 vga=869

[    1.023247] sd 0:0:0:0: [sda] 250069680 512-byte logical blocks: (128 GB/119 GiB)

[    1.068954] sd 0:0:0:0: [sda] Write Protect is off

[    1.114689] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00

[    1.114712] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA

[    1.162079]  sda: sda1 sda2 sda3 sda4

[    1.185830] sd 0:0:0:0: [sda] Attached SCSI disk

[    4.957898] PM: Checking image partition /dev/sda2

[    5.363231] EXT4-fs (sda3): mounted filesystem with ordered data mode. Opts: (null)

[    7.383781] EXT4-fs (sda3): re-mounted. Opts: discard

[    7.475749] EXT4-fs (sda3): re-mounted. Opts: discard

[    7.791782] EXT4-fs (sda1): mounted filesystem without journal. Opts: (null)

[    7.942693] Adding 4200992k swap on /dev/sda2.  Priority:-1 extents:1 across:4200992k SS

[   40.403646] EXT4-fs (sda3): re-mounted. Opts: discard,commit=0

```

any more?

----------

## aderesch

 *hoerbe wrote:*   

> 
> 
> ```
> [    0.383904] ahci 0000:00:1f.2: AHCI 0001.0100 32 slots 3 ports 1.5 Gbps 0x1 impl SATA mode
> 
> ...

 

A few of the missing lines would have been interesting (especially those containing "SATA link up"), but the 1.5 Gbps in the above line does not look promising at all.

A quick google search for 

```
ich8m sata 3.0Gbps
```

 leads me to the following:

http://forum.thinkpads.com/viewtopic.php?f=27&t=84953

So it seems your chipset is indeed artificially restricted to 1.5Gbps (~150MB/s) by the BIOS.

ad

----------

## hoerbe

Indeed! SATA II seem to be locked to 1.5 Gbps on the Thinkpad T61 models!

There is a patched BIOS out there that removes the lock. It is reported to work!

What do you think about the alignment question. Is it worth doing it?

As far as I figured out, one could use fdisk -H 32 -S 32 /dev/sda, and start the first partition at cylinder 2 (link).

----------

## aderesch

 *hoerbe wrote:*   

> What do you think about the alignment question. Is it worth doing it?
> 
> As far as I figured out, one could use fdisk -H 32 -S 32 /dev/sda, and start the first partition at cylinder 2 (link).

 

I don't see any drawbacks (discounting waste of a negligible amount of disk space), so I wouldn't (and didn't) take any chances.

Since I couldn't get any reliable information about the erase block size of my drive (it was very new at the time), I actually went with -H 64 and aligned everything to multiples of 1MB. Be careful about your units (e.g. cylinder 2), as fdisk's default units are actually sectors (not cylinders) nowadays.

ad

----------

## albright

I just tried the modified BIOS (1.10-1.01) you linked to on my thinkpad

x300 -- hdparm went from 133 MB/sec to 186 MB/sec !!! (I have the

standard 128gb samsung ssd - not a real speed demon but this is excellent

read performance)

thanks for pointing this out.

----------

## hoerbe

Me either! Works great.

```

hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  790 MB in  3.00 seconds = 263.27 MB/sec

```

Currently on my not-aligned ext4 partition I observed the following speeds:

Write:

```

dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc

1024+0 records in

1024+0 records out

1073741824 bytes (1.1 GB) copied, 8.36605 s, 128 MB/s

```

Read:

```

echo 3 > /proc/sys/vm/drop_caches

dd if=tempfile of=/dev/null bs=1M count=1024

1024+0 records in

1024+0 records out

1073741824 bytes (1.1 GB) copied, 3.89939 s, 275 MB/s

```

As soon as I have some time left I'll re-align the disk partitions and report the results.

Whats the best way of doing that? A fresh install (stage4)?

----------

## hoerbe

I now aligned the partitions using fdisk -H 32 -S 32 /dev/sda.

The read/write tests on ext4 reported more or less the same results.

Using echo 8192 > /sys/block/sda/queue/read_ahead_kb and/or hdparm -W 0 /dev/sda brings no improvement as well.

I think thats it! Approx. 270 MB/s read and 130 MB/s write seems to be what I can get out of the disk.

Thanks for the help.

----------

## marwat208

Someone more knowledgeable than me correct me if I'm wrong...

```
/dev/sda2          112455     8514449     4200997+  82  Linux swap / Solaris 
```

Swap on an SSD is not so good for the drive life and performance.

----------

## hoerbe

Sure. But one does not have much choise with a laptop. In addition swap space is rarely used if you have enough memory.

----------

## pigeon768

Setting swappiness to 0 is also a good idea with swap on SSD.

----------

## Tolstoi

 *aderesch wrote:*   

>  *hoerbe wrote:*   
> 
> ```
> [    0.383904] ahci 0000:00:1f.2: AHCI 0001.0100 32 slots 3 ports 1.5 Gbps 0x1 impl SATA mode
> 
> ...

 

There's a BIOS around for some Thinkpad models like the T61 which disables the 1.5 Gbps limitation. I've just flashed my BIOS last week with it.

----------

