lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49B710C4.8040401@cn.fujitsu.com>
Date:	Wed, 11 Mar 2009 09:15:48 +0800
From:	Li Zefan <lizf@...fujitsu.com>
To:	bharata@...ux.vnet.ibm.com
CC:	linux-kernel@...r.kernel.org, Balaji Rao <balajirrao@...il.com>,
	Dhaval Giani <dhaval@...ux.vnet.ibm.com>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	Paul Menage <menage@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Subject: Re: [RFC PATCH] cpuacct: per-cgroup utime/stime statistics - v1

> +static const struct cpuacct_stat_desc {
> +	const char *msg;
> +	u64 unit;
> +} cpuacct_stat_desc[] = {
> +	[CPUACCT_STAT_UTIME] = { "utime", 1, },
> +	[CPUACCT_STAT_STIME] = { "stime", 1, },
> +};
> +

I think we can just remove 'unit'.

> +static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft,
> +		struct cgroup_map_cb *cb)
> +{
> +	struct cpuacct *ca = cgroup_ca(cgrp);
> +	int i;
> +
> +	for (i = 0; i < CPUACCT_STAT_NSTATS; i++) {
> +		s64 val = percpu_counter_read(&ca->cpustat[i]);
> +		val *= cpuacct_stat_desc[i].unit;
> +		cb->fill(cb, cpuacct_stat_desc[i].msg, val);
> +	}
> +	return 0;
> +}
> +
...
> +/*
> + * Account the system/user time to the task's accounting group.
> + */
> +static void cpuacct_update_stats(struct task_struct *tsk,
> +		enum cpuacct_stat_index idx, int val)
> +{
> +	struct cpuacct *ca;
> +
> +	if (!cpuacct_subsys.active)

if (unlikely(!cpuacct_subsys.active)))

> +		return;
> +
> +	ca = task_ca(tsk);
> +
> +	for (; ca; ca = ca->parent)
> +		percpu_counter_add(&ca->cpustat[idx], val);
> +}
> +

We can reduce one NULL check:

do (
	percpu_counter_add();
	ca = ca->parent;
} while (ca);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ