From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 9DE5330F556 for ; Mon, 22 Dec 2025 22:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766441895; cv=none; b=NLJ+10myEMSQxsnqN1F054QaaEZDWJ6KVB44pS5q/He3UiQUMnDqPqMPpjA37G0IfM8qCxZW6jv5r5M6a3sQ7BbB/nkVYFqaRTDHDd7TJ2gJz5QUzggtOY1IZC8PqiPaT0GYU+LiEn9b0Gx3W1lnJ+CXILbFnmw/AIurpe2A59E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766441895; c=relaxed/simple; bh=MKaruFJAvzdF39BSq94DdIWjqCtHP58kdaPWUeGyaBY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dvcYivq/2w/T/bRu1SrxBzqdGumcDoKBTuvgbQiFl4LRMq0qQ0svFri9tqHqcifj+24RWrQ3MjpMqKzluChcQu3BUovMkcVll+DPNPgcpzOHxF3VwYau0JDCN49mWhiu1ki8B99wjVxWCJCsiLx3onLLmwIGHm2rBFb9f7JdYrQ= 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=Y2Gmn3ya; arc=none smtp.client-ip=95.215.58.170 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="Y2Gmn3ya" 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=1766441881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vsKpZybnVUvHz7hRUHCLmAtPAg5RYYwFpvXRG+uP0Po=; b=Y2Gmn3yaC40doAZ2YzgTJWK4Mk9JL7G8CzvInTpsFB2aqOmm1KsS/tqmTVGecBk8Bff1P/ 5n8hPp7s42NdiGMj8CjJwdsgmwJfA4m70E5g7xBd5DqoclmMy3aPxSMO6DL7UBg/Opkfp4 QxnhCaTKiuiOojudbnzJTYAH/u+nrSw= From: Roman Gushchin To: bpf@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: JP Kobryn , Alexei Starovoitov , Daniel Borkmann , Shakeel Butt , Michal Hocko , Johannes Weiner , Roman Gushchin Subject: [PATCH bpf-next v3 0/6] mm: bpf kfuncs to access memcg data Date: Mon, 22 Dec 2025 14:17:48 -0800 Message-ID: <20251222221754.186191-1-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-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Introduce kfuncs to simplify the access to the memcg data. These kfuncs can be used to accelerate monitoring use cases and for implementing custom OOM policies once BPF OOM is landed. This patchset was separated out from the BPF OOM patchset to simplify the logistics and accelerate the landing of the part which is useful by itself. No functional changes since BPF OOM v2. v3: - dropped redundant kfuncs flags (by Alexei) - fixed kdocs warnings (by Alexei) - merged memcg stats access patches into one (by Alexei) - restored root memcg usage reporting, added a comment - added checks for enum boundaries - added Shakeel and JP as co-maintainers (by Shakeel) v2: - added mem_cgroup_disabled() checks (by Shakeel B.) - added special handling of the root memcg in bpf_mem_cgroup_usage() (by Shakeel B.) - minor fixes in the kselftest (by Shakeel B.) - added a MAINTAINERS entry (by Shakeel B.) v1: https://lore.kernel.org/bpf/87ike29s5r.fsf@linux.dev/T/#t JP Kobryn (1): bpf: selftests: selftests for memcg stat kfuncs Roman Gushchin (5): mm: declare memcg_page_state_output() in memcontrol.h mm: introduce BPF kfuncs to deal with memcg pointers mm: introduce bpf_get_root_mem_cgroup() BPF kfunc mm: introduce BPF kfuncs to access memcg statistics and events MAINTAINERS: add an entry for MM BPF extensions MAINTAINERS | 9 + include/linux/memcontrol.h | 20 ++ mm/Makefile | 3 + mm/bpf_memcontrol.c | 193 +++++++++++++++ mm/memcontrol-v1.h | 1 - mm/memcontrol.c | 10 + .../testing/selftests/bpf/cgroup_iter_memcg.h | 18 ++ .../bpf/prog_tests/cgroup_iter_memcg.c | 223 ++++++++++++++++++ .../selftests/bpf/progs/cgroup_iter_memcg.c | 39 +++ 9 files changed, 515 insertions(+), 1 deletion(-) create mode 100644 mm/bpf_memcontrol.c create mode 100644 tools/testing/selftests/bpf/cgroup_iter_memcg.h create mode 100644 tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c create mode 100644 tools/testing/selftests/bpf/progs/cgroup_iter_memcg.c -- 2.52.0