RE: [git patches] IDE update

Al Boldi
2005-07-09T21:41:57Z

[-- Attachment #1: Type: text/plain, Size: 6142 bytes --]

Jens Axboe <axboe@suse.de> wrote:{
> >>
> >>>Some more investigation - it appears to be broken read-ahead, actually.
> >>>
> >>>--- mm/readahead.c~ 2005-07-08 11:16:14.000000000 +0200
> >>>+++ mm/readahead.c 2005-07-08 11:17:49.000000000 +0200
> >>>@@ -351,7 +351,9 @@
> >>> ra->cache_hit += nr_to_read;
> >>> if (ra->cache_hit >= VM_MAX_CACHE_HIT) {
> >>> ra_off(ra);
> >>>+#if 0
> >>> ra->flags |= RA_FLAG_INCACHE;
> >>>+#endif
> >>> return 0;
> >>> }
> >>> } else {
> >>
> >> >Just use the test app I posted, it shows the problem just fine. If I
> >use a regular file, behaviour is identical as expected (ie equally
> >broken :-).
}

Modified test app shows comparison w/ and w/o O_DIRECT.

Your comments please!

2.4.31# (hdparm -f /dev/hda;free;time /tmp/readisk /dev/hda 1 )

/dev/hda:
total used free shared buffers cached
Mem: 256388 23728 232660 0 1944 4324
-/+ buffers/cache: 17460 238928
Swap: 0 0 0
Mem Throughput: 107 MiB/sec - 8388608-16 bs-blks
Mem Throughput: 121 MiB/sec - 4194304-32 bs-blks
Mem Throughput: 122 MiB/sec - 2097152-64 bs-blks
Mem Throughput: 122 MiB/sec - 1048576-128 bs-blks
Mem Throughput: 120 MiB/sec - 524288-256 bs-blks
Mem Throughput: 120 MiB/sec - 262144-512 bs-blks
Mem Throughput: 131 MiB/sec - 131072-1024 bs-blks
Mem Throughput: 336 MiB/sec - 65536-2048 bs-blks
Mem Throughput: 476 MiB/sec - 32768-4096 bs-blks
Mem Throughput: 432 MiB/sec - 16384-8192 bs-blks
Mem Throughput: 824 MiB/sec - 8192-16384 bs-blks <--- 20% faster
Mem Throughput: 799 MiB/sec - 4096-32768 bs-blks
Mem Throughput: 494 MiB/sec - 2048-65536 bs-blks
Mem Throughput: 270 MiB/sec - 1024-131072 bs-blks
Mem Throughput: 146 MiB/sec - 512-262144 bs-blks
Mem Throughput: 76 MiB/sec - 256-524288 bs-blks
Disk Throughput: 39 MiB/sec
1.13user 12.35system 0:15.65elapsed 86%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (87major+2061minor)pagefaults 0swaps
=====================================================================

2.4.31# (hdparm -f /dev/hda;free;time /tmp/readisk /dev/hda 1 1 )
O_DIRECT

/dev/hda:
total used free shared buffers cached
Mem: 256388 23824 232564 0 2024 4324
-/+ buffers/cache: 17476 238912
Swap: 0 0 0
Mem Throughput: 36 MiB/sec - 8388608-16 bs-blks
Mem Throughput: 34 MiB/sec - 4194304-32 bs-blks
Mem Throughput: 34 MiB/sec - 2097152-64 bs-blks
Mem Throughput: 37 MiB/sec - 1048576-128 bs-blks
Mem Throughput: 29 MiB/sec - 524288-256 bs-blks <--- small dip
Mem Throughput: 15 MiB/sec - 262144-512 bs-blks <--- 333% slower
Mem Throughput: 42 MiB/sec - 131072-1024 bs-blks
Mem Throughput: 45 MiB/sec - 65536-2048 bs-blks
Mem Throughput: 40 MiB/sec - 32768-4096 bs-blks
Mem Throughput: 36 MiB/sec - 16384-8192 bs-blks
Mem Throughput: 33 MiB/sec - 8192-16384 bs-blks
Mem Throughput: 25 MiB/sec - 4096-32768 bs-blks
Mem Throughput: 16 MiB/sec - 2048-65536 bs-blks
Mem Throughput: 10 MiB/sec - 1024-131072 bs-blks
read infile: Invalid argument 512-262144 bs-blks <--- too small?
read infile: Invalid argument 256-524288 bs-blks
Disk Throughput: 38 MiB/sec
0.27user 10.88system 1:12.95elapsed 15%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (99major+2062minor)pagefaults 0swaps
=====================================================================

2.6.12# (hdparm -f /dev/hda;free;time /tmp/readisk /dev/hda 1 )

/dev/hda:
total used free shared buffers cached
Mem: 255228 15668 239560 0 5060 4252
-/+ buffers/cache: 6356 248872
Swap: 0 0 0
Mem Throughput: 97 MiB/sec - 8388608-16 bs-blks
Mem Throughput: 120 MiB/sec - 4194304-32 bs-blks
Mem Throughput: 120 MiB/sec - 2097152-64 bs-blks
Mem Throughput: 120 MiB/sec - 1048576-128 bs-blks
Mem Throughput: 121 MiB/sec - 524288-256 bs-blks
Mem Throughput: 120 MiB/sec - 262144-512 bs-blks
Mem Throughput: 129 MiB/sec - 131072-1024 bs-blks
Mem Throughput: 237 MiB/sec - 65536-2048 bs-blks
Mem Throughput: 451 MiB/sec - 32768-4096 bs-blks
Mem Throughput: 418 MiB/sec - 16384-8192 bs-blks
Mem Throughput: 636 MiB/sec - 8192-16384 bs-blks
Mem Throughput: 672 MiB/sec - 4096-32768 bs-blks <--- 20% slower
Mem Throughput: 399 MiB/sec - 2048-65536 bs-blks
Mem Throughput: 217 MiB/sec - 1024-131072 bs-blks
Mem Throughput: 115 MiB/sec - 512-262144 bs-blks
Mem Throughput: 59 MiB/sec - 256-524288 bs-blks
Disk Throughput: 26 MiB/sec
0.93user 13.79system 0:18.59elapsed 79%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+2150minor)pagefaults 0swaps
=====================================================================

2.6.12# (hdparm -f /dev/hda;free;time /tmp/readisk /dev/hda 1 1)
O_DIRECT

/dev/hda:
total used free shared buffers cached
Mem: 255228 15668 239560 0 5060 4252
-/+ buffers/cache: 6356 248872
Swap: 0 0 0
Mem Throughput: 33 MiB/sec - 8388608-16 bs-blks
Mem Throughput: 30 MiB/sec - 4194304-32 bs-blks
Mem Throughput: 34 MiB/sec - 2097152-64 bs-blks
Mem Throughput: 39 MiB/sec - 1048576-128 bs-blks
Mem Throughput: 30 MiB/sec - 524288-256 bs-blks <--- small dip
Mem Throughput: 49 MiB/sec - 262144-512 bs-blks <--- 333% faster
Mem Throughput: 49 MiB/sec - 131072-1024 bs-blks
Mem Throughput: 44 MiB/sec - 65536-2048 bs-blks
Mem Throughput: 42 MiB/sec - 32768-4096 bs-blks
Mem Throughput: 40 MiB/sec - 16384-8192 bs-blks
Mem Throughput: 29 MiB/sec - 8192-16384 bs-blks
Mem Throughput: 22 MiB/sec - 4096-32768 bs-blks
Mem Throughput: 14 MiB/sec - 2048-65536 bs-blks
Mem Throughput: 8 MiB/sec - 1024-131072 bs-blks
Mem Throughput: 4 MiB/sec - 512-262144 bs-blks
read infile: Invalid argument 256-524288 bs-blks <--- too small?
Disk Throughput: 34 MiB/sec
0.69user 32.09system 1:39.15elapsed 33%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+2164minor)pagefaults 0swaps
=====================================================================

[-- Attachment #2: rd128.c --]
[-- Type: application/octet-stream, Size: 1702 bytes --]

//#include <stdio.h>
#include <unistd.h>
#define __USE_GNU
#include <fcntl.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <linux/fs.h>

#define BS (8192*1024)
#define BLOCKS (128*1024/8192)
#define ALIGN(buf) (char *) (((unsigned long) (buf) + 4095) & ~(4095))

void print_time(struct timeval *s, int memory)
{
unsigned long ms, mb;
struct timeval e;
mb = BS * BLOCKS / 1024;
gettimeofday(&e, NULL);
ms = (e.tv_sec - s->tv_sec) * 1000 + (e.tv_usec - s->tv_usec) / 1000;

if (memory)
printf("Mem Throughput: %lu MiB/sec - %lu-%lu bs-blks\n", mb / ms, BS/memory, BLOCKS*memory);
else
printf("Disk Throughput: %lu MiB/sec\n", mb / ms);
}

void read_stuff(int fd, char *buffer, int memory)
{
struct timeval s;
int i, ret;

int j=1; if (memory)\r j=memory;

gettimeofday(&s, NULL);

for (i = 0; i < (BLOCKS*j); i++) {
if (memory)
lseek(fd, 0, SEEK_SET);
ret = read(fd, buffer, BS/j);

if (!ret)
break;
else if (ret < 0) {
perror("read infile");
// break;
return;
}
}
print_time(&s, memory);
}

int main(int argc, char *argv[])
{
char *buffer;
int i, fd, seek;
if (argc < 2) {
printf("%s: <device>\n", argv[0]);
return 1;
}

if (argc > 2)
seek = 1;
else
seek = 0;

if (argc > 3)
fd = open(argv[1], O_RDONLY | O_DIRECT);
else
fd = open(argv[1], O_RDONLY );

if (argc > 4)
seek = 0;

if (fd == -1) {
perror("open");
return 2;
}
ioctl(fd, BLKFLSBUF, 0);

buffer = ALIGN(malloc(BS + 4095));

if (seek) {
for (i = 0; i < 16 ; i++) {
read_stuff(fd, buffer, (2<<i)/2);
}}
read_stuff(fd, buffer, 0);
return 0;
}