Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michal Hocko wrote:
> +bool task_has_external_users(struct task_struct *p)
> +{
> +	struct mm_struct *mm = NULL;
> +	struct task_struct *t;
> +	int active_threads = 0;
> +	bool ret = true;	/* be pessimistic */
> +
> +	rcu_read_lock();
> +	for_each_thread(p, t) {
> +		task_lock(t);
> +		if (likely(t->mm)) {
> +			active_threads++;
> +			if (!mm) {
> +				mm = t->mm;
> +				atomic_inc(&mm->mm_count);
> +			}
> +		}
> +		task_unlock(t);
> +	}
> +	rcu_read_unlock();
> +

I don't like this. We might sleep here long enough to change mm_users.

> +	if (mm) {
> +		if (atomic_read(&mm->mm_users) <= active_threads)
> +			ret = false;
> +		mmdrop(mm);
> +	}
> +	return ret;
> +}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]