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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 Sep 2010 19:10:25 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Michael Holzheu <holzheu@...ux.vnet.ibm.com>
Cc:	Shailabh Nagar <nagar1234@...ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Venkatesh Pallipadi <venki@...gle.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Suresh Siddha <suresh.b.siddha@...el.com>,
	John stultz <johnstul@...ibm.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	Ingo Molnar <mingo@...e.hu>,
	Heiko Carstens <heiko.carstens@...ibm.com>,
	Martin Schwidefsky <schwidefsky@...ibm.com>,
	linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH 09/10] taskstats: Fix exit CPU time accounting

Sorry, I didn't look at other patches, but this one looks strange
to me...

On 09/23, Michael Holzheu wrote:
>
> Currently there are code pathes (e.g. for kthreads) where the consumed
> CPU time is not accounted to the parents cumulative counters.

Could you explain more?

> +static void account_to_parent(struct task_struct *p)
> +{
> +	struct signal_struct *psig, *sig;
> +	struct task_struct *tsk_parent;
> +
> +	read_lock(&tasklist_lock);

No need to take tasklist, you can use rcu_read_lock() if you need
get_task_struct(). But this can't help, please see below.

> +	tsk_parent = p->real_parent;
> +	if (!tsk_parent) {
> +		read_unlock(&tasklist_lock);
> +		return;
> +	}
> +	get_task_struct(tsk_parent);
> +	read_unlock(&tasklist_lock);
> +
> +	// printk("XXX Fix accounting: pid=%d ppid=%d\n", p->pid, tsk_parent->pid);
> +	spin_lock_irq(&tsk_parent->sighand->siglock);

This is racy. ->real_parent can exit after we drop tasklist_lock,
->sighand can be NULL.

>  void release_task(struct task_struct * p)
>  {
>  	struct task_struct *leader;
>  	int zap_leader;
> +
> +	if (!p->exit_accounting_done)
> +		account_to_parent(p);
>  repeat:
>  	tracehook_prepare_release_task(p);
>  	/* don't need to get the RCU readlock here - the process is dead and
> @@ -1279,6 +1313,7 @@
>  			psig->cmaxrss = maxrss;
>  		task_io_accounting_add(&psig->ioac, &p->ioac);
>  		task_io_accounting_add(&psig->ioac, &sig->ioac);
> +		p->exit_accounting_done = 1;

Can't understand.

Suppose that a thread T exits and reaps itself (calls release_task).
Now we call account_to_parent() which accounts T->signal->XXX + T->XXX.
After that T calls __exit_signal and does T->signal->XXX += T->XXX.

If another thread exits it does the same and we account the already
exited thread T again?

When the last thread exits, wait_task_zombie() accounts T->signal
once again.

IOW, this looks like the over-accounting to me, no?

Oleg.

--
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