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:	Mon, 30 Jan 2012 17:51:20 -0800
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Anton Vorontsov <anton.vorontsov@...aro.org>
Cc:	Oleg Nesterov <oleg@...hat.com>,
	Arve Hjønnevåg <arve@...roid.com>,
	KOSAKI Motohiro <kosaki.motohiro@...il.com>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	San Mehat <san@...gle.com>, Colin Cross <ccross@...roid.com>,
	linux-kernel@...r.kernel.org, kernel-team@...roid.com,
	linaro-kernel@...ts.linaro.org
Subject: Re: [PATCH 1/3] procfs: Export next_tgid(), move it to kernel/pid.c

Anton Vorontsov <anton.vorontsov@...aro.org> writes:

> On Mon, Jan 30, 2012 at 02:43:12PM +0100, Oleg Nesterov wrote:
>> On 01/30, Anton Vorontsov wrote:
>> >
>> > We'd like to use this function in the android low memory killer driver, so
>> > let's export it.
>> 
>> I guess you mean 3/3.
>> 
>> If lowmem_shrink() can use next_tid() which is not really accurate,
>> then why tou can't simply change it to use rcu_read_lock ?
>
> Yes, in LMK driver we don't need to be accurate. I probably could use
> rcu_read_lock, but the plan was in not holding any global locks (in
> this case the rcu) at all, instead I'd like to hold just a reference
> of the task, which the driver is analyzing at this time. Once we decide
> (to kill or not to kill the task), we either send a signal (and drop
> the reference) or just drop the reference.

rcu_read_lock unless it is implemented wrong is free from a lock
perspective.  rcu_read_lock only touches local state.

>From the look of your loop it already does a walk through the entire
process list so it looks to me like playing games with get_task_struct
and put_task_struct are going to be much more expensive.

proc grabs task references because we can't hold the rcu_read_lock
over a copy_to_user because that is a sleeping function.

You don't call anything that sleeps so rcu_read_lock should be
sufficient.

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