zoukankan      html  css  js  c++  java
  • BUG实例分析五:binder alloc buf, no vma


    http://www.mywiki.cn/hovercool/index.php/BUG%E5%AE%9E%E4%BE%8B%E5%88%86%E6%9E%90%E4%BA%94%EF%BC%9Abinder_alloc_buf,_no_vma


    原因:

    vma已经释放,但其对应的proc结构却未释放

    而vma和proc分别是在 binder_vma_close 和 binder_release-> binder_deferred_workqueue中释放的


    在main_log中发现:

    03-19 15:06:05.842   143 12974 E M4U_L   : Open file failed mFileDescriptor=-1, error=24 :Too many open files
    03-19 15:06:05.842   143 12974 E M4U_L   : m4u_alloc_mva failed
    

    这样怀疑是文件打开过多,导致m4u要打开/dev/M4U_device进行mmap出错,然后mediaserver退出

    但即使mediaserver退出,binder驱动也应该同步释放其对应的 proc结构啊!

    于是怀疑是不是在文件打开过多的情况下就会这一问题,验证:

    先在一个拥有binder服务的进程中打开多个文件(一般最多可以打开1024+3, 1024可用ulimit -a查看, 3是三个标准输入输出),然后再kill掉此进程,结果重现:

    kernel log中对pid=131也确实只调用释放了vma,没有释放proc(binder_release)

    T:WaP1227T_1.14.2o	p89_c_j2systemin> adb shell cat /proc/kmsg |egrep "vma|binder_release"
    <6>[   45.091496] (0)[1737:Binder_1]binder: 1727 close vm area 5d12c000-5d32a000 (2040 K) vma 2220051 pagep 79f
    <6>[   45.091793] (1)[44:kworker/u:1]binder_release: 1727: page 0 at e6e00000 not freed
    <6>[   45.091894] (1)[44:kworker/u:1]binder_release: 1727 threads 4, nodes 2 (ref 2), refs 8, active transactions 0, buffers 0, pages 1
    <6>[   95.385043] (0)[2003:MyClient]binder: 2003 close vm area 401aa000-403a8000 (2040 K) vma 2220051 pagep 79f
    <6>[   95.385316] (0)[5:kworker/u:0]binder_release: 2003: page 0 at e0c00000 not freed
    <6>[   95.385392] (0)[5:kworker/u:0]binder_release: 2003 threads 1, nodes 0 (ref 0), refs 2, active transactions 0, buffers 1, pages 1
    <6>[  136.355312] (0)[176:Binder_1]binder: 131 close vm area 4081c000-40a1a000 (2040 K) vma 2220051 pagep 79f
    <6>[  136.373461] (0)[2019:vivo_daemon]binder_mmap: 2019 4068a000-40888000 (2040 K) vma 200071 pagep 79f
    

    同时,在系统中已经不存在pid=131的进程,但其binder/proc却仍然存在:

    F:WDeclipsein
    elease>adb shell ps 131
    USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
    
    F:WDeclipsein
    elease>adb shell cat /mnt/binder/proc/131
    binder proc state:
    proc 131
      thread 131: l 22
      thread 176: l 22
      node 5 (vivo_daemon.service): u4031b8a8 c4031b88c hs 1 hw 1 ls 0 lw 0 is 0 iw 0
      ref 3: desc 0 node 1 s 1 w 1 d   (null)
      node work 5: u4031b8a8 c4031b88c
    

    ps.奇怪的是,在上述vivo_daemon自动重启后,重复这一操作,proc和vma则都能正常销毁,可以是与131已经存在于binder驱动中有关,这个要后面深入binder驱动才能解释。


  • 相关阅读:
    (树链剖分+线段树)POJ
    (树上莫队)HDU
    (LCA+树上主席树)FZU 2237
    (预处理+莫队算法)HDU
    (莫队算法)两题莫队算法统计数量的入门题
    (莫队算法)CodeForces
    sublime配置C++14
    (dfs序+莫队算法/启发式合并/树分治)Codeforces 375D
    (线段树两个lazy标记需要设定优先级)UVA 11992
    (线段树区间合并)UVA 11235
  • 原文地址:https://www.cnblogs.com/ztguang/p/12644843.html
Copyright © 2011-2022 走看看