mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuyi Zhou <zhouchuyi@bytedance.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	muchun.song@linux.dev, bpf <bpf@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	wuyun.abel@bytedance.com, robin.lu@bytedance.com,
	Michal Hocko <mhocko@suse.com>
Subject: Re: [RFC PATCH v2 1/5] mm, oom: Introduce bpf_oom_evaluate_task
Date: Thu, 17 Aug 2023 10:51:19 +0800	[thread overview]
Message-ID: <93627e45-dc67-fd31-ef43-a93f580b0d6e@bytedance.com> (raw)
In-Reply-To: <CAADnVQK=7NWbRtJyRJAqy5JwZHRB7s7hCNeGqixjLa4vB609XQ@mail.gmail.com>

Hello,

在 2023/8/17 10:07, Alexei Starovoitov 写道:
> On Thu, Aug 10, 2023 at 1:13 AM Chuyi Zhou <zhouchuyi@bytedance.com> wrote:
>>   static int oom_evaluate_task(struct task_struct *task, void *arg)
>>   {
>>          struct oom_control *oc = arg;
>> @@ -317,6 +339,26 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
>>          if (!is_memcg_oom(oc) && !oom_cpuset_eligible(task, oc))
>>                  goto next;
>>
>> +       /*
>> +        * If task is allocating a lot of memory and has been marked to be
>> +        * killed first if it triggers an oom, then select it.
>> +        */
>> +       if (oom_task_origin(task)) {
>> +               points = LONG_MAX;
>> +               goto select;
>> +       }
>> +
>> +       switch (bpf_oom_evaluate_task(task, oc)) {
>> +       case BPF_EVAL_ABORT:
>> +               goto abort; /* abort search process */
>> +       case BPF_EVAL_NEXT:
>> +               goto next; /* ignore the task */
>> +       case BPF_EVAL_SELECT:
>> +               goto select; /* select the task */
>> +       default:
>> +               break; /* No BPF policy */
>> +       }
>> +
> 
> I think forcing bpf prog to look at every task is going to be limiting
> long term.
> It's more flexible to invoke bpf prog from out_of_memory()
> and if it doesn't choose a task then fallback to select_bad_process().
> I believe that's what Roman was proposing.
> bpf can choose to iterate memcg or it might have some side knowledge
> that there are processes that can be set as oc->chosen right away,
> so it can skip the iteration.

IIUC, We may need some new bpf features if we want to iterating 
tasks/memcg in BPF, sush as:
bpf_for_each_task
bpf_for_each_memcg
bpf_for_each_task_in_memcg
...

It seems we have some work to do first in the BPF side.
Will these iterating features be useful in other BPF scenario except OOM 
Policy?

Thanks.

  reply	other threads:[~2023-08-17  2:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  8:13 [RFC PATCH v2 0/5] mm: Select victim using bpf_oom_evaluate_task Chuyi Zhou
2023-08-10  8:13 ` [RFC PATCH v2 1/5] mm, oom: Introduce bpf_oom_evaluate_task Chuyi Zhou
2023-08-17  2:07   ` Alexei Starovoitov
2023-08-17  2:51     ` Chuyi Zhou [this message]
2023-08-17  3:22       ` Alexei Starovoitov
2023-08-18  3:30         ` Chuyi Zhou
2023-08-18  4:34           ` Alexei Starovoitov
2023-08-22 10:39     ` Michal Hocko
2023-09-13  1:18   ` Bixuan Cui
2023-09-13  8:00     ` Chuyi Zhou
2023-09-13 11:24   ` Bixuan Cui
2023-08-10  8:13 ` [RFC PATCH v2 2/5] mm: Add policy_name to identify OOM policies Chuyi Zhou
2023-08-14 20:51   ` Jonathan Corbet
2023-08-15  2:28     ` Chuyi Zhou
2023-09-14 12:02     ` Bixuan Cui
2023-09-14 12:50       ` [External] " Chuyi Zhou
2023-09-15  2:28         ` Bixuan Cui
2023-09-15  3:31           ` Chuyi Zhou
2023-09-14 12:04     ` Bixuan Cui
2023-08-10  8:13 ` [RFC PATCH v2 3/5] mm: Add a tracepoint when OOM victim selection is failed Chuyi Zhou
2023-08-16 11:54   ` Alan Maguire
2023-08-10  8:13 ` [RFC PATCH v2 4/5] bpf: Add a OOM policy test Chuyi Zhou
2023-08-16 11:53   ` Alan Maguire
2023-08-16 12:31     ` Chuyi Zhou
2023-08-16 13:49       ` Alan Maguire
2023-08-16 14:34         ` Chuyi Zhou
2023-09-28 11:35           ` Charlley Green
2023-09-13  7:55   ` Bixuan Cui
2023-08-10  8:13 ` [RFC PATCH v2 5/5] bpf: Add a BPF OOM policy Doc Chuyi Zhou
2023-08-16 15:49 ` [PATCH RFC v2 0/5] mm: Select victim using bpf_oom_evaluate_task Yosry Ahmed

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=93627e45-dc67-fd31-ef43-a93f580b0d6e@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=robin.lu@bytedance.com \
    --cc=roman.gushchin@linux.dev \
    --cc=wuyun.abel@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®