From: Andrew Morton <akpm@linux-foundation.org>
To: Guillaume Chazarain <guichaz@yahoo.fr>
Cc: balbir@linux.vnet.ibm.com, Jonathan Lim <jlim@sgi.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jay Lan <jlan@cthulhu.engr.sgi.com>
Subject: Re: Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v3)
Date: Wed, 12 Sep 2007 17:18:16 -0700 [thread overview]
Message-ID: <20070912171816.f0993440.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070831143535.2e4709c7@localhost.localdomain>
On Fri, 31 Aug 2007 14:35:35 +0200
Guillaume Chazarain <guichaz@yahoo.fr> wrote:
> TASKSTATS_CMD_ATTR_TGID used to return only the delay accounting stats,
> not the basic and extended accounting. With this patch,
> TASKSTATS_CMD_ATTR_TGID also aggregates the accounting info for all threads of a
> thread group. This makes TASKSTATS_CMD_ATTR_TGID usable in a similar
> fashion to TASKSTATS_CMD_ATTR_PID, for commands like iotop -P
> (http://guichaz.free.fr/misc/iotop.py).
>
> Here is the output of the testcase before the patch:
>
> ...
> Documentation/accounting/dump-test.c | 314 +++++++++++++++++++++++++++++++++++
Another C file in the Documentation directory. Sigh. At kernel summit I
suggested that we should be putting these things in a place from where we
can actually build and install them. People said there was no need to do
that because kernel developers can now easily get new stuff into
util-linux. I don't believe them. Wanna be a guinea pig?
> +static void loop_reading(const char *filename)
> +{
> + int fd = open(filename, O_RDONLY);
> + char buffer[4096];
> +
> + if (fd < 0) {
> + perror(filename);
> + return;
> + }
> +
> + for (;;) {
> + lseek(fd, 0, SEEK_SET);
> + while (read(fd, buffer, sizeof(buffer)) > 0) ;
newline here. Just because it's userspace doesn't mean that it needs to
look crappy, despite all the code out there which disproves this ;)
I think you just invented pread().
> + }
> +}
> +
>
> ...
>
> --- a/kernel/taskstats.c Fri Aug 31 01:42:23 2007 -0700
> +++ b/kernel/taskstats.c Fri Aug 31 13:36:29 2007 +0200
> @@ -168,6 +168,60 @@ static void send_cpu_listeners(struct sk
> up_write(&listeners->sem);
> }
>
> +/*
> + * There are two types of taskstats fields when considering a thread group:
> + * - those that can be aggregated from each thread in the group (like CPU
> + * times),
> + * - those that cannot be aggregated (like UID) or are identical (like
> + * memory usage), so are taken from the group leader.
> + * XXX_threadgroup() methods deal with the first type while XXX_add_tsk() with
> + * the second.
> + */
> +static void fill_threadgroup(struct taskstats *stats, struct task_struct *task)
> +{
> + /*
> + * Each accounting subsystem adds calls to its functions to initialize
> + * relevant parts of struct taskstsats for a single tgid as follows:
> + *
> + * per-task-foo-fill_threadgroup(stats, task);
> + */
> +
> + stats->version = TASKSTATS_VERSION;
> +
> + /* fill in basic acct fields */
> + bacct_fill_threadgroup(stats, task);
> +
> + /* fill in extended acct fields */
> + xacct_fill_threadgroup(stats, task);
> +}
> +
> +/*
> + * Stats specific to each thread in the thread group. Stats of @task should be
> + * combined with those already present in @stats. add_tsk() works in
> + * conjunction with fill_threadgroup(), taskstats fields should not be touched
> + * by both functions.
> + */
It's odd to use kerneldoc-style markup in a non-kerneldoc comment.
> @@ -232,32 +272,21 @@ static int fill_tgid(pid_t tgid, struct
> else
> memset(stats, 0, sizeof(*stats));
>
> + leader = first->group_leader;
> + get_task_struct(leader);
> + fill_threadgroup(stats, leader);
> + put_task_struct(leader);
> +
Are the get_task_struct/put_task_struct here actually needed?
next prev parent reply other threads:[~2007-09-13 0:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-02 13:53 [PATCH] Add all thread stats for TASKSTATS_CMD_ATTR_TGID Guillaume Chazarain
2007-08-02 19:04 ` Andrew Morton
2007-08-19 19:34 ` Guillaume Chazarain
2007-08-20 17:01 ` Balbir Singh
2007-08-25 15:10 ` Guillaume Chazarain
2007-08-26 4:58 ` Balbir Singh
2007-08-26 9:44 ` Guillaume Chazarain
2007-08-31 3:02 ` Jonathan Lim
2007-08-31 7:24 ` Balbir Singh
2007-08-31 12:35 ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v3) Guillaume Chazarain
2007-09-13 0:18 ` Andrew Morton [this message]
2007-09-15 18:42 ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v4) Guillaume Chazarain
2007-09-17 22:23 ` Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v5) Guillaume Chazarain
2007-09-18 15:29 ` Oleg Nesterov
2007-09-20 6:20 ` Andrew Morton
2007-09-20 8:54 ` Balbir Singh
2007-09-20 12:16 ` Oleg Nesterov
2007-09-20 12:17 ` Balbir Singh
2007-09-07 23:37 ` [PATCH] Add all thread stats for TASKSTATS_CMD_ATTR_TGID Jonathan Lim
2007-09-10 13:03 ` Guillaume Chazarain
2007-08-15 7:15 ` Balbir Singh
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=20070912171816.f0993440.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=guichaz@yahoo.fr \
--cc=jlan@cthulhu.engr.sgi.com \
--cc=jlim@sgi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.