[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLBrOgeH5T2iXa7nNpHTtQvpzuzfOgEgPQv8T_AKEg6mQ@mail.gmail.com>
Date: Thu, 4 Sep 2025 09:26:45 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Roman Gushchin <roman.gushchin@...ux.dev>
Cc: Tejun Heo <tj@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Kumar Kartikeya Dwivedi <memxor@...il.com>, linux-mm <linux-mm@...ck.org>, bpf <bpf@...r.kernel.org>,
Suren Baghdasaryan <surenb@...gle.com>, Johannes Weiner <hannes@...xchg.org>, Michal Hocko <mhocko@...e.com>,
David Rientjes <rientjes@...gle.com>, Matt Bobrowski <mattbobrowski@...gle.com>,
Song Liu <song@...nel.org>, Alexei Starovoitov <ast@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 01/14] mm: introduce bpf struct ops for OOM handling
On Thu, Sep 4, 2025 at 7:32 AM Roman Gushchin <roman.gushchin@...ux.dev> wrote:
>
> Tejun Heo <tj@...nel.org> writes:
>
> > Hello,
> >
> > On Wed, Sep 03, 2025 at 04:30:16PM -0700, Roman Gushchin wrote:
> > ...
> >> > - I'm passing in cgroup_id as an optional field in struct_ops and then in
> >> > enable path, look up the matching cgroup, verify it can attach there and
> >> > insert and update data structures accordingly:
> >> >
> >> > https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git/tree/kernel/sched/ext.c?h=scx-hier-prototype#n5280
> >>
> >> Yeah, we discussed this option with Martin up in this thread. It doesn't
> >> look as the best possible solution, but maybe the best we have at the moment.
> >>
> >> Ideally, I want something like this:
> >>
> >> void test_oom(void)
> >> {
> >> struct test_oom *skel;
> >> int err, cgroup_fd;
> >>
> >> cgroup_fd = open(...);
> >> if (cgroup_fd < 0)
> >> goto cleanup;
> >>
> >> skel = test_oom__open_and_load();
> >> if (!skel)
> >> goto cleanup;
> >>
> >> err = test_oom__attach_cgroup(skel, cgroup_fd);
> >> if (CHECK_FAIL(err))
> >> goto cleanup;
> >
> > Yeah, that'd look better but are there practical differences? The only one I
> > can think of is fs based permission check but that can be done separately
> > too.
>
> The practical difference is that a single struct ops can be attached
> to multiple cgroups.
+1
Attaching the same scheduler to multiple cgroups also sounds useful.
I feel sched-ext should use cgroup_fd too and do scx_sub_enable() at
attach time instead of load time.
Then scx_sub_disable() can happen at link detach.
Looks more flexible from user pov.
Powered by blists - more mailing lists