Re: 2.6.9-rc1-mm3

From: Peter Osterlund
Date: Sun Sep 05 2004 - 04:02:48 EST


Andrew Morton <akpm@xxxxxxxx> writes:

> Peter Osterlund <petero2@xxxxxxxxx> wrote:
> >
> > One problem that does remain though, is that when dumping huge amounts
> > of data to a CD or DVD disc (so that you get memory pressure), the
> > effective writing speed of other block devices (like IDE hard disks)
> > is reduced to the same speed as the packet device.
> >
> > I have posted a patch that fixes this problem by limiting the amount
> > of writeback data in the packet driver, but unfortunately it makes the
> > effective writing speed of the packet device suffer a lot. The proper
> > fix is probably to improve the filesystem and/or VM code to start I/O
> > operations in sequential order a lot more often than it currently
> > does.
>
> If you decrease /proc/sys/vm/dirty_ratio and dirty_background_ratio to much
> smaller levels, does that fix things up?

No, it seems to slow the packet device down without improving the hard
disk speed.

I wrote a patch that logs what I/O operations are received by the
packet driver. For my test case, which does

time cp -av /testdata /udf ; time sync

where /testdata contains 120MB of data in 29 files, the I/O pattern
looks like this:

10:06:03 421 - 1905
10:06:03 1906 - 2482
10:06:03 4255 - 6031
10:06:03 6032 - 6320
10:06:03 8514 - 10277
10:06:03 10278 - 10566
10:06:03 13773 - 15821
10:06:03 16520 - 18568
10:06:03 19021 - 21068
10:06:03 21069 - 23117
10:06:03 23208 - 24869
10:06:03 24870 - 25286
10:06:03 27120 - 28714
10:06:03 28715 - 29195
10:06:03 30307 - 32355
10:06:03 32732 - 34704
10:06:03 34705 - 34801
10:06:03 36905 - 38953
10:06:03 39390 - 41283
10:06:03 41284 - 41444
10:06:03 43663 - 45008
10:06:03 45009 - 45713
10:06:03 46719 - 48678
10:06:03 48679 - 48775
10:06:03 51004 - 53052
10:06:03 53497 - 55545
10:06:03 2482 - 4254
10:06:03 55581 - 55869
10:06:03 6320 - 8368
10:06:03 57527 - 59529
10:06:03 10566 - 10630
10:06:03 59530 - 61578
10:06:03 15821 - 16466
10:06:03 16474 - 16519
10:06:03 18568 - 19020
10:06:03 23117 - 23207
10:06:03 25286 - 26118
10:06:03 29195 - 30306
10:06:03 32355 - 32731
10:06:03 34801 - 35377
10:06:03 38953 - 39389
10:06:03 41444 - 43076
10:06:03 45713 - 46718
10:06:03 48775 - 49831
10:06:03 53052 - 53496
10:06:03 55545 - 55579
10:06:03 55869 - 57469
10:06:03 8368 - 8513
10:06:03 10630 - 12550
10:06:03 61578 - 62086
10:06:03 26118 - 27119
10:06:03 35377 - 35921
10:06:03 43076 - 43662
10:06:04 49831 - 51003
10:06:04 57469 - 57526
10:06:04 12550 - 12806
10:06:04 35921 - 36904
10:06:04 12806 - 13772
10:06:04 273 - 278
10:06:04 417 - 418
10:06:04 419 - 421
10:06:04 1905 - 1906
10:06:04 4254 - 4255
10:06:04 6031 - 6032
10:06:04 8513 - 8514
10:06:04 10277 - 10278
10:06:04 13772 - 13773
10:06:04 16519 - 16520
10:06:04 19020 - 19021
10:06:04 21068 - 21069
10:06:04 23207 - 23208
10:06:04 24869 - 24870
10:06:04 27119 - 27120
10:06:04 28714 - 28715
10:06:04 30306 - 30307
10:06:04 32731 - 32732
10:06:04 34704 - 34705
10:06:04 36904 - 36905
10:06:04 39389 - 39390
10:06:04 41283 - 41284
10:06:04 43662 - 43663
10:06:04 45008 - 45009
10:06:04 46718 - 46719
10:06:04 48678 - 48679
10:06:04 51003 - 51004
10:06:04 53496 - 53497
10:06:04 55579 - 55581
10:06:04 57526 - 57527
10:06:31 59529 - 59530
10:06:31 273 - 274

See attachment for a graph of this data. The X axis corresponds to the
I/O submission order and the Y axis corresponds to the sector numbers.

Attachment: iopattern.png
Description: IO_pattern.png


diff -puN drivers/block/pktcdvd.c~packet-io-log drivers/block/pktcdvd.c
--- linux/drivers/block/pktcdvd.c~packet-io-log 2004-09-05 10:35:24.697900200 +0200
+++ linux-petero/drivers/block/pktcdvd.c 2004-09-05 10:35:24.701899592 +0200
@@ -896,6 +896,27 @@ static inline void pkt_set_state(struct
pkt->state = state;
}

+static void pkt_io_log(struct bio *bio)
+{
+ static sector_t start, stop;
+ typedef unsigned long long ull;
+
+ if (bio) {
+ if (stop == bio->bi_sector) {
+ stop = stop + bio_sectors(bio);
+ } else {
+ if (start != stop)
+ printk("pkt: %lld - %lld\n", (ull)(start >> 2), (ull)(stop >> 2));
+ start = bio->bi_sector;
+ stop = start + bio_sectors(bio);
+ }
+ } else {
+ if (start != stop)
+ printk("pkt: %lld - %lld\n", (ull)(start >> 2), (ull)(stop >> 2));
+ start = stop = 0;
+ }
+}
+
/*
* Scan the work queue to see if we can start a new packet.
* returns non-zero if any work was done.
@@ -949,6 +970,8 @@ try_next_bio:
spin_unlock(&pd->lock);
if (!bio) {
VPRINTK("handle_queue: no bio\n");
+ if (list_empty(&pd->cdrw.pkt_active_list))
+ pkt_io_log(NULL);
return 0;
}

@@ -2197,6 +2220,8 @@ static int pkt_make_request(request_queu
}
}

+ pkt_io_log(bio);
+
/*
* If we find a matching packet in state WAITING or READ_WAIT, we can
* just append this bio to that packet.
_

--
Peter Osterlund - petero2@xxxxxxxxx
http://w1.894.telia.com/~u89404340