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:	Fri, 9 Jan 2015 16:54:31 -0800
From:	Cong Wang <xiyou.wangcong@...il.com>
To:	Michal Hocko <mhocko@...e.cz>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Tejun Heo <tj@...nel.org>,
	"\\Rafael J. Wysocki\\" <rjw@...ysocki.net>,
	David Rientjes <rientjes@...gle.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Oleg Nesterov <oleg@...hat.com>, linux-mm@...ck.org,
	LKML <linux-kernel@...r.kernel.org>,
	Linux PM <linux-pm@...r.kernel.org>
Subject: Re: [PATCH -v3 5/5] oom, PM: make OOM detection in the freezer path raceless

On Fri, Jan 9, 2015 at 3:05 AM, Michal Hocko <mhocko@...e.cz> wrote:
>  /**
>   * freeze_processes - Signal user space processes to enter the refrigerator.
>   * The current thread will not be frozen.  The same process that calls
> @@ -142,7 +118,6 @@ static bool check_frozen_processes(void)
>  int freeze_processes(void)
>  {
>         int error;
> -       int oom_kills_saved;
>
>         error = __usermodehelper_disable(UMH_FREEZING);
>         if (error)
> @@ -157,29 +132,22 @@ int freeze_processes(void)
>         pm_wakeup_clear();
>         pr_info("Freezing user space processes ... ");
>         pm_freezing = true;
> -       oom_kills_saved = oom_kills_count();
>         error = try_to_freeze_tasks(true);
>         if (!error) {
>                 __usermodehelper_set_disable_depth(UMH_DISABLED);
> -               oom_killer_disable();
> -
> -               /*
> -                * There might have been an OOM kill while we were
> -                * freezing tasks and the killed task might be still
> -                * on the way out so we have to double check for race.
> -                */
> -               if (oom_kills_count() != oom_kills_saved &&
> -                   !check_frozen_processes()) {
> -                       __usermodehelper_set_disable_depth(UMH_ENABLED);
> -                       pr_cont("OOM in progress.");
> -                       error = -EBUSY;
> -               } else {
> -                       pr_cont("done.");
> -               }
> +               pr_cont("done.");
>         }
>         pr_cont("\n");
>         BUG_ON(in_atomic());
>
> +       /*
> +        * Now that the whole userspace is frozen we need to disbale


disable


> +        * the OOM killer to disallow any further interference with
> +        * killable tasks.
> +        */
> +       if (!error && !oom_killer_disable())
> +               error = -EBUSY;
> +
[...]
>  void unmark_oom_victim(void)
>  {
> -       clear_thread_flag(TIF_MEMDIE);
> +       if (!test_and_clear_thread_flag(TIF_MEMDIE))
> +               return;
> +
> +       down_read(&oom_sem);
> +       /*
> +        * There is no need to signal the lasst oom_victim if there

last

> +        * is nobody who cares.
> +        */
> +       if (!atomic_dec_return(&oom_victims) && oom_killer_disabled)
> +               wake_up_all(&oom_victims_wait);
> +       up_read(&oom_sem);
> +}
[...]
>  /*
>   * The pagefault handler calls here because it is out of memory, so kill a
>   * memory-hogging task.  If any populated zone has ZONE_OOM_LOCKED set, a
> @@ -727,12 +806,25 @@ void pagefault_out_of_memory(void)
>  {
>         struct zonelist *zonelist;
>
> +       down_read(&oom_sem);
>         if (mem_cgroup_oom_synchronize(true))
> -               return;
> +               goto unlock;
>
>         zonelist = node_zonelist(first_memory_node, GFP_KERNEL);
>         if (oom_zonelist_trylock(zonelist, GFP_KERNEL)) {
> -               out_of_memory(NULL, 0, 0, NULL, false);
> +               if (!oom_killer_disabled)
> +                       __out_of_memory(NULL, 0, 0, NULL, false);
> +               else
> +                       /*
> +                        * There shouldn't be any user tasks runable while the

runnable


> +                        * OOM killer is disabled so the current task has to
> +                        * be a racing OOM victim for which oom_killer_disable()
> +                        * is waiting for.
> +                        */
> +                       WARN_ON(test_thread_flag(TIF_MEMDIE));
> +
>                 oom_zonelist_unlock(zonelist, GFP_KERNEL);
>         }
> +unlock:
> +       up_read(&oom_sem);
>  }


Thanks!
--
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