linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Cc: Shailabh Nagar <nagar1234@in.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Venkatesh Pallipadi <venki@google.com>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Oleg Nesterov <oleg@redhat.com>,
	John stultz <johnstul@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [RFC][PATCH 02/10] taskstats: Separate taskstats commands
Date: Mon, 11 Oct 2010 13:10:35 +0530	[thread overview]
Message-ID: <20101011074035.GA17223@balbir.in.ibm.com> (raw)
In-Reply-To: <1285250462.1837.79.camel@holzheu-laptop>

* Michael Holzheu <holzheu@linux.vnet.ibm.com> [2010-09-23 16:01:02]:

> Subject: [PATCH] taskstats: Separate taskstats commands
> 
> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> 
> This patch moves each taskstats command into a single function. This
> makes
> the code more readable and makes it easier to add new commands.
> 
> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> ---
>  kernel/taskstats.c |  118
> +++++++++++++++++++++++++++++++++++------------------
>  1 file changed, 78 insertions(+), 40 deletions(-)
> 
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -424,39 +424,76 @@ err:
>  	return rc;
>  }
> 
> -static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info
> *info)
> +static int cmd_attr_register_cpumask(struct genl_info *info)
>  {
> -	int rc;
> -	struct sk_buff *rep_skb;
> -	struct taskstats *stats;
> -	size_t size;
>  	cpumask_var_t mask;
> +	int rc;
> 
>  	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
>  		return -ENOMEM;
> -
>  	rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask);
>  	if (rc < 0)
> -		goto free_return_rc;
> -	if (rc == 0) {
> -		rc = add_del_listener(info->snd_pid, mask, REGISTER);
> -		goto free_return_rc;
> -	}
> +		goto out;
> +	rc = add_del_listener(info->snd_pid, mask, REGISTER);
> +out:
> +	free_cpumask_var(mask);
> +	return rc;
> +}
> +
> +static int cmd_attr_deregister_cpumask(struct genl_info *info)
> +{
> +	cpumask_var_t mask;
> +	int rc;
> 
> +	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
> +		return -ENOMEM;
>  	rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], mask);
>  	if (rc < 0)
> -		goto free_return_rc;
> -	if (rc == 0) {
> -		rc = add_del_listener(info->snd_pid, mask, DEREGISTER);
> -free_return_rc:
> -		free_cpumask_var(mask);
> -		return rc;
> -	}
> +		goto out;
> +	rc = add_del_listener(info->snd_pid, mask, DEREGISTER);
> +out:
>  	free_cpumask_var(mask);
> +	return rc;
> +}
> +static int cmd_attr_pid(struct genl_info *info)
> +{
> +	struct taskstats *stats;
> +	struct sk_buff *rep_skb;
> +	size_t size;
> +	u32 pid;
> +	int rc;
> +
> +	size = nla_total_size(sizeof(u32)) +
> +		nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
> +
> +	rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size);
> +	if (rc < 0)
> +		return rc;
> +
> +	rc = -EINVAL;
> +	pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
> +	stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
> +	if (!stats)
> +		goto err;
> +
> +	rc = fill_pid(pid, NULL, stats);
> +	if (rc < 0)
> +		goto err;
> +	return send_reply(rep_skb, info);
> +err:
> +	nlmsg_free(rep_skb);
> +	return rc;
> +}
> +
> +static int cmd_attr_tgid(struct genl_info *info)
> +{
> +	struct taskstats *stats;
> +	struct sk_buff *rep_skb;
> +	size_t size;
> +	u32 tgid;
> +	int rc;
> 
> -	/*
> -	 * Size includes space for nested attributes
> -	 */
>  	size = nla_total_size(sizeof(u32)) +
>  		nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
> 
> @@ -465,33 +502,34 @@ free_return_rc:
>  		return rc;
> 
>  	rc = -EINVAL;
> -	if (info->attrs[TASKSTATS_CMD_ATTR_PID]) {
> -		u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
> -		stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
> -		if (!stats)
> -			goto err;
> -
> -		rc = fill_pid(pid, NULL, stats);
> -		if (rc < 0)
> -			goto err;
> -	} else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) {
> -		u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
> -		stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
> -		if (!stats)
> -			goto err;
> -
> -		rc = fill_tgid(tgid, NULL, stats);
> -		if (rc < 0)
> -			goto err;
> -	} else
> +	tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
> +	stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
> +	if (!stats)
>  		goto err;
> 
> +	rc = fill_tgid(tgid, NULL, stats);
> +	if (rc < 0)
> +		goto err;
>  	return send_reply(rep_skb, info);
>  err:
>  	nlmsg_free(rep_skb);
>  	return rc;
>  }
> 
> +static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info
> *info)
> +{
> +	if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
> +		return cmd_attr_register_cpumask(info);
> +	else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
> +		return cmd_attr_deregister_cpumask(info);
> +	else if (info->attrs[TASKSTATS_CMD_ATTR_PID])
> +		return cmd_attr_pid(info);
> +	else if (info->attrs[TASKSTATS_CMD_ATTR_TGID])
> +		return cmd_attr_tgid(info);
> +	else
> +		return -EINVAL;
> +}
> +
>  static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk)
>  {
>  	struct signal_struct *sig = tsk->signal;
> 
>

Looks good (sorry for the delay in reviewing, I expect to be slow for
another two weeks or so)

 
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
 

-- 
	Three Cheers,
	Balbir

  parent reply	other threads:[~2010-10-11  7:40 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 13:48 [RFC][PATCH 00/10] taskstats: Enhancements for precise accounting Michael Holzheu
2010-09-23 14:00 ` [RFC][PATCH 01/10] taskstats: Use real microsecond granularity for CPU times Michael Holzheu
2010-10-07  5:08   ` Balbir Singh
2010-10-08 15:08     ` Michael Holzheu
2010-10-08 16:39       ` Balbir Singh
2010-09-23 14:01 ` [RFC][PATCH 02/10] taskstats: Separate taskstats commands Michael Holzheu
2010-09-27  9:32   ` Balbir Singh
2010-10-11  7:40   ` Balbir Singh [this message]
2010-09-23 14:01 ` [RFC][PATCH 03/10] taskstats: Split fill_pid function Michael Holzheu
2010-09-23 17:33   ` Oleg Nesterov
2010-09-27  9:33   ` Balbir Singh
2010-10-11  8:31   ` Balbir Singh
2010-09-23 14:01 ` [RFC][PATCH 04/10] taskstats: Add new taskstats command TASKSTATS_CMD_ATTR_PIDS Michael Holzheu
2010-09-23 14:01 ` [RFC][PATCH 05/10] taskstats: Add "/proc/taskstats" Michael Holzheu
2010-09-23 14:01 ` [RFC][PATCH 06/10] taskstats: Add thread group ID to taskstats structure Michael Holzheu
2010-09-23 14:01 ` [RFC][PATCH 07/10] taskstats: Add per task steal time accounting Michael Holzheu
2010-09-23 14:02 ` [RFC][PATCH 08/10] taskstats: Add cumulative CPU time (user, system and steal) Michael Holzheu
2010-09-23 14:02 ` [RFC][PATCH 09/10] taskstats: Fix exit CPU time accounting Michael Holzheu
2010-09-23 17:10   ` Oleg Nesterov
2010-09-24 12:18     ` Michael Holzheu
2010-09-26 18:11       ` Oleg Nesterov
2010-09-27 13:23         ` Michael Holzheu
2010-09-27 13:42         ` Martin Schwidefsky
2010-09-27 16:51           ` Oleg Nesterov
2010-09-28  7:09             ` Martin Schwidefsky
2010-09-29 19:19             ` Roland McGrath
2010-09-30 13:47               ` Michael Holzheu
2010-10-05  8:57                 ` Roland McGrath
2010-10-06  9:29                   ` Michael Holzheu
2010-10-06 15:26                     ` Oleg Nesterov
2010-10-07 15:06                       ` Michael Holzheu
2010-10-11 12:37                         ` Oleg Nesterov
2010-10-12 13:10                           ` Michael Holzheu
2010-10-14 13:47                             ` Oleg Nesterov
2010-10-15 14:34                               ` Michael Holzheu
2010-10-19 14:17                                 ` Oleg Nesterov
2010-10-22 16:53                                   ` Michael Holzheu
2010-09-28  8:36           ` Balbir Singh
2010-09-28  9:08             ` Martin Schwidefsky
2010-09-28  9:23               ` Balbir Singh
2010-09-28 10:36                 ` Martin Schwidefsky
2010-09-28 10:39                   ` Balbir Singh
2010-09-28  8:21   ` Balbir Singh
2010-09-28 16:50     ` Michael Holzheu
2010-09-23 14:04 ` [RFC][PATCH 10/10] taststats: User space with ptop tool Michael Holzheu
2010-09-23 20:11 ` [RFC][PATCH 00/10] taskstats: Enhancements for precise accounting Andrew Morton
2010-09-23 22:11   ` Matt Helsley
2010-09-24 12:39     ` Michael Holzheu
2010-09-25 18:19     ` Serge E. Hallyn
2010-09-24  9:10   ` Michael Holzheu
2010-09-24 18:50     ` Andrew Morton
2010-09-27  9:18       ` Michael Holzheu
2010-09-27 20:02         ` Andrew Morton
2010-09-28  8:17           ` Balbir Singh
2010-09-27 10:49     ` Balbir Singh
2010-09-24  9:16 ` 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=20101011074035.GA17223@balbir.in.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nagar1234@in.ibm.com \
    --cc=oleg@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=venki@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).