Android高阶

android go 内存回收

2018-12-10  本文已影响1人  布吉刀

内核通过/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计算核心)

上一篇 下一篇

猜你喜欢

热点阅读