From: Florian Mickler <florian@mickler.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Dan Carpenter <error27@gmail.com>, Jeff Mahoney <jeffm@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
balbir@linux.vnet.ibm.com, guichaz@gmail.com
Subject: Re: [PATCH] taskstats: Use better ifdef for alignment
Date: Sat, 8 Jan 2011 23:42:00 +0100 [thread overview]
Message-ID: <20110108234200.209c67e4@schatten.dmk.lab> (raw)
In-Reply-To: <20110102131747.3e79107a@schatten.dmk.lab>
On Sun, 2 Jan 2011 13:17:47 +0100
Florian Mickler <florian@mickler.org> wrote:
> On Sat, 1 Jan 2011 19:51:35 +0300
> Dan Carpenter <error27@gmail.com> wrote:
>
> > On Sat, Jan 01, 2011 at 05:19:46PM +0100, Florian Mickler wrote:
> > > Is there already a patch available or integrated into iotop which
> > > fixes this? I'd think that if the kernel could wait on fixed iotop's to
> > > be distributed it would be easier to sell the breakage on bugzilla &
> > > co...
Ok, I sent a fix for the iotop parsing to Guillaume, but didn't receive
any reaction... maybe someone here find's it useful...
commit 392f7e7455c94cdc64aeb0353a79d22b4780687c
Author: Florian Mickler <florian@mickler.org>
Date: Tue Jan 4 12:03:25 2011 +0100
fix parsing of netlink messages
The linux kernel may enhance the message with fields to pad the taskstats struct
(commit 4be2c95d1f ["taskstats: pad taskstats netlink
response for aligment issues on ia64"] in Linus tree).
So now we honour the flexible format and extract the field we are
interested in.
diff --git a/iotop/data.py b/iotop/data.py
index 1164344..c75c190 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -136,6 +136,7 @@ TASKSTATS_CMD_GET = 1
TASKSTATS_CMD_ATTR_PID = 1
TASKSTATS_TYPE_AGGR_PID = 4
TASKSTATS_TYPE_PID = 1
+TASKSTATS_TYPE_STATS = 3
class TaskStatsNetlink(object):
# Keep in sync with format_stats() and pinfo.did_some_io()
@@ -163,19 +164,23 @@ class TaskStatsNetlink(object):
if len(reply.payload) < 292:
# Short reply
return
- reply_length, reply_type = struct.unpack('HH', reply.payload[4:8])
- assert reply_length >= 288
- assert reply_type == TASKSTATS_TYPE_AGGR_PID
-
- pid_length, pid_type = struct.unpack('HH', reply.payload[8:12])
- assert pid_type == TASKSTATS_TYPE_PID
-
- taskstats_start = 4 + 4 + pid_length + 4
- taskstats_data = reply.payload[taskstats_start:]
+ reply.payload = reply.payload[4:]
+ data = get_data(TASKSTATS_TYPE_AGGR_PID, reply.payload)
+ assert( len(data) > 0)
+ taskstats_data = get_data(TASKSTATS_TYPE_STATS, data)
taskstats_version = struct.unpack('H', taskstats_data[:2])[0]
assert taskstats_version >= 4
return Stats(taskstats_data)
+def get_data(field_type, payload):
+ while len(payload) > 3:
+ reply_length, reply_type = struct.unpack('HH', payload[:4])
+ if (reply_type == field_type):
+ break
+ payload = payload[reply_length:]
+
+ return payload[4:reply_length]
+
#
# PIDs manipulations
#
next prev parent reply other threads:[~2011-01-08 22:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-30 0:12 [PATCH] taskstats: Use better ifdef for alignment Jeff Mahoney
2010-12-30 0:14 ` Andrew Morton
2010-12-30 5:26 ` Jeff Mahoney
2010-12-30 5:32 ` Andrew Morton
2010-12-30 15:52 ` Jeff Mahoney
2011-01-01 16:19 ` Florian Mickler
2011-01-01 16:51 ` Dan Carpenter
2011-01-02 12:17 ` Florian Mickler
2011-01-08 22:42 ` Florian Mickler [this message]
2011-01-08 22:46 ` Jeff Mahoney
2010-12-31 0:23 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110108234200.209c67e4@schatten.dmk.lab \
--to=florian@mickler.org \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=error27@gmail.com \
--cc=guichaz@gmail.com \
--cc=jeffm@suse.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox