内核通过/dev/memcg/memory.pressure_level来更新。
具体patch见
memcg: Add memory.pressure_level events
+static bool vmpressure_event(struct vmpressure *vmpr,
+ unsigned long scanned, unsigned long reclaimed)
+{
+ struct vmpressure_event *ev;
+ int level = vmpressure_calc_level(scanned, reclaimed);
+ bool signalled = false;
+
+ mutex_lock(&vmpr->events_lock);
+
+ list_for_each_entry(ev, &vmpr->events, node) {
+ if (level >= ev->level) {
+ eventfd_signal(ev->efd, 1);
+ signalled = true;
+ }
+ }
+
+ mutex_unlock(&vmpr->events_lock);
+
+ return signalled;
+}
新的计算方式为
Pressure=memory.usage_in_bytes*100/memory.memsw.usage_in_bytes
细节见Lmkd pressure值计算(Android lmkd计算核心)
网友评论