Wednesday, May 28, 2008

task i/o accounting in Linux: provide distinct tgid/tid i/o statistics

Here a new patch sent to the LKML. This patch (coverage at LWN.net) allows to properly account i/o statistics of threaded applications (tasks spawning threads by clone() syscall + CLONE_THREAD flag).

Without this fix a generic application can bypass of the accounting of the actual i/o statistics creating a bunch of threads doing the real i/o work.

The patch permits to account aggregate i/o statistics in /proc/PID/io, so it allows to easily find the top i/o consumer simply looking at this file, even when PID spawns the i/o worker threads. Moreover, a new file /proc/PID/task/TID/io (one for each TID) is created in procfs to account single thread i/o statistics, allowing in this way, to find which thread(s) of the top i/o consumer is eating the whole i/o bandwidth.

Thursday, May 8, 2008

Recover data from hexdump output in the console

It happens sooner or later to delete some blocks of a disk by a wrong "dd" executed as root... :-) Ok, if you've been so lucky to "hexdump -v -C" those blocks to the console before you can just copy&paste the dump-ed ouput and send it to the standard input of this one-liner perl script:
 
map { map { print pack('H[2]', $_) } split(/\s+/, $1)
if ((/^\w+\s+((\w{2}\s+){1,16})\s+|.*$/i) && ($1)) } 
 
The corresponding binary data can be taken from the standard output. That's it! :-)