From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6195E1DF75D for ; Wed, 8 Oct 2025 17:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759942964; cv=none; b=GmCQZAB//1nfXStIQkypjeXOo3tEErhsFLbpuvw/Hn18uiibfSIJFHybGu4I6+4C2egj3xl4k+MT6uYPcuXdE6575Ny83MgpUeDY5FyPInFXXISxfjtDbnVMqoKksXsshDSmsIwOqCo4t/sMBZPrzrvWqJKUMGhedJR1MkBofkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759942964; c=relaxed/simple; bh=BODKjR/Yrua4uagxV7JAKQu5Y6484FclXcvnVtP0Ids=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=f6vHo1raL7wwuR9s5XM7Se3MrFOIbQhqNi9kMue+bZAI3Nokw/4g3dUWjKsTBAToTRytLmPIFV0K8XXi9HS78owZSce7Kv20IM2sHGQMOGAMbVplXzjn25mSTJTPUUqqUP0T83TsoUMg8QR1ffKHRf5RXIxX5m980fqfq6pumxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ImEtogTh; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ImEtogTh" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1759942960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BODKjR/Yrua4uagxV7JAKQu5Y6484FclXcvnVtP0Ids=; b=ImEtogTh0Qu0BQbbsIQhE3xhi2kpV56iAk7nUKH+E+BrfzLTe1IFnAs1u2nKXZ4WwXK+rP N4Qk9gMKmXy+ZNj+q5FZFsQxoYmLp0idznsWNAYeTnVwQAUsZ+z4suI0RtYA3ZrCJZnGqD 4lTBro4kASUXODnrVr2/PzmbAiart0s= From: Roman Gushchin To: Song Liu Cc: Song Liu , Andrii Nakryiko , Martin KaFai Lau , Alexei Starovoitov , Kumar Kartikeya Dwivedi , linux-mm , bpf , Suren Baghdasaryan , Johannes Weiner , Michal Hocko , David Rientjes , Matt Bobrowski , Alexei Starovoitov , Andrew Morton , LKML Subject: Re: [PATCH v1 01/14] mm: introduce bpf struct ops for OOM handling In-Reply-To: (Song Liu's message of "Wed, 8 Oct 2025 00:03:37 -0700") References: <20250818170136.209169-1-roman.gushchin@linux.dev> <20250818170136.209169-2-roman.gushchin@linux.dev> <87ms7tldwo.fsf@linux.dev> <1f2711b1-d809-4063-804b-7b2a3c8d933e@linux.dev> <87wm6rwd4d.fsf@linux.dev> <87iki0n4lm.fsf@linux.dev> <877bxb77eh.fsf@linux.dev> <871pnfk2px.fsf@linux.dev> <87tt0bfsq7.fsf@linux.dev> <87playf8ab.fsf@linux.dev> Date: Wed, 08 Oct 2025 10:02:28 -0700 Message-ID: <871pnd2uor.fsf@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Song Liu writes: > On Tue, Oct 7, 2025 at 7:15=E2=80=AFPM Roman Gushchin wrote: > [...] >> > >> > I am not sure what is the best option for cgroup oom killer. There >> > are multiple options. Technically, it can even be a sysfs entry. >> > We can use it as: >> > >> > # load and pin oom killers first >> > $ cat /sys/fs/cgroup/user.slice/oom.killer >> > [oom_a] oom_b oom_c >> > $ echo oom_b > /sys/fs/cgroup/user.slice/oom.killer >> > $ cat /sys/fs/cgroup/user.slice/oom.killer >> > oom_a [oom_b] oom_c >> >> It actually looks nice! >> But I expect that most users of bpf_oom won't use it directly, >> but through some sort of middleware (e.g. systemd), so Idk if >> such a user-oriented interface makes a lot of sense. >> >> > Note that, I am not proposing to use sysfs entries for oom killer. >> > I just want to say it is an option. >> > >> > Given attach() can be implemented in different ways, we probably >> > don't need to add it to bpf_struct_ops. But if that turns out to be >> > the best option, I would not argue against it. OTOH, I think it is >> > better to keep reg() and attach() separate, though sched_ext is >> > using reg() for both options. >> >> I'm inclining towards a similar approach, except that I don't want >> to embed cgroup_id into the struct_ops, but keep it in the link, >> as Martin suggested. But I need to implement it end-to-end before I can >> be sure that it's the best option. Working on it... > > If we add cgroup_id to the link, I guess this means we need the link > (some fd in user space) to hold reference on the attachment of this > oom struct_ops on this is cgroup. Do we also need this link to hold > a reference on the cgroup? Not necessarily. I agree that the struct_ops should not hold a reference to the cgroup, it's better to do the opposite. This is why the link can have cgroup_id, not cgroup pointer. I think it's similar to Tejun's approach to embed cgroup_id into the struct ops, but potentially more flexible. Thanks!