LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-08-2009, 06:30 AM   #1
Jung
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
dd if=file1 of=file2 bs=1k PUSHES AVG QUEUE LENGTH UP TO 80 !!!!!


Hi all,

I assume the following command would read 1k first and then write it to output and then repeat the cycle to the end.

# dd if=/dev/sda of=/dev/null bs=1k

Because 1k bytes are only 2 sectors on disk, there would only one request to the disk I guess.
Therefore, dd would issue a request to read 1k and then wait for the data and write it to /dev/null and then request a read again.
So there can be only one request in the request queue for the disk at any time, at least I thought.

However, what happened actually was as below.

While dd is using bs of 1k to read from /dev/sda and write to /dev/null,
# watch -n .1 cat /proc/diskstats
shows that there are as many as 80 requests in progress (that is the 3rd number from the end in each line)

202 0 sda 4597064 37943747 66911714 17175328 1248147 3642689 38644060 175422532 80 3681860 192598428

I am struggling to understand how there can be 80 requests when there should be only 1 at most.

Interestingly, I have this problem with disks with HP cciss driver but not with scsi driver. With SCSI driver, the queue length is 1 usually.
SCSI disks are used for both tests.

Can anyone please shed a light on this issue?

Last edited by Jung; 04-08-2009 at 06:32 AM.
 
Old 04-08-2009, 06:39 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by Jung View Post
Hi all,

I assume ...
Always a bad start.
Testing to validate (or not as the case may be) your assumptions is commendable.
Try changing the I/O scheduler to NOOP and run your tests again.
 
Old 04-08-2009, 07:13 AM   #3
Jung
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
NOOP

I can't test it with NOOP at the moment.

However, I strongly believe that with bs=1k, a single read request from dd should be the only IO request to the disk until the disk returns the requested data.

I have confirmed the theory by testing as below.

# dd if=/dev/sda of=/dev/null bs=1G
and then trace it
# strace -p 'pid of dd'

Because it takes some time to read 1G, strace shows that dd is stuck with read for long time and then quickly write to /dev/null and then spend a while again to read and so on.
(This proves that dd processes only one request at a time. But with a request of 1G-read from dd would make MANY smaller requests to the I/O scheduler.
That is why I used bs=1k to make the problem easier to understand)

I just don't know enough how there can be 80 requests in the request queue.

There is absolutely no other apps using the disk except my dd.
No disk swapping. CPU idle 100% before testing.

Last edited by Jung; 04-08-2009 at 07:22 AM.
 
Old 04-08-2009, 07:27 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by Jung View Post
I can't test it with NOOP at the moment.
I/O scheduler can be set per device - "on the fly"; doesn't require a (re-)boot. If you can find a quiet period for the environment you may be able to test.
Quote:
However, I strongly believe that with bs=1k, a single read request from dd should be the only IO request to the disk until the disk returns the requested data.

I have confirmed the theory by testing as below.

# dd if=/dev/sda of=/dev/null bs=1G
and then trace it
# strace -p 'pid of dd'
using a test of 1 Gig blksize to test ("confirm" ... ???) a theory re 1 K blocksize (or 1 sector) is not valid in any sense.

You might be interested in the data provided by blktrace - I found it quite instructive. But I wouldn't use it in anything but a test system.
 
Old 04-08-2009, 07:56 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
If dd is a single thread process, then regardless of block-size, it's only going to issue one read() at a time. However, perhaps that request is being broken down in kernel space into smaller amounts, 4K pages sounds plausible, or maybe even individual disk blocks(sectors). Maybe the disk driver always reads a track or cylinder at a time. Does that 80 have any relation to your disk geometry values at all? sectors per track or anything like that?

This is all conjecture on my part, I've not studied Linux internals enough to do much more, just throwing it up there to give you some things to consider.

Last edited by GazL; 04-08-2009 at 07:57 AM.
 
Old 04-08-2009, 08:56 AM   #6
Jung
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
>> using a test of 1 Gig blksize to test ("confirm" ... ???) a theory re 1 K blocksize (or 1 sector) is not valid in any sense.

By issuing #dd bs=1G and stracing it, I was able to see that dd is single threaded and waits for completion of a read request of 1G before proceeding with a write of 1G.

So I was lead to believe that it would be the same even if bs=1k.
1k read, completed, 1k write, completed, and so on.

Now, for bs=1k, how many requests should I expect to see in the request queue? Just ONE.

But, as far as HP cciss driver is concerned, it goes beyond 1 and as high as 80~81 on my system.

80 doesn't mean anything special but just happens to be the highest number I have been seeing with the test.

Anyone please tell me how this can be explained?

(I have just tested the same thing on a Xen virtualised guest OS and the queue length is between 4~5 while #dd bs=1k is running)

Last edited by Jung; 04-08-2009 at 09:29 AM.
 
Old 04-08-2009, 09:31 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Quote:
Field 9 -- # of I/Os currently in progress The only field that should go to zero. Incremented as requests are given to appropriate struct request_queue and decremented as they finish.
You're still assuming that One read() call == One request. I don't know whether that assumption is correct or not, but the simplest explanation to the results that you're seeing is that it isn't.
 
Old 04-08-2009, 11:20 PM   #8
Jung
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
1k read

I didn't mean any one request should be one call to disk.
A request of 1G read would be converted to lots of smaller calls to disk, of course.

But when it is only a request of 1k read, I assume it would be only one call to disk (assuming that there is no other access to the same device).

I am still curious to know why HP cciss shows upto 80 io requests in progress while scsi driver shows only 1 io in progress.
 
Old 04-09-2009, 04:36 AM   #9
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Quote:
Originally Posted by Jung View Post
But when it is only a request of 1k read, I assume it would be only one call to disk (assuming that there is no other access to the same device).
Yes, that does sound as if it ought to be the case doesn't it.

Perhaps even though dd is only fetching 1K with the read() the kernel is anticipating further reads and is pre-fetching subsequent sectors for efficiency purposes? But again, I'm only guessing here.

I get the feeling this is something that needs a fairly indepth understanding of the I/O specific parts of the kernel to explain. I'm quite curious about this too now, but I don't think we're going to find an answer here on LQ.

Anyway, any further guesswork on my part isn't really going to add any value from this point on so I'll bow out. Hope you didn't mind me sharing my thought processes on this.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract matching lines from File2 based on File1. grep+while? pwd_pwd_omg_pwd Linux - Newbie 5 04-07-2009 01:48 PM
Copy from file1 to file2 - Trying sed LinuxCrayon Linux - Newbie 3 03-30-2008 07:51 AM
[Comp] How to create a file from the differences between file1 and file2 Xeratul Linux - Software 2 11-19-2006 01:20 PM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
Avoid cat file1>>file2 automatic add return after file2. AshesOfTime Programming 5 11-25-2004 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration