From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 47EAF37FF51 for ; Mon, 12 Jan 2026 18:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768242053; cv=none; b=Wfm1mDJ3ieREx5rH8r8aQvhQuZZ2ufr+F//X6L8IcQbduK40BOXAviAYtAJEQ7c1n6e1lz+CX/EpyFX4iQWktSkleAnbU3/3iB7OxUF+rKDysLOnocIJ+VOb20ySjf/0FrbwI/ONYXvIPtjPKxUVXKHN++DjVF5blqYeY90cPhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768242053; c=relaxed/simple; bh=2kDMNGlutLZbBlBwbeCuPsKPzeKjPwdmAr2kRZI8ISk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G+aQlDT9NNzBR7Cp8d0g8UT1/YIr2j//KmHqvgkvzvR20aiIihr2wD4MrsnXgXwgQQ8v5Yjg6+HVCIzP7cwRPzVGX/HQy9FG5y4zXI+mStKc95ZbeO5AtqH55vEFsQUiKsTbz/BoBW43sc6TmHCSidJgKqdGboJxzZQoi4ouT48= 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=qcXi7YaI; arc=none smtp.client-ip=209.85.218.43 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="qcXi7YaI" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-b8719ac9af7so199448866b.0 for ; Mon, 12 Jan 2026 10:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768242051; x=1768846851; 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=8XHGqVtaW8x0Sh1FjZrgxZJsIoNRNYfvhtGoAiQ9Qrc=; b=qcXi7YaI8TqqlD3628ylsT3CVvAt+SCOSI0MjNzZgDhM4FgG2c2V962xOgHX0nOYPG MAq45iYgE8EevBCBaA0uDHRnllUNcSooNFm8IJfp0TG84klkUR4hP034nxmQmgYXxf9R hcu6dkr5j15qfp/OCeOdKRJ2ATu6vG3QhveRkna5Lj2SHLvNVVKJ7l3xjD1znJE94Paf oZtOL4diWOJmN0dSHF/kclchYYjPfhs80Z181R9T+m5yKNqafS4raNv/RlDCKxoiNX4C PsQj1Ei/Uo3MDVUCjvjmIa23b2EbkWZbozT9Pp3t2oVYR8R4dtCQEYmVAavP/QhipYZ3 vr+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768242051; x=1768846851; 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=8XHGqVtaW8x0Sh1FjZrgxZJsIoNRNYfvhtGoAiQ9Qrc=; b=FI4a6nINNJ3sKF1v1zD+ZS05yFLlJTa+kqtWdvv9+qvOgBY6d/BXGpLDHXdDVf5tEm vkZAASAd7JIymv+K7VEHEUMH+S/UHLNhKlVivc2cyKbg9OBdBeCsxE9XwvPEVBaXlths Ld5ww98tiOWcdjbbX2ySMRRfgM5ArkjVteaVU3GRhb1geePIKuCw3BUwv6V5+0yg9bLT QQrgE1S2/NoDpri9tLTFDdeP7egop9Qh/D9AGuhaJ7SfILuOmHR5DzzGrBcAsDn7ALqA S1e9t14KMzz7M+JXNOEUqyMydgvjFhLJMSTNoMvS2YamF14I+CuTss+evKtZxOPzalKk unrA== X-Forwarded-Encrypted: i=1; AJvYcCVNUF+Ec93kncQ1ZgqPkGskLf1zHv/+G6xuDQto31zG1XVMuB4GHWkV4UcQg2KtXJhLwsWnW0crJtr2rII=@vger.kernel.org X-Gm-Message-State: AOJu0YyvW/DpamsPyr9oc7gxZlhXpB1l4Zeyl+Kwt4hG1Dl7DaUlo6T/ CR1ilXlmw9BZs+qeN/t0ssveOCiZWnfifb+Ht6NtObUV+QY6u5HSD47DYOX0Tj9AhQ== X-Gm-Gg: AY/fxX6057tKaeyKaVlzl8TxcWpwS1Og92cNXpYNG6lTIY8puQZrSa6ze+pO11yWgeM MgSQVd0sl1+R1Uuo8FI3l4+pdGK/Tez/64jG81Oq1uULHUw5dWoFiy9cuh67i/H7rozSbjxndTp 4vzbdwpXw2yvw5yW3hrHSQGkuTL/pTivgIjvNAo6rU7cWenqD05kedyCpveRzhbcrmMEZezwFSv GqDtamr8Pyan0vympKHW3g+2tcPuUoi3+HQ8IGLOfeyifqjUHcXT6CwK4ynwL57mGp24ZUCp85O 6nBVnvIKalI2TCDYurK4GcfoMS07Amv0s2HAS8WvyRu0atxQpCtl+Dwa3A5B1UmCBdbV+mo3QjB eEAzQFA3wKGK5WZfT3HL2KpDsJehG+97b/cfaTI5fFEEZ66uidudOXoFSj0i2qCuf1F/EC+hg4A IoZUOYAOVEhxNQ05Xwcfm45S++pXM+EVBRIpwt2D6QWe2xUR2hJ7Z9XvByjwhSlVf6 X-Received: by 2002:a17:906:d553:b0:b87:29ae:2b96 with SMTP id a640c23a62f3a-b87357dbad6mr34509066b.12.1768242050430; Mon, 12 Jan 2026 10:20:50 -0800 (PST) Received: from google.com (14.59.147.34.bc.googleusercontent.com. [34.147.59.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b86f1e95273sm752858966b.62.2026.01.12.10.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 10:20:50 -0800 (PST) Date: Mon, 12 Jan 2026 18:20:46 +0000 From: Matt Bobrowski To: Roman Gushchin Cc: Andrew Morton , linux-kernel@vger.kernel.org, Alexei Starovoitov , Suren Baghdasaryan , Michal Hocko , Shakeel Butt , Johannes Weiner , Andrii Nakryiko , JP Kobryn , linux-mm@kvack.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Kumar Kartikeya Dwivedi , Tejun Heo Subject: Re: [PATCH v2 06/23] mm: introduce BPF struct ops for OOM handling Message-ID: References: <20251027231727.472628-1-roman.gushchin@linux.dev> <20251027231727.472628-7-roman.gushchin@linux.dev> <87ecnusq7m.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=us-ascii Content-Disposition: inline In-Reply-To: <87ecnusq7m.fsf@linux.dev> On Mon, Jan 12, 2026 at 09:20:13AM -0800, Roman Gushchin wrote: > Matt Bobrowski writes: > > > On Mon, Oct 27, 2025 at 04:17:09PM -0700, Roman Gushchin wrote: > >> Introduce a bpf struct ops for implementing custom OOM handling > >> policies. > >> > >> ... > >> > >> +#ifdef CONFIG_MEMCG > >> + /* Find the nearest bpf_oom_ops traversing the cgroup tree upwards */ > >> + for (memcg = oc->memcg; memcg; memcg = parent_mem_cgroup(memcg)) { > >> + bpf_oom_ops = READ_ONCE(memcg->bpf_oom); > >> + if (!bpf_oom_ops) > >> + continue; > >> + > >> + /* Call BPF OOM handler */ > >> + ret = bpf_ops_handle_oom(bpf_oom_ops, memcg, oc); > >> + if (ret && oc->bpf_memory_freed) > >> + goto exit; > > > > I have a question about the semantics of oc->bpf_memory_freed. > > > > Currently, it seems this flag is used to indicate that a BPF OOM > > program has made forward progress by freeing some memory (i.e., > > bpf_oom_kill_process()), but if it's not set, it falls back to the > > default in-kernel OOM killer. > > > > However, what if forward progress in some contexts means not freeing > > memory? For example, in some bespoke container environments, the > > policy might be to catch the OOM event and handle it gracefully by > > raising the memory.limit_in_bytes on the affected memcg. In this kind > > of resizing scenario, no memory would be freed, but the OOM event > > would effectively be resolved. > > I'd say we need to introduce a special kfunc which increases the limit > and sets bpf_memory_freed. I think it's important to maintain safety > guarantee, so that a faulty bpf program is not leading to the system > being deadlocked on memory. Yeah, I was thinking something along the same lines. We can always add this kind of new BPF kfunc in at a later point, so need to directly address this use case right now.