From: Bixuan Cui <cuibixuan@vivo.com>
To: Jonathan Corbet <corbet@lwn.net>,
Chuyi Zhou <zhouchuyi@bytedance.com>,
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
Subject: Re: [RFC PATCH v2 2/5] mm: Add policy_name to identify OOM policies
Date: Thu, 14 Sep 2023 20:04:27 +0800 [thread overview]
Message-ID: <3f7d41bd-ca12-4458-89ba-474d7a4b5bb2@vivo.com> (raw)
In-Reply-To: <87h6p1uz3w.fsf@meer.lwn.net>
在 2023/8/15 4:51, Jonathan Corbet 写道:
>> /**
>> * dump_tasks - dump current memory state of all system tasks
>> * @oc: pointer to struct oom_control
>> @@ -484,8 +513,8 @@ static void dump_oom_summary(struct oom_control *oc, struct task_struct *victim)
>>
>> static void dump_header(struct oom_control *oc, struct task_struct *p)
>> {
>> - pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
>> - current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
>> + pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, policy_name=%s, oom_score_adj=%hd\n",
>> + current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order, oc->policy_name,
> ...and if the policy name is unterminated, this print will run off the
> end of the structure.
>
> Am I missing something here?
Perhaps it is inaccurate to use policy name in this way. For example,
some one use BPF_PROG(bpf_oom_evaluate_task, ...) but do not set the
policy name through bpf_set_policy_name. In this way, the result is
still policy name=default, which ultimately leads to error print in the
dump_header.
I think a better way:
+static const char *const policy_select[] = {
+ "OOM_DEFAULT";
+ "BPF_ABORT",
+ "BPF_NEXT",
+ "BPF_SELECT",
+};
struct oom_control {
/* Used to print the constraint info. */
enum oom_constraint constraint;
+
+ /* Used to report the policy select. */
+ int policy_select;
};
static int oom_evaluate_task(struct task_struct *task, void *arg)
{
...
+ switch (bpf_oom_evaluate_task(task, oc)) {
+ case BPF_EVAL_ABORT:
+ oc->policy_select = BPF_EVAL_ABORT;
+ goto abort; /* abort search process */
+ case BPF_EVAL_NEXT:
+ oc->policy_select = BPF_EVAL_NEXT;
+ goto next; /* ignore the task */
+ case BPF_EVAL_SELECT:
+ oc->policy_select = BPF_EVAL_SELECT;
+ goto select; /* select the task */
+ default:
+ break; /* No BPF policy */
+ }
static void dump_header(struct oom_control *oc, struct task_struct *p)
{
- pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d,
oom_score_adj=%hd\n",
- current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
+ pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d,
policy_name=%s, oom_score_adj=%hd\n",
+ current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
policy_select[oc->policy_select],
current->signal->oom_score_adj);
And all definitions of oc should be added
struct oom_control oc = {
.select = NO_BPF_POLICY,
}
Delete set_oom_policy_name, it makes no sense for users to set policy
names. :-)
Thanks
Bixuan Cui
next prev parent reply other threads:[~2023-09-14 12:04 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
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 [this message]
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=3f7d41bd-ca12-4458-89ba-474d7a4b5bb2@vivo.com \
--to=cuibixuan@vivo.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--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 \
--cc=zhouchuyi@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®