From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (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 C896531A56C for ; Tue, 25 Nov 2025 12:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764072784; cv=none; b=XzfIqhaDXIIsVaCSHuOJom7E/m2pd7URNSJrxkOLEmBVt9pD8O+Nnq168HjJqkulOE9dI8LF/Hflvkx8+mUFXneIV+lSmj2bc+YLMS86HjrP+uqGDG8n7gfL5c7EbEY25Zr2mxQVP4S9CO9jHbedygx5IGFihTuXeISy3q/q/Cg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764072784; c=relaxed/simple; bh=CwP644Bw/wTUEOIYembKp5pq5/shG4Vtk2t3qMFJQFs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JW4KASsUpAk2g9dMUs3gmqKxbLlu8U5EhDwYrdn7O6iHQZTenPvnL6W8imph4FOn0Cb36fSbN/wKNC+GnYhOAP1N6A1cGV1IA43pqwauTpe37el54sA2exdJEYgoiuat3P4MzUFKvVVQN7l0rMIba1ah/bYWM4nBV+q0umRaGRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Lwsxcfxg; arc=none smtp.client-ip=209.85.128.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Lwsxcfxg" Received: by mail-wm1-f68.google.com with SMTP id 5b1f17b1804b1-4779cb0a33fso53038185e9.0 for ; Tue, 25 Nov 2025 04:13:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1764072780; x=1764677580; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=dxJGiJOjFGbJrN6TdFxredys8Cq/gwxxT5DnbpdfeGc=; b=LwsxcfxgEAna6Ht0IsaXQmq96Syh21XGEqBc4biKD4skz9U1lvY8HZRfndWJY/MxVJ Kig7AMZSgv7Rqf8TAxp2SGyUDvEJpTT31OSc+LyMj7NGJf1CqQ0Meh2zRJ8gmGor7QtN VzBml2H7l3hiXSUxPhPNwI7lNIs//xTfZdO//116PpR1rpbaCcKGBs4TiQy0RlfORian Vujjt7ztosBg63wPPZyEu2XcbMXzMxLAj9pONHFQoLqfPNVjCL0Haur9SgiiKJqwESJ/ x3+y4IE12Ori3zag+w7iOMtPN1Xgv3MWabPOkxkVQWxwTwRYozhyVkSHby/1K1pJUmu0 DrVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764072780; x=1764677580; h=in-reply-to:content-transfer-encoding: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=dxJGiJOjFGbJrN6TdFxredys8Cq/gwxxT5DnbpdfeGc=; b=Fk0uhfmxeqo3ZWShEmlP93EtLialMANsWkuD/BCrwVLR5EFa2+b+nSrz8Hd8NWgeoW v2g1GpHjBCc76DLGiiA8foCl6b/QKs2pr4lDzsbUSptkhJx5SX1AS+lfdK/CII/qatAY cIX2AWbUC38m7Ofsv5QlOIXf6iUNsrQ1COfqQyxjAIP4+IHrtl9JiWwciw8Z+yTpVYUx lENEe0pLRrYqz+POFLoL33Usd4qg+Z1/IgXoxURhdkDPGdbNumPtImssrD+oDP4EwcFe O3xPQbQvG0s/ZGkgDuJMS0jvJSfWR8Q+FeKvnr7jRSejOJJ9w0/6wV+9fvn6evaxoEGN Pk6w== X-Forwarded-Encrypted: i=1; AJvYcCWZ8YgAKbKsZHh5P0lIGB7/LNURRIL0XTvJgKU4IahcuzGDi/2ma9yx/uxMMBXc0g0KtbDqxRsCBwc/0Ow=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9p2AwaDQkU3dwddJ/QoK/AD5hWCQd/KvFBdrsSJfXmxuY+yAI xKRHF8SKwuJu8HJAvJS/DvVai2iRSECvscfnSDZ18e3vjpZq6x1V0wbMgABJcIjxqYY= X-Gm-Gg: ASbGncsi4ue+42GToGazlDBcl0HghH3dhMfy/P4rHAJBSKbtxnk7iQf2lOGykg9+HDK kMJEMFl/GTMMsseZObWXHiT4gdsE91pi6leXtGRiOmpe61BVNIeFXLei+JMF3gpSGoMofLMQHsm dDmIWeM51mCQ65a/UGXfkdYu32hvhxefu47R8JniwgzANR6Pw0QfSWYRR1dw9Gbzm4A2BD1fyO7 iy4/Boxv47iEoEz2h9wSEzD7ZawEYWmnLlIwysg0h+dvhV18gQqoeHFhD+KbY2GZuUwbpO7zh1x 1CwRvFc3j3uDkW9RcJkT+pMlY1ivbucZlR2oxACm9qQ8u2RzNga9a89L5fJfEK7nm/o/N59PstO /fnIFAntQc/djofXJMfc7WPHkVWlvWokaLmR26hQI9/AyfeTz6IIKXbTv1NZUFyZXqBXOaYivqH FYDooMm3kflbOQawZF6EOHA2qa X-Google-Smtp-Source: AGHT+IEV2rB8yUe2NCUZIw4moQNsZpTQgAmZgRSSfaXojAIWU3YqaEOZQPUbkzKEE+rrVogbayao5A== X-Received: by 2002:a05:6000:22ca:b0:42b:30a6:9c10 with SMTP id ffacd0b85a97d-42cc1d22e12mr16592650f8f.56.1764072780019; Tue, 25 Nov 2025 04:13:00 -0800 (PST) Received: from localhost (109-81-29-251.rct.o2.cz. [109.81.29.251]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7fa3a81sm34815638f8f.26.2025.11.25.04.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 04:12:59 -0800 (PST) Date: Tue, 25 Nov 2025 13:12:58 +0100 From: Michal Hocko To: hui.zhu@linux.dev Cc: Roman Gushchin , Andrew Morton , Johannes Weiner , Shakeel Butt , Muchun Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Peter Zijlstra , Miguel Ojeda , Nathan Chancellor , Kees Cook , Tejun Heo , Jeff Xu , mkoutny@suse.com, Jan Hendrik Farr , Christian Brauner , Randy Dunlap , Brian Gerst , Masahiro Yamada , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Hui Zhu Subject: Re: [RFC PATCH 0/3] Memory Controller eBPF support Message-ID: References: <87ldk1mmk3.fsf@linux.dev> <895f996653b3385e72763d5b35ccd993b07c6125@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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri 21-11-25 02:46:31, hui.zhu@linux.dev wrote: > 2025年11月21日 03:20, "Michal Hocko" 写到: > > > > > > On Thu 20-11-25 09:29:52, hui.zhu@linux.dev wrote: > > [...] > > > > > > > > I generally agree with an idea to use BPF for various memcg-related > > > policies, but I'm not sure how specific callbacks can be used in > > > practice. > > > > > > Hi Roman, > > > > > > Following are some ideas that can use ebpf memcg: > > > > > > Priority‑Based Reclaim and Limits in Multi‑Tenant Environments: > > > On a single machine with multiple tenants / namespaces / containers, > > > under memory pressure it’s hard to decide “who should be squeezed first” > > > with static policies baked into the kernel. > > > Assign a BPF profile to each tenant’s memcg: > > > Under high global pressure, BPF can decide: > > > Which memcgs’ memory.high should be raised (delaying reclaim), > > > Which memcgs should be scanned and reclaimed more aggressively. > > > > > > Online Profiling / Diagnosing Memory Hotspots: > > > A cgroup’s memory keeps growing, but without patching the kernel it’s > > > difficult to obtain fine‑grained information. > > > Attach BPF to the memcg charge/uncharge path: > > > Record large allocations (greater than N KB) with call stacks and > > > owning file/module, and send them to user space via a BPF ring buffer. > > > Based on sampled data, generate: > > > “Top N memory allocation stacks in this container over the last 10 minutes,” > > > Reports of which objects / call paths are growing fastest. > > > This makes it possible to pinpoint the root cause of host memory > > > anomalies without changing application code, which is very useful > > > in operations/ops scenarios. > > > > > > SLO‑Driven Auto Throttling / Scale‑In/Out Signals: > > > Use eBPF to observe memory usage slope, frequent reclaim, > > > or near‑OOM behavior within a memcg. > > > When it decides “OOM is imminent,” instead of just killing/raising > > > limits, it can emit a signal to a control‑plane component. > > > For example, send an event to a user‑space agent to trigger > > > automatic scaling, QPS adjustment, or throttling. > > > > > > Prevent a cgroup from launching a large‑scale fork+malloc attack: > > > BPF checks per‑uid or per‑cgroup allocation behavior over the > > > last few seconds during memcg charge. > > > > > AFAIU, these are just very high level ideas rather than anything you are > > trying to target with this patch series, right? > > > > All I can see is that you add a reclaim hook but it is not really clear > > to me how feasible it is to actually implement a real memory reclaim > > strategy this way. > > > > In prinicipal I am not really opposed but the memory reclaim process is > > rather involved process and I would really like to see there is > > something real to be done without exporting all the MM code to BPF for > > any practical use. Is there any POC out there? > > Hi Michal, > > I apologize for not delivering a more substantial POC. > > I was hesitant to add extensive eBPF support to memcg > because I wasn't certain it aligned with the community's > vision—and such support would require introducing many > eBPF hooks into memcg. > > I will add more eBPF hook to memcg and provide a more > meaningful POC in the next version. Just to make sure we are on the same page. I am not suggesting we need more of those hooks. I just want to see how many do we really need in order to have a sensible eBPF driven reclaim policy which seems to be the main usecase you want to puruse, right? -- Michal Hocko SUSE Labs