summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-26 21:20:09 +0100
committerMark Brown <broonie@kernel.org>2026-07-26 21:20:09 +0100
commit9754be9143bac7f0984f33e45577eb0a74f732d9 (patch)
treefbe49031ee747ea26cd10e1b1b9e68402405100c /include/linux
parent0f9c2ea2b2dc7229b3c5ef3ddef9ed217915f270 (diff)
parent022cce2cda452ed2d316991c5088d82d9676c482 (diff)
downloadlinux-next-9754be9143bac7f0984f33e45577eb0a74f732d9.tar.gz
linux-next-9754be9143bac7f0984f33e45577eb0a74f732d9.zip
Merge branch 'fs-current' of linux-next
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/memcontrol.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 957260677678..8170bb8066a2 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -520,6 +520,22 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
return (memcg == root_mem_cgroup);
}
+/**
+ * mem_cgroup_shrink_is_root - is this a global or root-memcg shrink invocation?
+ * @sc: shrink_control describing the current shrinker call
+ *
+ * Returns true when @sc represents a global reclaim shrink (sc->memcg == NULL)
+ * or a root-memcg shrink, i.e. not a per-memcg iteration of
+ * shrink_slab_memcg(). Filesystems whose ->nr_cached_objects()/
+ * ->free_cached_objects() implementations operate on filesystem-global state
+ * and do not honour sc->memcg can use this to early-return 0 in per-memcg
+ * contexts.
+ */
+static inline bool mem_cgroup_shrink_is_root(struct shrink_control *sc)
+{
+ return !sc->memcg || mem_cgroup_is_root(sc->memcg);
+}
+
static inline bool obj_cgroup_is_root(const struct obj_cgroup *objcg)
{
return objcg->is_root;
@@ -1071,6 +1087,11 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
return true;
}
+static inline bool mem_cgroup_shrink_is_root(struct shrink_control *sc)
+{
+ return true;
+}
+
static inline bool obj_cgroup_is_root(const struct obj_cgroup *objcg)
{
return true;