On Mon, 18 Jan 2010, Linus Torvalds wrote: > > In particular: > > strace -s8 -T -o trace .libs/lt-blkid /dev/sdc1 > grep -v '<0.0' trace > > gives > > read(3, "\353<\220){'`j"..., 1024) = 1024 <1.024049> > read(3, "\0\0\0\0\0\0\0\0"..., 16384) = 16384 <2.048790> > close(3) = 0 <4.102118> > > and I have _no_ idea why that close() takes so long, but I'm guessing that > it is flushing the page cache and has to wait for any read-ahead to > finish. > > That is arguably a kernel problem, and I'll take a look at it. Although > disabling read-ahead in blkid is probably a good thing regardless. Here's a patch. With this, I get: read(3, "\353<\220){'`j"..., 1024) = 1024 <0.256857> read(3, "\0\0\0\0\0\0\0\0"..., 16384) = 16384 <1.033671> ie the reads themselves sped up (because we only read what we really need, no read-ahead), and the overhead of "close()" obviously went away too. So how I get [root@EeePC misc-utils]# time ./blkid /dev/sdc1 /dev/sdc1: SEC_TYPE="msdos" TYPE="vfat" real 0m1.342s user 0m0.015s sys 0m0.033s which is a _lot_ better, and quite acceptable. It's not the 8kB read that you claimed, but it's fine. This improves the full-disk case too, but not enough: [root@EeePC misc-utils]# time ./blkid /dev/sdc real 0m4.968s user 0m0.023s sys 0m0.047s I think it's still unacceptable to take five seconds to notice that it's just a regular DOS partition thing, but it is certainly a lot faster than it used to be. Linus --- From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Subject: Disable read-ahead when probing device files in blkid Read-ahead doesn't work very well on device probing, and can hurt a lot when we do essentially random accesses on very slow devices. So disable it if possible. Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> --- shlibs/blkid/src/probe.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 2d3cafe..21791c1 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -640,6 +640,10 @@ int blkid_probe_set_device(blkid_probe pr, int fd, pr->mode = 0; pr->blkssz = 0; +#ifdef POSIX_FADV_RANDOM + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM); +#endif + if (size) pr->size = size; else { -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html