[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help using "dd" command!

From: Bernhard Voelker
Subject: Re: Help using "dd" command!
Date: Mon, 15 Sep 2014 08:11:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0

[re-adding the list]

On 09/14/2014 07:11 PM, Ricardo Ramos wrote:
> Em 14/09/2014 06:58, "Bernhard Voelker" <address@hidden> escreveu:
>> On 09/14/2014 06:49 AM, Ricardo Ramos wrote:
>>> Has you can see, it looks like it's a similar pattern, could anyone explain
>>> to me one or both of the work so that I can find out why are they using
>>> almost the same percentage of CPU cores and exactly the same cores.
>> I can't speak for ddrescue, and I'm not sure I understand the graphs
>> correctly, but dd(1) definitely only uses 1 CPU core.  It's neiter a threaded
>> program nor does it fork other processes (like rsync(1) would).
> Thank you for your response Berny, my doubt it's, the program pidstat show
> that the CPU used by the program dd were some of the cores, not just only one.
> That got me thinking that the Linux kernel might have changed the core of
> the CPU that dd was using or even changed the core while the program was
> waiting for some I/O operation? Could it be one of the 2 cases or the
> program might have returned wrong values during the monitoring process.
> The graphs indicate that dd used more the 5th core than any other on the
> 120GB HDD, but on the 160GB HDD it used the 5th core and also the 6th core.
> The patterns are different on the HDD, but similar on the 2 programs.

Hi Ricardo,

first of all, dd(1) is using only 1 CPU core at the same time.  But it's totally
up to the kernel on which core it is running. Of course, the kernel may decide
to migrate a process to another CPU code at any time, depending on the load, the
configured scheduling policy etc.  Well, on my openSUSE-13.1 system with 4 
a "dd if=/dev/zero of=/dev/null" stays pretty much using the same CPU, but with
higher load, it is moved to other CPUs.

BTW: you can even force the kernel to move a process away from a certain core.
E.g. the above dd(1) process was on CPU core 1 (of 0-3), and I force it to be
moved to another by taking that core out of the process' affinity list:

  $ taskset -pc 26755
  pid 26755's current affinity list: 0-3

  $ taskset -pc 0,2,3 26755
  pid 26755's current affinity list: 0-3
  pid 26755's new affinity list: 0,2,3

Now, the process was moved to core 3, but nothing would prevent the kernel
from moving it to one of the other remaining cores of the affinity list again.
You could even restrict the list of permitted cores to a certain single one
with e.g. "taskset -pc 2 26755", but this probably decreases the overall
performance of the process.  It couldn't run if another process is running
on that CPU, so unless for special cases, I'd not do this because the kernel
usually just does the right thing your you.

After all, this question is not specific to dd(1).

Have a nice day,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]