linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuyi Zhou <zhouchuyi@bytedance.com>
To: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	muchun.song@linux.dev
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	wuyun.abel@bytedance.com, robin.lu@bytedance.com,
	Chuyi Zhou <zhouchuyi@bytedance.com>
Subject: [RFC PATCH 0/2] mm: Select victim using bpf_select_task
Date: Fri,  4 Aug 2023 17:38:02 +0800	[thread overview]
Message-ID: <20230804093804.47039-1-zhouchuyi@bytedance.com> (raw)

This patchset adds a new interface and use it to select victim when OOM
is invoked. The mainly motivation is the need to customizable OOM victim
selection functionality.

The new interface is a bpf hook plugged in oom_evaluate_task. It takes oc
and current task as parameters and return a result indicating which one is
selected by the attached bpf program.

There are several conserns when designing this interface suggested by
Michal:

1. Hooking into oom_evaluate_task can keep the consistency of global and
memcg OOM interface. Besides, it seems the least disruptive to the existing
oom killer implementation.

2. Userspace can handle a lot on its own and provide the input to the BPF
program to make a decision. Since the oom scope iteration will be
implemented already in the kernel so all the BPF program has to do is to
rank processes or memcgs.

Previous discussion link:
[1]https://lore.kernel.org/lkml/20230727073632.44983-1-zhouchuyi@bytedance.com/

Chuyi Zhou (2):
  mm, oom: Introduce bpf_select_task
  bpf: Add OOM policy test

 mm/oom_kill.c                                 |  57 ++++++-
 .../bpf/prog_tests/test_oom_policy.c          | 140 ++++++++++++++++++
 .../testing/selftests/bpf/progs/oom_policy.c  |  77 ++++++++++
 3 files changed, 267 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/test_oom_policy.c
 create mode 100644 tools/testing/selftests/bpf/progs/oom_policy.c

-- 
2.20.1


             reply	other threads:[~2023-08-04  9:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  9:38 Chuyi Zhou [this message]
2023-08-04  9:38 ` [RFC PATCH 1/2] mm, oom: Introduce bpf_select_task Chuyi Zhou
2023-08-04 11:29   ` Michal Hocko
2023-08-04 13:15     ` Chuyi Zhou
2023-08-04 13:34       ` Michal Hocko
2023-08-07  2:21         ` Chuyi Zhou
2023-08-07  7:04           ` Michal Hocko
2023-08-07 17:28             ` Roman Gushchin
2023-08-08  8:18               ` Michal Hocko
2023-08-08 21:41                 ` Roman Gushchin
2023-08-09  7:53                   ` Michal Hocko
2023-08-10  4:00                     ` Abel Wu
2023-08-15 19:52                       ` Roman Gushchin
2023-08-10 19:41                     ` Martin KaFai Lau
2023-08-15 19:03                       ` Roman Gushchin
2023-08-14 11:25                     ` Chuyi Zhou
2023-08-22 12:42                       ` Michal Hocko
2023-08-04 11:34   ` Alan Maguire
2023-08-04 23:55     ` Chuyi Zhou
2023-08-07  8:32       ` Michal Hocko
2023-08-04  9:38 ` [RFC PATCH 2/2] bpf: Add OOM policy test Chuyi Zhou

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=20230804093804.47039-1-zhouchuyi@bytedance.com \
    --to=zhouchuyi@bytedance.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=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;
as well as URLs for NNTP newsgroup(s).