From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 EC87827FD5D for ; Thu, 20 Nov 2025 19:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763666424; cv=none; b=FD2A3HMLl9nHDN9HJmUBJHRtn9O8hqkVqynG9QeLECsn8PlG9BiiYtWR0q6kjmHcs68SIGB26Ifw4H0DOLuiy8JfZuXIgjYv4/RO1RDTSv+fq71+y/A0LSsiHW9L0M64vUpHrWDPCyOOM0/YaX0p7/nSc3gUvAdxY/ciFIcqDI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763666424; c=relaxed/simple; bh=AaCcqFGlaMkBKinMgcJOTsQZe0To9vv4Dqsh7zVA0tk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aDivkqXXHQpkj0E4DminBrezszhuLm/pQqENrDfWNSL3oEsUa5nT1T5FSsrdeM2ZLuUoLYA0XVT2obU2MZzOB2HPSwU/xz1Qy9/HYSSVf0FDqvbSHhks7+Ex3F5CfH/aA1noPHrluSCkTNa+FAAN5FmMoAQWzRDyxDaf8FekxZo= 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=c6qGKiCC; arc=none smtp.client-ip=209.85.221.45 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="c6qGKiCC" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-42b3b0d76fcso701068f8f.3 for ; Thu, 20 Nov 2025 11:20:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1763666420; x=1764271220; 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=1GdkfT+k3vOqAIJe3mmQZm2FSZ3v5dOxrZlq1SxHp5k=; b=c6qGKiCCqVGjbVCF3KPrM8v17KfcDRCjANlVnpv3vnsNhSl5fK8MLoVc+YvU9JLjyC aHEGZyboEx2KYcfxE/3eQ+82zxQC9pSxwwnIv/j2mITLr+VDioC0kNk92RRHFneto+AO KzJ04xEvX1xcsUiHBOZ80r8Cd0K+JwsaIn704XiLROJKjqvLwy/I41nIY6aKuhQeRTcr EoWeD8aPvIIpkJYwobikIjMoW/byJ4lPJAtROwlVmhsSoY2naJv4MCAZSLro02igbfbb rPPAjrHUpFAwuJhEFhkmC9TCo+7I8Mv4/vwcuyOZepdIVMa3eC0gpj5odgydgsgJB9OL pFMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763666420; x=1764271220; 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=1GdkfT+k3vOqAIJe3mmQZm2FSZ3v5dOxrZlq1SxHp5k=; b=clHo/YKKuOwNmGjKVuFl3Dy7w/f6GdVP1+Ie65MV5u8HDLbnggblobCsctHePuJ3ip U9KzZ4dK4uidU3bdSJXc4dvBTEGaawkrZzb60Rq4L9k9m/RbqolVZS/KC4Mis7Ob4fc0 fiooxKQJqqe3VqZZ8qHOA/heG3W7xI2/Q6l8O6r5z3Xbd4BSTMEGjWHO5Kk+6ABNSEdz H3hmqJoTv21rvf1fspeKJ0EsDUXr1iB7NbxuuwRhTXvzfj1nJn8Nsx/Y2b9eRwa5VhUx T/f6cWWWLslOQAsspo9AFON3F/3L3xoOR57SskvYZaeM8c3dXNNryGUasJVXUSfgkDal kdLw== X-Forwarded-Encrypted: i=1; AJvYcCUgWf3tvlAryOS4YK0VunuQ0cUbPg+fZf/xdGFTIJJ74XgRMaghglIFyfhNjFKqDzzAOqcGeuafSNKNUZs=@vger.kernel.org X-Gm-Message-State: AOJu0Yww45y0Vn+N/HPR+2P76V3GvURN6oxoNFNxFKNuwhUfii+ZY+Jl oPr9T9uiqfoCOBg6FwCxwS3y2UAFV4Quwtl0AckUxvd0R8UVsst2zKHQQxRGVYam4g8= X-Gm-Gg: ASbGncskZ45Wze6pr8yY/wz01ds3fF9/4W3GTyP5k/ZFHXTZQoEW14jDu4U04qufjm3 HgCCHE43+8VVkpsxP6DskQLdYxAb15fpfwBpehuJhFwFVtR7YfT5RkdlIfXE4cwms6a+YXuAAqQ Bk4YbanEEih4xU9U/xYBc4Myu+RM25K3jdmuzbsASo1vHmnXygLs4aN5moZASlAotrYTjx5X8Vu h33xIMGdu48rcceCCQ16xtnXtdZ5lmCaJz7d5uXTOgnUYJIS4BTQVY7FsqoaRhYkKppn5dkNoIP T7EhL9Nj9V2K1KOjG4i4HIDyP/h8Zu7aOOjMyADchpTOO20Kcj89nYROQaSvBZFn4I1eV9Q9Dhs YzoNbuaacFX4mpRbj3s6/i2uWlk+ypWCjPjuLSSGQlyKgvNSQUaUMW2cMV/N8MV1/Tu3dI4Ilgp OX/D8XWxd1GBSbo6cXFimqXyyA X-Google-Smtp-Source: AGHT+IGAoi9mcb2Ki+Vf2x8GF9MIVNCxw9/ODHm+fzM81xCrrAi2YNRfJaEumj8/F5Vldpj31JhIrw== X-Received: by 2002:a5d:5f50:0:b0:42b:5628:f4a3 with SMTP id ffacd0b85a97d-42cb9a0d86bmr4652179f8f.1.1763666420131; Thu, 20 Nov 2025 11:20:20 -0800 (PST) Received: from localhost (109-81-31-109.rct.o2.cz. [109.81.31.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7fa41d2sm6785593f8f.22.2025.11.20.11.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 11:20:19 -0800 (PST) Date: Thu, 20 Nov 2025 20:20:18 +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: <895f996653b3385e72763d5b35ccd993b07c6125@linux.dev> 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? -- Michal Hocko SUSE Labs