2001-10-04 19:52:34

by Roger Larsson

[permalink] [raw]
Subject: [PATCH] scaling of 'max_readahead' in /proc/ide/hda/settings

I put the note first since it is important:
-----------------------------------------------
NOTE: this scaling problem might be in several drivers and possibly
also in several places in this driver. Most likely in -ac too when
enabling dynamic readahead for SCSI
-----------------------------------------------

In an earlier message I reported that dynamically changing readahead
for ide disk produced unexpected results.

I have now found the reason!

If you did cat the /proc/ide/hda/settings you would have noticed that
max_readahead was zero. But reading the code you would see that
is initialized with MAX_READAHEAD (defined to 31)

I tried to modify this and got strange results when diffing two files bigger
than RAM. Sinusoidal between very good and very poor...
But modifying the MAX_READAHEAD and recompiling worked!

Both of these are due to the same problem with scaling in ide-disk.c

mul_factor = 1
div_factor = 1024

But max_readahead is measured in pages.

When reading the file max_readahead is divided by 1024, resulting
in zero.

A value written to it is on the other hand multiplied by 1024...

So when I tried to set 511 pages readahead (2MB) it was interpreted
as 511*1024 pages (2GB !) So it tried to read ahead all of one file
before trying to read the other (but one file is bigger than my memory)

With the included patch I measure in kB and limit it at 16MB.

/RogerL

--
Roger Larsson
Skellefte?
Sweden


Attachments:
patch-2.4.11-pre2-ide_settings (1.43 kB)