From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073601DC9B3 for ; Mon, 2 Feb 2026 05:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770010796; cv=none; b=J2CexhLLINcdgl0aseIq40+4DWxwc2ihWuJsNkDztDtcv2hhadUrhpF5jl+fUju1nG9Fn4T0UlZ+szHzh3Dyok2RZ6iFb6VE6wGLSwmayHlK0Q9a0Rhn7fcU2VIGXpXrVyuQqLA6KttWenweNqoMPrxKP8T9UN33ieVoq0C1rYE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770010796; c=relaxed/simple; bh=cXdg5YoGsJVjjvtwqrLiUIW+CK4LXMS0mPg91TTgNsw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SfLMFB63jABZnjIk2d1x7G6dTbAgWf9UYkfpaZaiWCurhWRK6BB/gvM/lDwM0+0NtSohmwqQKbTUCYYRKw28HSyMZCIprq39KNdgGSqm/y9k/SxTDfCKt6+cAHTlz43EQLe5dBC9nXdW6bVSBSIQW4xP+MF9sK7zYGwCMn8E51s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tQmu5Ifm; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tQmu5Ifm" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-b8876d1a39bso572896966b.1 for ; Sun, 01 Feb 2026 21:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770010793; x=1770615593; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oQHxYYh/oaSmYIKd15e37VDf14jUNP+IN3jHPHFgtg4=; b=tQmu5Ifm34sayGchBEo+KFQTDvp7mUzbMKz/Y0+Bgwk66scgAJPdvrS1uCBLQ+soG3 jUHSk37X33KL8mREqSfvCJ78Ixi/8xaiIzFxFYIE37mKCZawzfYV5gI7OEyz+4RVGrRS KPnhA3UP/1UB8gxvisZwGFoW1t7vpJz/mI+IiYyF6xvSzu0fHg4UWUSn7/QJ5Z+J/eqk MrkxjL3kzYgWZHRdUtatDpV/uw+gbkGxBr1JBYuegyEP94Hy+i3REfkUSQlELBSujAVc pFZpc4O7oy38Ic3/KUoJAEyogEh1BDirfNX8Jd4kYzaFYqzrvk0ejBQcYhpNf5V9CNKx frYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770010793; x=1770615593; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oQHxYYh/oaSmYIKd15e37VDf14jUNP+IN3jHPHFgtg4=; b=UuYxl0UZ6qwylTkyyPe+hvI2850z7+tZiE8ELW6AU28WfrNqVYTRHA9LfUba1aYznA W/+vFrqUbxbJTuJYkBTles7J1lNGbDtvFPqY8HCzpDWmtpdGlU6AXGL1HD021tWW0/OS bPUVwbO3Yop/1Rmdmal+zdq3HAkDGqJtpqehJeallZVdc+GkoJMSIuF+nQGy/I8hitXa 0gJ4f1gA4P3AJmEsMs8hTZyKsHkiuewep/6mll2eIuqudHKdoPa2MeP3SuSSZB9mVHQf QoMuqleX00pYM1dZv1M4WAR0zmEbuaiNeoFpx0LIM6OQGGZ8TNqobTGGLyVn5d+o1NXM +thQ== X-Forwarded-Encrypted: i=1; AJvYcCUhZVEu59LgkqbZHzdGadnrl4sF6vNcO5MivyQ/0wCai/vjaaZ+sZkcbiyxHOqLIBWeyiGtXrBuE8oB9V0=@vger.kernel.org X-Gm-Message-State: AOJu0YyYeBheViT9LVoeR42YEChOy9KN/1px/jACecksr/kOB7wTT+Yy KUWCym8X2q3kBU+eRnDaB0gWRCcZAU/eL1B6RmXU+9Q5HS2Y7ATeksqJ5sAXV2s5Yk0Ft+HcPi+ 07p5ChA== X-Gm-Gg: AZuq6aJZxmUdVMhENyABTxbbZpH2C06xj4VyWgm9KE6V5ypKz1Xz0yqxRBbn+tw0KGS +dppQUoCMj2nYGry/yLjLasfh1p5lByAYOgTwIt8vJIQCAiUNHP1EBlt3XCETBbhG1aU3FD9KFF DCpIT+cBFfKtwyVqh2NXxu0BvfZPJwjdJxybUjhSPsHYbHwNc0CGj4rQf/4D89aN0W/4s3cEhrT Aw8upY3HeDWSLZlEE6w8wpHRGWpwglTPYVVzOsOj2Cr2YrypPusyR4rCgvsjoKslbM1cO0c2lR1 axrZomgReEB075/AS54JqCiJaMlkQ8krD1963GSCHeuyBTASDJHaBdaoohK6cRpKegv7kX+WuWM 3FZ9cTU2A8pLdW52/DGZQBU204edIfgLWKcRzMbEpsEZOW+HiPXil0bUffM0Y2YrSzy7M20Ksqa 66KzR5VbDG4ezrhfs609uRTpBesiWlJ7ia+gxCaHa7piuDl1bD0jU= X-Received: by 2002:a17:907:846:b0:b7d:1cbb:5deb with SMTP id a640c23a62f3a-b8dff5bfd66mr624231366b.27.1770010793134; Sun, 01 Feb 2026 21:39:53 -0800 (PST) Received: from google.com (93.50.90.34.bc.googleusercontent.com. [34.90.50.93]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-658b4691d0asm7521455a12.18.2026.02.01.21.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Feb 2026 21:39:52 -0800 (PST) Date: Mon, 2 Feb 2026 05:39:48 +0000 From: Matt Bobrowski To: Roman Gushchin Cc: bpf@vger.kernel.org, Michal Hocko , Alexei Starovoitov , Shakeel Butt , JP Kobryn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Suren Baghdasaryan , Johannes Weiner , Andrew Morton Subject: Re: [PATCH bpf-next v3 10/17] mm: introduce bpf_task_is_oom_victim() kfunc Message-ID: References: <20260127024421.494929-1-roman.gushchin@linux.dev> <20260127024421.494929-11-roman.gushchin@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=us-ascii Content-Disposition: inline In-Reply-To: <20260127024421.494929-11-roman.gushchin@linux.dev> On Mon, Jan 26, 2026 at 06:44:13PM -0800, Roman Gushchin wrote: > Export tsk_is_oom_victim() helper as a BPF kfunc. > It's very useful to avoid redundant oom kills. > > Signed-off-by: Roman Gushchin > Suggested-by: Michal Hocko > --- > mm/oom_kill.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index 8f63a370b8f5..53f9f9674658 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -1381,10 +1381,24 @@ __bpf_kfunc int bpf_out_of_memory(struct mem_cgroup *memcg__nullable, > return ret; > } > > +/** > + * bpf_task_is_oom_victim - Check if the task has been marked as an OOM victim > + * @task: task to check > + * > + * Returns true if the task has been previously selected by the OOM killer > + * to be killed. It's expected that the task will be destroyed soon and some > + * memory will be freed, so maybe no additional actions required. > + */ > +__bpf_kfunc bool bpf_task_is_oom_victim(struct task_struct *task) > +{ > + return tsk_is_oom_victim(task); > +} Why not just do a direct memory read (i.e., task->signal->oom_mm) within the BPF program? I'm not quite convinced that a BPF kfunc wrapper for something like tsk_is_oom_victim() is warranted as you can literally achieve the same semantics without one.