Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757755Ab0BCWzK (ORCPT ); Wed, 3 Feb 2010 17:55:10 -0500 Received: from cantor.suse.de ([195.135.220.2]:51344 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756402Ab0BCWzF (ORCPT ); Wed, 3 Feb 2010 17:55:05 -0500 From: Lubos Lunak To: David Rientjes Subject: Re: Improving OOM killer Date: Wed, 3 Feb 2010 23:55:01 +0100 User-Agent: KMail/1.9.10 Cc: Balbir Singh , Rik van Riel , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , KOSAKI Motohiro , Nick Piggin , Jiri Kosina References: <201002012302.37380.l.lunak@suse.cz> <20100203170127.GH19641@balbir.in.ibm.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201002032355.01260.l.lunak@suse.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1850 Lines: 56 On Wednesday 03 of February 2010, David Rientjes wrote: > My rewrite for the badness() heuristic is centered on the idea that scores > should range from 0 to 1000, 0 meaning "never kill this task" and 1000 > meaning "kill this task first." The baseline for a thread, p, may be > something like this: > > unsigned int badness(struct task_struct *p, > unsigned long totalram) > { > struct task_struct *child; > struct mm_struct *mm; > int forkcount = 0; > long points; > > task_lock(p); > mm = p->mm; > if (!mm) { > task_unlock(p); > return 0; > } > points = (get_mm_rss(mm) + > get_mm_counter(mm, MM_SWAPENTS)) * 1000 / > totalram; > task_unlock(p); > > list_for_each_entry(child, &p->children, sibling) > /* No lock, child->mm won't be dereferenced */ > if (child->mm && child->mm != mm) > forkcount++; > > /* Forkbombs get penalized 10% of available RAM */ > if (forkcount > 500) > points += 100; As far as I'm concerned, this is a huge improvement over the current code (and, incidentally :), quite close to what I originally wanted). I'd be willing to test it in few real-world desktop cases if you provide a patch. > /* > * /proc/pid/oom_adj ranges from -1000 to +1000 to either > * completely disable oom killing or always prefer it. > */ > points += p->signal->oom_adj; This changes semantics of oom_adj, but given that I expect the above to make oom_adj unnecessary on the desktop for the normal cases, I don't really mind. -- Lubos Lunak openSUSE Boosters team, KDE developer l.lunak@suse.cz , l.lunak@kde.org -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/