All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: ytk.lee@samsung.com, "mhocko@kernel.org" <mhocko@kernel.org>,
	"mhocko@suse.com" <mhocko@suse.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm, oom_adj: avoid meaningless loop to find processes sharing mm
Date: Mon, 8 Oct 2018 11:52:09 +0900	[thread overview]
Message-ID: <af7ae9c4-d7f1-69af-58fa-ec6949161f5b@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20181008011931epcms1p82dd01b7e5c067ea99946418bc97de46a@epcms1p8>

On 2018/10/08 10:19, Yong-Taek Lee wrote:
> @@ -1056,6 +1056,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
>         struct mm_struct *mm = NULL;
>         struct task_struct *task;
>         int err = 0;
> +       int mm_users = 0;
> 
>         task = get_proc_task(file_inode(file));
>         if (!task)
> @@ -1092,7 +1093,8 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
>                 struct task_struct *p = find_lock_task_mm(task);
> 
>                 if (p) {
> -                       if (atomic_read(&p->mm->mm_users) > 1) {
> +                       mm_users = atomic_read(&p->mm->mm_users);
> +                       if ((mm_users > 1) && (mm_users != get_nr_threads(p))) {

How can this work (even before this patch)? When clone(CLONE_VM without CLONE_THREAD/CLONE_SIGHAND)
is requested, copy_process() calls copy_signal() in order to copy sig->oom_score_adj and
sig->oom_score_adj_min before calling copy_mm() in order to increment mm->mm_users, doesn't it?
Then, we will get two different "struct signal_struct" with different oom_score_adj/oom_score_adj_min
but one "struct mm_struct" shared by two thread groups.

>                                 mm = p->mm;
>                                 atomic_inc(&mm->mm_count);
>                         }


  reply	other threads:[~2018-10-08  2:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181008011931epcms1p82dd01b7e5c067ea99946418bc97de46a@epcms1p8>
2018-10-08  1:19 ` [PATCH] mm, oom_adj: avoid meaningless loop to find processes sharing mm Yong-Taek Lee
2018-10-08  2:52   ` Tetsuo Handa [this message]
     [not found]   ` <CGME20181008011931epcms1p82dd01b7e5c067ea99946418bc97de46a@epcms1p5>
2018-10-08  6:14     ` Yong-Taek Lee
2018-10-08  6:22       ` Tetsuo Handa
     [not found]       ` <CGME20181008011931epcms1p82dd01b7e5c067ea99946418bc97de46a@epcms1p2>
2018-10-08  8:38         ` Yong-Taek Lee
2018-10-08  9:27           ` Tetsuo Handa
2018-10-09  6:35             ` Michal Hocko
2018-10-09  7:50               ` Michal Hocko
2018-10-09 10:00                 ` Tetsuo Handa
2018-10-09 11:10                   ` Michal Hocko
2018-10-09 12:52                     ` Tetsuo Handa
2018-10-09 12:58                       ` Michal Hocko
2018-10-09 13:14                         ` Tetsuo Handa
2018-10-09 13:26                           ` Michal Hocko
2018-10-09 13:51                             ` Tetsuo Handa
2018-10-09 14:09                               ` Michal Hocko
2018-10-09  8:02           ` Michal Hocko
     [not found] <CGME20181005063208epcms1p22959cd2f771ad017996e2b18266791ea@epcms1p2>
2018-10-05  6:32 ` Yong-Taek Lee
2018-10-09  6:23   ` Michal Hocko
2018-10-09  8:03     ` Michal Hocko

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=af7ae9c4-d7f1-69af-58fa-ec6949161f5b@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=ytk.lee@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.