public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Galbraith <efault-Mmb7MZpHnFY@public.gmane.org>
To: Qiang Gao <gaoqiangscut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>,
	Balbir Singh
	<bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	Peter Zijlstra
	<a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org>
Subject: Re: process hangs on do_exit when oom happens
Date: Fri, 26 Oct 2012 13:04:37 -0700	[thread overview]
Message-ID: <1351281877.16639.98.camel@maggy.simpson.net> (raw)
In-Reply-To: <1351270990.16639.92.camel-sZ+7a5bGyC/1wTEvPJ5Q0F6hYfS7NtTn@public.gmane.org>

On Fri, 2012-10-26 at 10:03 -0700, Mike Galbraith wrote:

> The bug is in the patch that used sched_setscheduler_nocheck().  Plain
> sched_setscheduler() would have replied -EGOAWAY.

sched_setscheduler_nocheck() should say go away too methinks.  This
isn't about permissions, it's about not being stupid in general.

sched: fix __sched_setscheduler() RT_GROUP_SCHED conditionals

Remove user and rt_bandwidth_enabled() RT_GROUP_SCHED conditionals in
__sched_setscheduler().  The end result of kernel OR user promoting a
task in a group with zero rt_runtime allocated is the same bad thing,
and throttle switch position matters little.  It's safer to just say
no solely based upon bandwidth existence, may save the user a nasty
surprise if he later flips the throttle switch to 'on'.

The commit below came about due to sched_setscheduler_nocheck()
allowing a task in a task group with zero rt_runtime allocated to
be promoted by the kernel oom logic, thus marooning it forever.

<quote>
commit 341aea2bc48bf652777fb015cc2b3dfa9a451817
Author: KOSAKI Motohiro <kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
Date:   Thu Apr 14 15:22:13 2011 -0700

    oom-kill: remove boost_dying_task_prio()
    
    This is an almost-revert of commit 93b43fa ("oom: give the dying task a
    higher priority").
    
    That commit dramatically improved oom killer logic when a fork-bomb
    occurs.  But I've found that it has nasty corner case.  Now cpu cgroup has
    strange default RT runtime.  It's 0!  That said, if a process under cpu
    cgroup promote RT scheduling class, the process never run at all.
</quote>

Signed-off-by: Mike Galbraith <efault-Mmb7MZpHnFY@public.gmane.org>

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d8927f..d3a35f8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3810,17 +3810,14 @@ recheck:
 	}
 
 #ifdef CONFIG_RT_GROUP_SCHED
-	if (user) {
-		/*
-		 * Do not allow realtime tasks into groups that have no runtime
-		 * assigned.
-		 */
-		if (rt_bandwidth_enabled() && rt_policy(policy) &&
-				task_group(p)->rt_bandwidth.rt_runtime == 0 &&
-				!task_group_is_autogroup(task_group(p))) {
-			task_rq_unlock(rq, p, &flags);
-			return -EPERM;
-		}
+	/*
+	 * Do not allow realtime tasks into groups that have no runtime
+	 * assigned.
+	 */
+	if (rt_policy(policy) && task_group(p)->rt_bandwidth.rt_runtime == 0 &&
+			!task_group_is_autogroup(task_group(p))) {
+		task_rq_unlock(rq, p, &flags);
+		return -EPERM;
 	}
 #endif
 

  parent reply	other threads:[~2012-10-26 20:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 10:23 process hangs on do_exit when oom happens gaoqiang
2012-10-19 16:04 ` Michal Hocko
2012-10-22  2:16   ` Qiang Gao
     [not found]     ` <CAKWKT+Z-SZb1=3rwLm+urs3fghQ3M6pdOR_rzXKCevoad11a5g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-22  5:38       ` Balbir Singh
2012-10-22 13:01     ` Michal Hocko
2012-10-22  4:26   ` Qiang Gao
2012-10-23  3:35   ` Qiang Gao
2012-10-23  4:40     ` Balbir Singh
     [not found]       ` <CAKTCnzkMQQXRdx=ikydsD9Pm3LuRgf45_=m7ozuFmSZyxazXyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-23  7:18         ` Qiang Gao
2012-10-23  9:50           ` Michal Hocko
     [not found]             ` <20121023095028.GD15397-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2012-10-23 10:10               ` Qiang Gao
2012-10-23 10:15                 ` Michal Hocko
2012-10-23 17:43                   ` Balbir Singh
2012-10-24  3:44                     ` Qiang Gao
2012-10-25  9:57                       ` Michal Hocko
2012-10-26  2:42                         ` Qiang Gao
     [not found]                           ` <CAKWKT+ZRTUwer8qhjWGjkra63e10R67UQzezdaCaStz+rvGjxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-26 17:03                             ` Mike Galbraith
     [not found]                               ` <1351270990.16639.92.camel-sZ+7a5bGyC/1wTEvPJ5Q0F6hYfS7NtTn@public.gmane.org>
2012-10-26 20:04                                 ` Mike Galbraith [this message]
2012-10-23  8:35     ` Michal Hocko
2012-10-23  9:08       ` Qiang Gao
2012-10-23  9:43         ` Michal Hocko
     [not found]     ` <CAKWKT+ZRMHzgCLJ1quGnw-_T1b9OboYKnQdRc2_Z=rdU_PFVtw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-23  9:01       ` Sha Zhengju
2012-10-23  9:10         ` Qiang Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351281877.16639.98.camel@maggy.simpson.net \
    --to=efault-mmb7mzphnfy@public.gmane.org \
    --cc=a.p.zijlstra-/NLkJaSkS4VmR6Xm/wNWPw@public.gmane.org \
    --cc=bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gaoqiangscut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox