# Desktop Lags under Heavy IO

## pwaller

My Machine:

pwaller@jupiter ~ $ uname -a

Linux jupiter 2.6.22-suspend2 #2 SMP PREEMPT Mon Sep 3 00:55:46 UTC 2007 i686 Genuine Intel(R) CPU T2500 @ 2.00GHz GenuineIntel GNU/Linux

The lag I'm experiencing is most noticeable when I'm emerging or searching for files using find. Notably it affects the mouse and the keyboard. It makes typing almost impossible because it seems something is registering the key being pressed but not registering the key being released and so I get lots of a single keypress when trying to type.

I'm not really sure where to begin with trying to figure out what is causing this, can somebody recommend a starting point?

Cheers.

P.S. Can someone recommend a way of attaching my Kernel config to this post?

----------

## Ehnvis

Do you have DMA running on your harddrives? Check with hdparm /dev/hdX or hdparm /dev/sdX, where X is the letter of the drive.

Easiest way to attach the kernel config is to open it up in an editor or view it in some way. Copy the text and paste it to here in code tags.

----------

## tuam

 *Ehnvis wrote:*   

> Easiest way to attach the kernel config is to open it up in an editor or view it in some way. Copy the text and paste it to here in code tags.

 

And please try to shorten it to reasonable size, e.g. by deleting commented (audio, network, usb) driver lines.

FF,

Daniel

----------

## John R. Graham

 *pwaller wrote:*   

> P.S. Can someone recommend a way of attaching my Kernel config to this post?

 The best way is to emerge wgetpaste.  This utility will establish a temporary place (lasts 30 days) on the web for people to view your config.  You can just type

```
wgetpaste /usr/src/linux/.config
```

and wgetpaste will return a URL that you can post to the forums.

- John

----------

## pwaller

http://rafb.net/p/3v2vGd88.html

----------

## energyman76b

try cfq as default scheduler.

I had pretty good experiences with it. Better than with AS.

also, please post your dmesg - and maybe explain some of your config choices.

Memory hotplug yes? MSR only module? wtf?

and turn of the generic ide driver, if you are using a chipset driver. Or generic will 'steal' the device - and it is slower.

Also, turn off nmi-watchdog  nmi_watchdog=0 as boot parameter. There are reports that it becomes less laggy that way.

do you really need all that scsi-crap? or the stuff in block? or all that fs? btw, if you are using reiserfs, turn of the 'Preempt big kernel log' - it is faster that way. 'Voluntary Preemption' might be better too and '300Hz' instead of 1000. if you are using a laptop, you really don't want 1000Hz, because it sucks down battery juice like a thristy camel water.

Maybe clean up your config. You can't have everything installed you turned on or turned on as module.. your kernel build-time will decrease a lot!

----------

## Sadako

 *energyman76b wrote:*   

> btw, if you are using reiserfs, turn of the 'Preempt big kernel log' - it is faster that way. 'Voluntary Preemption' might be better too and '300Hz' instead of 1000. if you are using a laptop, you really don't want 1000Hz, because it sucks down battery juice like a thristy camel water.

 

Any source on this?

I'm not questioning you, it's just that I'm using reiserfs (v3.6) and have "Preempt the big kernel lock" enabled (which is what I presume you meant), and I'd be really interested if those two don't play nice together somehow.

----------

## energyman76b

 *Hopeless wrote:*   

>  *energyman76b wrote:*   btw, if you are using reiserfs, turn of the 'Preempt big kernel log' - it is faster that way. 'Voluntary Preemption' might be better too and '300Hz' instead of 1000. if you are using a laptop, you really don't want 1000Hz, because it sucks down battery juice like a thristy camel water. 
> 
> Any source on this?
> 
> I'm not questioning you, it's just that I'm using reiserfs (v3.6) and have "Preempt the big kernel lock" enabled (which is what I presume you meant), and I'd be really interested if those two don't play nice together somehow.

 

I have read that on lkml some month ago.. and no, I don't have the link anymore. Reiserfs uses the BKL and the other fs don't. So if reiserfs holds the BKL and it gets preempted, you loose performance.

----------

## astor84

You don't happen to have an SiS chipset do you? SiS chipsets are notorious for being unable to handle a lot of simultaneous IO.

----------

## pwaller

No SIS chipset. Sorry for the long delay.. thanks for the advice guys.

I tried some of it out (I haven't switched to the CFQ scheduler yet.)

Here is the latest kernel config, with unused stuff stripped out (but section comments remaining)

http://pastebin.ca/707923

Here is my dmesg output:

http://pastebin.ca/707925

Here is my lspci:

http://pastebin.ca/707928

I tried turning of my scsi stuff but managed to mess everything up. Is there an easy way to maintain multiple kernel configurations installed with the same version of the kernel? I had the problem where I changed stuff and couldn't boot at all because it didn't recognise my hard-disk. I'm using genkernel.. I figure there must be an easy way to do this.

So the options seem to have helped a little, but still when emerging I lose my system almost entirely, and watching a DVD is very jerky.

Thanks in advance guys.

- Peter

----------

## energyman76b

 *pwaller wrote:*   

> No SIS chipset. Sorry for the long delay.. thanks for the advice guys.
> 
> I tried some of it out (I haven't switched to the CFQ scheduler yet.)
> 
> Here is the latest kernel config, with unused stuff stripped out (but section comments remaining)
> ...

 

so you are using slow onboard graphic, your laptop (?) lacks a hpet, I can't find DMA mentioned for your disks, you have two ide drivers loaded instead of one, you are still including douzend of fs you'll never use or need and your are using framebuffer.

only include the ide driver for your chipset

turn this off:

CONFIG_IDE_GENERIC

CONFIG_BLK_DEV_GENERIC

CONFIG_BLK_DEV_VIA82CXXX 

you don't have a freaking via-chipset!

turn on this:

Intel PIIXn chipsets support 

KICK OUT:

RTC

# Real Time Clock

CONFIG_RTC_LIB=y

CONFIG_RTC_CLASS=y

CONFIG_RTC_HCTOSYS=y

CONFIG_RTC_HCTOSYS_DEVICE="rtc0"

# RTC interfaces

CONFIG_RTC_INTF_SYSFS=y

CONFIG_RTC_INTF_PROC=y

CONFIG_RTC_INTF_DEV=y

CONFIG_RTC_INTF_DEV_UIE_EMUL=y

# Platform RTC drivers

CONFIG_RTC_DRV_DS1553=m

CONFIG_RTC_DRV_DS1742=m

CONFIG_RTC_DRV_M48T86=m

CONFIG_RTC_DRV_V3020=m

turn it off. all of it.

all that scsi-stuff

really.

# DMA Engine support

CONFIG_DMA_ENGINE=y

away!

# Miscellaneous filesystems

CONFIG_SQUASHFS=y

CONFIG_SQUASHFS_EMBEDDED=y

CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3

# Network File Systems

CONFIG_NFS_FS=m

CONFIG_NFS_V3=y

CONFIG_NFSD=m

CONFIG_NFSD_V3=y

CONFIG_NFSD_TCP=y

CONFIG_LOCKD=m

CONFIG_LOCKD_V4=y

CONFIG_EXPORTFS=m

CONFIG_NFS_COMMON=y

CONFIG_SUNRPC=m

CONFIG_CIFS=m

CONFIG_CIFS_XATTR=y

CONFIG_CIFS_POSIX=y

WAAAAAAAH!

almost all kernel-hacking options! Debug = SLOW

And use cfg instead of antipicatory as IO-scheduler.

Your system is jerky, because you load the wrong ide drivers, you slowed it additionally down with debug options you'll never need, increased the kernel size (bigger size = slow) with garbage and you are using a io-scheduler that is HUGE and not really fast.

Build a new kernel, report back if your problem persists.

----------

## pwaller

Cheers energyman. I will try this out over the next couple of hours and report back  :Smile: 

- Pete

----------

## energyman76b

and excuse me please, if I sound harsh  :Wink: 

----------

## Sadako

 *energyman76b wrote:*   

> and excuse me please, if I sound harsh 

 

You always sound harsh.

 :Razz: 

----------

## pwaller

s'ok, your help outweighs your attitude.  :Wink: 

I have to say though, I am worried about turning of the SCSI stuff. I think it caused me problems last time. And figuring out exactly what IDE driver to turn off is a pain, too.

Is there any way to keep my old, known-working kernel config around whilst trying out the new one?

----------

## energyman76b

 *pwaller wrote:*   

> s'ok, your help outweighs your attitude. 
> 
> I have to say though, I am worried about turning of the SCSI stuff. I think it caused me problems last time. And figuring out exactly what IDE driver to turn off is a pain, too.
> 
> Is there any way to keep my old, known-working kernel config around whilst trying out the new one?

 

just copy .config somewhere else. Also, I told you exactly which ide driver to turn off and on.

About the scsi stuff: it does not hurt keeping the scsi-disk, scsi-cd, scsi-generic and multi-lun support (the last one is needed for cardreaders). Everything else should be turned of.

 *Hopeless wrote:*   

>  *energyman76b wrote:*   and excuse me please, if I sound harsh  
> 
> You always sound harsh.
> 
> 

 

look at my avatar. See the annoyed look? That is how I feel 24h a day!

----------

## Sadako

 *pwaller wrote:*   

> Is there any way to keep my old, known-working kernel config around whilst trying out the new one?

 

I think that's what the CONFIG_LOCALVERSION option is there for.

You should definitley disable "CONFIG_IDE_GENERIC" if the VIA82CXXX is the right driver for your board.

Do you have dri, dbe and xv/xvmc working in xorg?

----------

## energyman76b

 *Hopeless wrote:*   

>  *pwaller wrote:*   Is there any way to keep my old, known-working kernel config around whilst trying out the new one? 
> 
> I think that's what the CONFIG_LOCALVERSION option is there for.
> 
> You should definitley disable "CONFIG_IDE_GENERIC" if the VIA82CXXX is the right driver for your board.
> ...

 

he does not have via. He has intel. He needs the intel driver. Nothing else.

----------

## Sadako

 *energyman76b wrote:*   

>  *Hopeless wrote:*    *energyman76b wrote:*   and excuse me please, if I sound harsh  
> 
> You always sound harsh.
> 
>  
> ...

 

You don't work in tech support, do you?

----------

## Sadako

 *energyman76b wrote:*   

>  *Hopeless wrote:*   A load of nonsense 
> 
> he does not have via. He has intel. He needs the intel driver. Nothing else.

 

Ah, I only looked at the kernel config.

 :Embarassed: 

My bad.

----------

## energyman76b

 *Hopeless wrote:*   

>  *energyman76b wrote:*    *Hopeless wrote:*    *energyman76b wrote:*   and excuse me please, if I sound harsh  
> 
> You always sound harsh.
> 
>  
> ...

 

almost. I play tech support for a bunch of net-addicted students who don't read the emails in their universities account nor the letters from the landlord (no rent, no net...).

----------

## Sadako

 *energyman76b wrote:*   

>  *Hopeless wrote:*   You don't work in tech support, do you? 
> 
> almost. I play tech support for a bunch of net-addicted students who don't read the emails in their universities account nor the letters from the landlord (no rent, no net...).

 

Ouch.

I feel your pain.

----------

## pwaller

Latest Kernel Config:

http://pastebin.ca/708088

Hey, I seem to have some improvement, but DMA is disabled.

I'm feeling really dumb, I can't figure out what I need to do to turn it on. I've grepped for DMA in the config, but to me it looks like all of the relevant options are on..?

I really appreciate the help guys.

----------

## Sadako

What does `hdparm -d 1 /dev/hda` actually return, on both the command line and in dmesg?

Oh, energyman76b, I read up on the reiserfs and "Preempt the big kernel lock" thing, and apparently it's only the journalling code which makes use of it, however there isn't much else in the kernel which does use the kernel lock so I've disabled that preemption option.

Thanks for the tip off.

----------

## energyman76b

dmesg would be helpfull. And you should be able to turn on dma with hdparm (hdparm -d1 -u1 -c1 /dev/hda & the same for your cd drive like hdc..)

----------

## pwaller

okay, so it turns out I was being really dumb and was compiling 2.6.22-suspend2-r2 but using 2.6.22-suspend2 (no -r2)

and it turns out that something I disabled (and I am unsure what unfortunately, because I made lots of small changes to make sure I didn't break anything, but wasn't using the right kernel, so I have no idea what broke it.

It's complaining it can't find my boot partition... I've tried turning lots of stuff back on but to no avail.. urrgh...

I will continue fiddling. If anyone can spot what I might be doing wrong I would appreciate it.

----------

## pwaller

jupiter afs # hdparm -d1 -u1 -c1 /dev/hda

/dev/hda:

 setting 32-bit IO_support flag to 1

 setting unmaskirq to 1 (on)

 setting using_dma to 1 (on)

 HDIO_SET_DMA failed: Operation not permitted

 IO_support    =  1 (32-bit)

 unmaskirq     =  1 (on)

 using_dma     =  0 (off)

Nothing listed in dmesg.

I managed to get a bootable system back. Not sure what was the problem. Started off with a good config and painstakingly removed bits at a time.

Benchmark using hdparm:

jupiter afs # hdparm -tT /dev/hda        

/dev/hda:

 Timing cached reads:   2258 MB in  2.00 seconds = 1129.86 MB/sec

 Timing buffered disk reads:   18 MB in  3.26 seconds =   5.52 MB/sec

I read that the cached reads number is acceptable, but the buffered read rate should be more like ten times what I have, and of course DMA is off.

My latest kernel config: (I will remove RTC and reset the schedulers and stuff soon, I'm now more worried about the DMA issues.)

http://pastebin.ca/708293

----------

## Sadako

"CONFIG_BLK_DEV_VIA82CXXX"?

You're still using the via chipset driver, and as energyman76b pointed out it's one of the intel drivers you should be using.

----------

## pwaller

Ah. Yup, whoops. I will be disabling this very shortly.

----------

## Sadako

 *pwaller wrote:*   

> Ah. Yup, whoops. I will be disabling this very shortly.

 

Disabling this will not be enough, you need to enable the appropriate driver for your intel chipset.

----------

## pwaller

hmm. I disabled the Via and I disabled the generic, enabling the Intel PIIX and I am unable to boot. Then I enabled the generic and I can boot.

Here is my dmesg:

http://pastebin.ca/708386

----------

## energyman76b

could you please post the config belonging to that dmesg? (and turn of the fs you don't have... please.. your dmesg will be a lot shorter and more readable with all the superfluos stuff turned off...).

----------

## pwaller

Config:

http://pastebin.ca/708522

Oh, and I have turned off all of the FS's I want to.

----------

## energyman76b

please turn off this stuff:

CONFIG_ATA=y

CONFIG_ATA_ACPI=y

CONFIG_ATA_PIIX=y

you only can have libata or the 'normal' ide drivers, but if you try using both, you run into problems.

----------

## pwaller

Okay, slightly confused. So I have an Intel Chipset (ICH stuff) and my hard drive is SATA. What do I want to be using? (If not the things you just listed)

----------

## energyman76b

aaaah. You have SATA. I missed that.

Ok, in that case, keep the ide stuff (not the libata stuff) and also set this option:

CONFIG_ATA_ACPI=y

CONFIG_SATA_AHCI=y

or, if AHCI does not work for you (but AHCI is supported by most intel chipsets - it was intels idea..):

deactivate everthing in ide, and set

CONFIG_ATA_PIIX

but, you also have to compile scsi harddisk support and scsi cdrom support into the kernel.

Is your cdrom sata too? Or only the harddisk?

----------

## pwaller

I don't know about the CD-Rom -- is there an easy way to find out?

----------

## energyman76b

 *pwaller wrote:*   

> I don't know about the CD-Rom -- is there an easy way to find out?

 

hdparm -iI /dev/deviceofyourcdrom and googling for the name.

----------

## pwaller

http://uk.shopping.com/xPF-Sony-SLIM-DL-DVD-RW-BLACK

IDE/EIDE, apparently.

----------

## energyman76b

ok, in that case try the AHCI driver in the SATA/ATA menu, compile scsi disk into the kernel, and the ide drivers.

I am not sure - it might be problematic, maybe someone using intel-chips could say something *sigh*

----------

## tarpman

Your laptop is very similar to mine.  What you want to do is disable the E/IDE subsystem completely in favour of the new libata stuff (CONFIG_ATA and friends).  Specifically, you need CONFIG_ATA for the libata subsystem (CONFIG_ATA_ACPI, a hidden symbol, is selected automatically), CONFIG_ATA_PIIX for your SATA chipset, and CONFIG_PATA_MPIIX for IDE support for your DVD drive.  All other ATA related options should be disabled; specifically, CONFIG_IDE and everything underneath it must be disabled, as must CONFIG_ATA_GENERIC.  Then, to allow the devices to show up, make sure CONFIG_BLK_DEV_SD (for your hard drive) and CONFIG_BLK_DEV_SR (for your optical drive) are enabled.  CONFIG_CHR_DEV_SG is also a good idea.

Be warned: this is a major subsystem change.  Your hard drive, if it is currently /dev/hda, will change to /dev/sda; make sure you update /etc/fstab to reflect this before rebooting.  Your DVD drive may or may not become /dev/sr0; it may also stay as /dev/hdc, in which case /dev/sr0 may or may not be a symlink to it (or vice versa), depending on your specific hardware; either way, udev should maintain appropriate /dev/cdrom and /dev/dvd symlinks, so you shouldn't have to do anything with that.  hdparm does not work to set parameters on SATA drives, although you can use it with -i and/or -I to show information about your drives; to set parameters you want sdparm instead.

DMA is automatically enabled for all drives supported by the libata subsystem, so if you are able to boot with CONFIG_IDE and CONFIG_ATA_GENERIC disabled, then DMA will be enabled for you unless it simply will not work with your particular hardware.

----------

## pwaller

Woohoo, this is exactly correct.  :Very Happy: 

Cheers.

- Pete

----------

## SkyLeach

I've searched google, these forums and others and I'm still having no luck getting DMA to work on an HP-Compaq 2300 series desktop microtower

lspci:

```
00:00.0 Host bridge: Intel Corporation Memory Controller Hub (rev 02)

00:01.0 PCI bridge: Intel Corporation PCI Express Root Port (rev 02)

00:02.0 VGA compatible controller: Intel Corporation Integrated Graphics Controller (rev 02)

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 01)

00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #1 (rev 01)

00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #2 (rev 01)

00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #3 (rev 01)

00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #4 (rev 01)

00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 01)

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

00:1f.0 ISA bridge: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge (rev 01)

00:1f.2 IDE interface: Intel Corporation 82801GB/GR/GH (ICH7 Family) Serial ATA Storage Controller IDE (rev 01)

00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 01)

02:00.0 RAID bus controller: Silicon Image, Inc. SiI 3124 PCI-X Serial ATA Controller (rev 01)

02:08.0 Ethernet controller: Intel Corporation 82801G (ICH7 Family) LAN Controller (rev 01)

```

There are no bios options on this machine concerning the operation mode of the SATA controller.  The kernel sees the disks as IDE disks (/dev/hda, /dev/hdb -> dvdr)

there is no ide interface on this system, it's all SATA

dunno what else to try, thought I'd try posting.

some additional info:

hdparm /dev/hda:

```
/dev/hda:

 multcount     = 16 (on)

 IO_support    =  0 (default 16-bit)

 unmaskirq     =  0 (off)

 using_dma     =  0 (off)

 keepsettings  =  0 (off)

 readonly      =  0 (off)

 readahead     = 256 (on)

 geometry      = 16383/255/63, sectors = 156301488, start = 0

```

speed test:

```
backdoorman mgregory # hdparm -tT /dev/hda

/dev/hda:

 Timing cached reads:   1994 MB in  2.00 seconds = 997.17 MB/sec

 Timing buffered disk reads:   12 MB in  3.39 seconds =   3.54 MB/sec

```

attempt to turn on dma results in this:

```
/dev/hda:

 setting using_dma to 1 (on)

 HDIO_SET_DMA failed: Operation not permitted

 using_dma     =  0 (off)
```

----------

## tarpman

Post your kernel config (with comments stripped out - try zgrep -ve "^#" -e "^$" /proc/config.gz) somewhere, and take a look at my post here.  I know your machine isn't a laptop, but the advice there pertains to any 82801 or similar chipset.

----------

## SkyLeach

 *tarpman wrote:*   

> Post your kernel config (with comments stripped out - try zgrep -ve "^#" -e "^$" /proc/config.gz) somewhere, and take a look at my post here.  I know your machine isn't a laptop, but the advice there pertains to any 82801 or similar chipset.

 

managed to fix it by using 2.6.22-gentoo-r7

----------

## SkyLeach

btw, I had already read your post and checked my kernel config.  I had found some other information on ICH7 based laptops and done all of it as well.

different chipset revision perhaps?  Mine is a 946gz express.

----------

## tarpman

Does your drive appear as /dev/sda with the new kernel, or is it still /dev/hda?  If you have it set up properly, it should be the former.  If it's still /dev/hda, then you're still using the older IDE subsystem, rather than the new libata one, and some things may not work at their best.  There's nothing to be lost from switching to libata - it's a fully mature and functional system at this point.  For SATA drives in particular, it's definitely the better choice (e.g. NCQ functionality).

Chipset revision doesn't (ok, shouldn't) matter; this information applies to all ICH7 boards, and possibly to some earlier ones as well.

----------

## desultory

Merged topic "no luck with DMA on intel 82801GB/GR/GH hardware".

Moved from Desktop Environments to Kernel & Hardware.

----------

## SkyLeach

 *tarpman wrote:*   

> Does your drive appear as /dev/sda with the new kernel, or is it still /dev/hda?  If you have it set up properly, it should be the former.  If it's still /dev/hda, then you're still using the older IDE subsystem, rather than the new libata one, and some things may not work at their best.  There's nothing to be lost from switching to libata - it's a fully mature and functional system at this point.  For SATA drives in particular, it's definitely the better choice (e.g. NCQ functionality).
> 
> Chipset revision doesn't (ok, shouldn't) matter; this information applies to all ICH7 boards, and possibly to some earlier ones as well.

 

yeah, it's showing up as a scsi device now.

----------

