Skip to contentSkip to conversation

mm/page_counter: Move calculating protection values to page_counter

PATCH Applied Maarten Lankhorst 2 participants 2 messages Jul 3, 2024 – Jul 10, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_counter: Move calculating protection values to page_counter

It's a lot of math, and there is nothing memcontrol specific about it. This makes it easier to use inside of the drm cgroup controller.

---
 include/linux/page_counter.h |   4 +
 mm/memcontrol.c              | 154 +------------------------------
 mm/page_counter.c            | 173 +++++++++++++++++++++++++++++++++++
 3 files changed, 180 insertions(+), 151 deletions(-)
include/linux/page_counter.h +4 -0
index 8cd858d912c4..904c52f97284 100644
@@ -81,4 +81,8 @@ static inline void page_counter_reset_watermark(struct page_counter *counter)
 	counter->watermark = page_counter_read(counter);
 }
 
+void page_counter_calculate_protection(struct page_counter *root,
+				       struct page_counter *counter,
+				       bool recursive_protection);
+
 #endif /* _LINUX_PAGE_COUNTER_H */
mm/memcontrol.c +3 -151

172 lines not on this page · raw message

mm/page_counter.c +173 -0

176 lines not on this page · raw message

Signature · 1 line
2.45.2
#1 lore raw
Quoted 7 lines · Maarten Lankhorst

It's a lot of math, and there is nothing memcontrol specific about it. This makes it easier to use inside of the drm cgroup controller.

---

...

Quoted 4 lines

+/**
+ * page_counter_calculate_protection - check if memory consumption is in the normal range
+ * @root: the top ancestor of the sub-tree being checked
+ * @memcg: the memory cgroup to check

need to document @counter instead

mm/page_counter.c:400: warning: Function parameter or struct member 'counter' not described in 'page_counter_calculate_protection' mm/page_counter.c:400: warning: Excess function parameter 'memcg' description in 'page_counter_calculate_protection'

Quoted 11 lines

+ * @recursive_protection: Whether to use memory_recursiveprot behavior.
+ *
+ * Calculates elow/emin thresholds for given page_counter.
+ *
+ * WARNING: This function is not stateless! It can only be used as part
+ * of a top-down tree iteration, not for isolated queries.
+ */

mm/page_counter.c +4 -0
+void page_counter_calculate_protection(struct page_counter *root,
+				       struct page_counter *counter,
+				       bool recursive_protection)
+{