android go 内存回收

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

    原文作者:布吉刀
    原文地址: https://www.jianshu.com/p/94a31d708953
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞