Re: [patch -mm 09/18] oom: add forkbomb penalty to badness heuristic

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

 



> +	list_for_each_entry(child, &tsk->children, sibling) {

this loop only check childs that created by main-thread.
we need to iterate sub-threads created childs.

> +		struct task_cputime task_time;
> +		unsigned long runtime;
> +		unsigned long rss;
> +
> +		task_lock(child);
> +		if (!child->mm || child->mm == tsk->mm) {
> +			task_unlock(child);
> +			continue;
> +		}

need to use find_lock_task_mm().



> +		rss = get_mm_rss(child->mm);

need rss+swap for keeping consistency. I think.

> +		task_unlock(child);
> +
> +		thread_group_cputime(child, &task_time);
> +		runtime = cputime_to_jiffies(task_time.utime) +
> +			  cputime_to_jiffies(task_time.stime);
> +		/*
> +		 * Only threads that have run for less than a second are
> +		 * considered toward the forkbomb penalty, these threads rarely
> +		 * get to execute at all in such cases anyway.
> +		 */
> +		if (runtime < HZ) {
> +			child_rss += rss;
> +			forkcount++;
> +		}
> +	}
> +
> +	return forkcount > sysctl_oom_forkbomb_thres ?
> +				(child_rss / sysctl_oom_forkbomb_thres) : 0;

0 divide risk is there.
correct style is

	thres = sysctl_oom_forkbomb_thres
	if (!thres)
		return;
	child_rss / thres;

copying local variable is must.



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  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]