深入浅出Android dmabuf_dump工具

dmabuf是什么?

 可以参考我之前写的一篇文章,在这篇文章中有介绍dma_buf:BufferManager_驱动的buffermanager-CSDN博客

dmabuf_dump工具介绍(基于Android 14)

dmabuf_dump是一个可执行文件,接收参数调用libdmabufinfo.a的接口完成dump功能,源码在:system/memory/libmeminfo/libdmabufinfo/tools/

安卓源代码目录下主要有下面2个文件,一个 Android.bp ,一个是 dmabuf_dump.cpp

Android.bp

// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_binary {
    name: "dmabuf_dump",
    cflags: [
        "-Wall",
        "-Werror",
    ],

    srcs: ["dmabuf_dump.cpp"],
    shared_libs: [
        "libbase",
    ],
    static_libs: [
        "libdmabufinfo",
    ],
    vendor_available: true,
}

dmabuf_dump.cpp

xref: /mivendor_u_sm8650/system/memory/libmeminfo/libdmabufinfo/tools/dmabuf_dump.cpp (revision unknown)
HomeHistoryAnnotateLine# Scopes# Navigate#Raw Download 
  current directory
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <dirent.h>
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#include <android-base/stringprintf.h>
#include <dmabufinfo/dmabufinfo.h>
#include <dmabufinfo/dmabuf_sysfs_stats.h>

using DmaBuffer = ::android::dmabufinfo::DmaBuffer;

[[noreturn]] static void usage(int exit_status) {
    fprintf(stderr,
            "Usage: %s [-abh] [per-process/per-buffer stats] \n"
            "-a\t show all dma buffers (ion) in big table, [buffer x process] grid \n"
            "-b\t show DMA-BUF per-buffer, per-exporter and per-device statistics \n"
            "-h\t show this help\n"
            "  \t If PID is supplied, the dmabuf information for that process is shown.\n"
            "  \t Per-buffer DMA-BUF stats do not take an argument.\n",
            getprogname());

    exit(exit_status);
}

static std::string GetProcessComm(const pid_t pid) {
    std::string pid_path = android::base::StringPrintf("/proc/%d/comm", pid);
    std::ifstream in{pid_path};
    if (!in) return std::string("N/A");
    std::string line;
    std::getline(in, line);
    if (!in) return std::string("N/A");
    return line;
}

static void PrintDmaBufTable(const std::vector<DmaBuffer>& bufs) {
    if (bufs.empty()) {
        printf("dmabuf info not found ¯\\_(ツ)_/¯\n");
        return;
    }

    // Find all unique pids in the input vector, create a set
    std::set<pid_t> pid_set;
    for (auto& buf : bufs) {
        pid_set.insert(buf.pids().begin(), buf.pids().end());
    }

    // Format the header string spaced and separated with '|'
    printf("    Dmabuf Inode |            Size |   Fd Ref Counts |  Map Ref Counts |");
    for (auto pid : pid_set) {
        printf("%16s:%-5d |", GetProcessComm(pid).c_str(), pid);
    }
    printf("\n");

    // holds per-process dmabuf size in kB
    std::map<pid_t, uint64_t> per_pid_size = {};
    uint64_t dmabuf_total_size = 0;

    // Iterate through all dmabufs and collect per-process sizes, refs
    for (auto& buf : bufs) {
        printf("%16ju |%13" PRIu64 " kB |%16zu |%16zu |",
               static_cast<uintmax_t>(buf.inode()), buf.size() / 1024, buf.fdrefs().size(),
               buf.maprefs().size());
        // Iterate through each process to find out per-process references for each buffer,
        // gather total size used by each process etc.
        for (pid_t pid : pid_set) {
            int pid_fdrefs = 0, pid_maprefs = 0;
            if (buf.fdrefs().count(pid) == 1) {
                // Get the total number of ref counts the process is holding
                // on this buffer. We don't differentiate between mmap or fd.
                pid_fdrefs += buf.fdrefs().at(pid);
            }
            if (buf.maprefs().count(pid) == 1) {
                pid_maprefs += buf.maprefs().at(pid);
            }

            if (pid_fdrefs || pid_maprefs) {
                // Add up the per-pid total size. Note that if a buffer is mapped
                // in 2 different processes, the size will be shown as mapped or opened
                // in both processes. This is intended for visibility.
                //
                // If one wants to get the total *unique* dma buffers, they can simply
                // sum the size of all dma bufs shown by the tool
                per_pid_size[pid] += buf.size() / 1024;
                printf("%9d(%6d) refs |", pid_fdrefs, pid_maprefs);
            } else {
                printf("%22s |", "--");
            }
        }
        dmabuf_total_size += buf.size() / 1024;
        printf("\n");
    }

    printf("------------------------------------\n");
    printf("%-16s  %13" PRIu64 " kB |%16s |%16s |", "TOTALS", dmabuf_total_size, "n/a", "n/a");
    for (auto pid : pid_set) {
        printf("%19" PRIu64 " kB |", per_pid_size[pid]);
    }
    printf("\n");

    return;
}

static void PrintDmaBufPerProcess(const std::vector<DmaBuffer>& bufs) {
    if (bufs.empty()) {
        printf("dmabuf info not found ¯\\_(ツ)_/¯\n");
        return;
    }

    // Create a reverse map from pid to dmabufs
    std::unordered_map<pid_t, std::set<ino_t>> pid_to_inodes = {};
    uint64_t userspace_size = 0;  // Size of userspace dmabufs in the system
    for (auto& buf : bufs) {
        for (auto pid : buf.pids()) {
            pid_to_inodes[pid].insert(buf.inode());
        }
        userspace_size += buf.size();
    }
    // Create an inode to dmabuf map. We know inodes are unique..
    std::unordered_map<ino_t, DmaBuffer> inode_to_dmabuf;
    for (auto buf : bufs) {
        inode_to_dmabuf[buf.inode()] = buf;
    }

    uint64_t total_rss = 0, total_pss = 0;
    for (auto& [pid, inodes] : pid_to_inodes) {
        uint64_t pss = 0;
        uint64_t rss = 0;

        printf("%16s:%-5d\n", GetProcessComm(pid).c_str(), pid);
        printf("%22s %16s %16s %16s %16s\n", "Name", "Rss", "Pss", "nr_procs", "Inode");
        for (auto& inode : inodes) {
            DmaBuffer& buf = inode_to_dmabuf[inode];
            printf("%22s %13" PRIu64 " kB %13" PRIu64 " kB %16zu %16" PRIuMAX "\n",
                   buf.name().empty() ? "<unknown>" : buf.name().c_str(), buf.size() / 1024,
                   buf.Pss() / 1024, buf.pids().size(), static_cast<uintmax_t>(buf.inode()));
            rss += buf.size();
            pss += buf.Pss();
        }
        printf("%22s %13" PRIu64 " kB %13" PRIu64 " kB %16s\n", "PROCESS TOTAL", rss / 1024,
               pss / 1024, "");
        printf("----------------------\n");
        total_rss += rss;
        total_pss += pss;
    }

    uint64_t kernel_rss = 0;  // Total size of dmabufs NOT mapped or opened by a process
    if (android::dmabufinfo::GetDmabufTotalExportedKb(&kernel_rss)) {
        kernel_rss *= 1024;  // KiB -> bytes
        if (kernel_rss >= userspace_size)
            kernel_rss -= userspace_size;
        else
            printf("Warning: Total dmabufs < userspace dmabufs\n");
    } else {
        printf("Warning: Could not get total exported dmabufs. Kernel size will be 0.\n");
    }
    printf("dmabuf total: %" PRIu64 " kB kernel_rss: %" PRIu64 " kB userspace_rss: %" PRIu64
           " kB userspace_pss: %" PRIu64 " kB\n ",
           (userspace_size + kernel_rss) / 1024, kernel_rss / 1024, total_rss / 1024,
           total_pss / 1024);
}

static void DumpDmabufSysfsStats() {
    android::dmabufinfo::DmabufSysfsStats stats;

    if (!android::dmabufinfo::GetDmabufSysfsStats(&stats)) {
        printf("Unable to read DMA-BUF sysfs stats from device\n");
        return;
    }

    auto buffer_stats = stats.buffer_stats();
    auto exporter_stats = stats.exporter_info();

    printf("\n\n----------------------- DMA-BUF per-buffer stats -----------------------\n");
    printf("    Dmabuf Inode |     Size(bytes) |             Exporter Name             |\n");
    for (const auto& buf : buffer_stats) {
        printf("%16lu |%" PRIu64 " | %16s \n", buf.inode, buf.size, buf.exp_name.c_str());
    }

    printf("\n\n----------------------- DMA-BUF exporter stats -----------------------\n");
    printf("      Exporter Name              | Total Count |     Total Size(bytes)   |\n");
    for (const auto& it : exporter_stats) {
        printf("%32s | %12u| %" PRIu64 "\n", it.first.c_str(), it.second.buffer_count,
               it.second.size);
    }

    printf("\n\n----------------------- DMA-BUF total stats --------------------------\n");
    printf("Total DMA-BUF count: %u, Total DMA-BUF size(bytes): %" PRIu64 "\n", stats.total_count(),
           stats.total_size());
}

int main(int argc, char* argv[]) {
    struct option longopts[] = {{"all", no_argument, nullptr, 'a'},
                                {"per-buffer", no_argument, nullptr, 'b'},
                                {"help", no_argument, nullptr, 'h'},
                                {0, 0, nullptr, 0}};

    int opt;
    bool show_table = false;
    bool show_dmabuf_sysfs_stats = false;
    while ((opt = getopt_long(argc, argv, "abh", longopts, nullptr)) != -1) {
        switch (opt) {
            case 'a':
                show_table = true;
                break;
            case 'b':
                show_dmabuf_sysfs_stats = true;
                break;
            case 'h':
                usage(EXIT_SUCCESS);
            default:
                usage(EXIT_FAILURE);
        }
    }

    pid_t pid = -1;
    if (optind < argc) {
        if (show_table || show_dmabuf_sysfs_stats) {
            fprintf(stderr, "Invalid arguments: -a and -b does not need arguments\n");
            usage(EXIT_FAILURE);
        }
        if (optind != (argc - 1)) {
            fprintf(stderr, "Invalid arguments - only one [PID] argument is allowed\n");
            usage(EXIT_FAILURE);
        }
        pid = atoi(argv[optind]);
        if (pid == 0) {
            fprintf(stderr, "Invalid process id %s\n", argv[optind]);
            usage(EXIT_FAILURE);
        }
    }

    if (show_dmabuf_sysfs_stats) {
        DumpDmabufSysfsStats();
        return 0;
    }

    std::vector<DmaBuffer> bufs;
    if (pid != -1) {
        if (!ReadDmaBufInfo(pid, &bufs)) {
            fprintf(stderr, "Unable to read dmabuf info for %d\n", pid);
            exit(EXIT_FAILURE);
        }
    } else {
        if (!ReadProcfsDmaBufs(&bufs)) {
            fprintf(stderr, "Failed to ReadProcfsDmaBufs, check logcat for info\n");
            exit(EXIT_FAILURE);
        }
    }

    // Show the old dmabuf table, inode x process
    if (show_table) {
        PrintDmaBufTable(bufs);
        return 0;
    }

    PrintDmaBufPerProcess(bufs);

    return 0;
}

整体架构结构如下

dmabuf_dump主要包含以下功能

  1. Dump整个系统DMA-BUF per-buffer, per-exporter and per-device statistics(dmabuf_dump -b),在kernel版本>= 5.10上生效。
  2. Dump整个系统的dmabuf info (dmabuf_dump)
  3. Dump某个PID的dmabuf info (dmabuf_dump )
  4. 以Table[buffer x process]方式呈现dmabuf info (dmabuf_dump -a)

前置背景知识

  1. Rss的含义:是当前段实际加载到物理内存中的大小。
  2. Pss 指的是:进程按比例分配当前段所占物理内存的大小。
  3. 下面dump整个手机系统在某一时刻的 dmabuf信息,可以看到有 binder进程的dmabuf信息、surfaceflinger进程的dmabuf信息、system_server进程的dmabuf信息等等。
  4. nr_procs是指有多少个进程在使用这块dmabuf。
  5. Name是指dmabuf的名字
  6. Inode是这块 dmabuf的唯一标识,注意Inode是全局唯一的。
  7. PROCESS TOTAL 是统计 Rss 或者 Pss的总和。
  8. dmabuf total 是整个系统dambuf的总和
  9. userspace_rss 是用户空间 rss的总和。
  10. userspace_pss 是用户空间 pss的总和。
  11. kernel_rss 目前初步认为是 内核空间rss的总和,但不特别准确,这个kernel_rss大有来头,后面有时间详细深度剖析。真实的项目过程中,会偶先 kernel_rss占用过大,或泄露的情况,这种问题还特别难分析和解决。

fdinfo

/proc/<pid>/fdinfo/ 下面的所有fd,针对每个fd读取如下信息:

  • count
  • exp_name,有exp_name则表示是 dmabuf 的file。
  • name
  • size
  • ino:inode

以下是camera provider的 fdinfo

wj@wj:~/Downloads$ adb shell ps -e | grep camera
cameraserver  1601     1   14307344 680656 binder_ioctl_write_read 0 S vendor.qti.camera.provider-service_64
cameraserver  2785     1    2720288  25620 binder_ioctl_write_read 0 S cameraserver
u0_a139      11065  1444    9305388 343752 do_epoll_wait       0 S com.android.camera
wj@wj:~/Downloads$ adb shell
aurora:/ # cd /proc/1601/fdinfo/                                                                                                                                                                                  
aurora:/proc/1601/fdinfo # ls
0   110  1137  117  123  15  19  22  26  3   33   36   383  399  406  43  47  50  54   56  6   63  67   7   73   745  751  79  82  899
1   111  114   118  124  16  2   23  27  30  336  37   384  4    407  44  48  51  55   57  60  64  68   70  731  748  76   8   84  9
10  112  115   121  13   17  20  24  28  31  34   38   386  40   41   45  49  52  557  58  61  65  687  71  74   75   77   80  85
11  113  116   122  14   18  21  25  29  32  35   382  39   400  42   46  5   53  558  59  62  66  69   72  743  750  78   81  86

可以看到 fdinfo 有以下这些:

aurora:/proc/1601/fdinfo # ls
0   110  1137  117  123  15  19  22  26  3   33   36   383  399  406  43  47  50  54   56  6   63  67   7   73   745  751  79  82  899
1   111  114   118  124  16  2   23  27  30  336  37   384  4    407  44  48  51  55   57  60  64  68   70  731  748  76   8   84  9
10  112  115   121  13   17  20  24  28  31  34   38   386  40   41   45  49  52  557  58  61  65  687  71  74   75   77   80  85
11  113  116   122  14   18  21  25  29  32  35   382  39   400  42   46  5   53  558  59  62  66  69   72  743  750  78   81  86

思考

我们知道每一个进程都有一个 fd,用户空间不同进程的 fd,是可以共享内核空间的同一块 dmabuf的,那么怎么样找到进程 fd 和对应 dmabuf的对应关系呢?

那么这个时候 inode 就要出场了,因为 dmabuf的inode是唯一确定的,所以这个时候我们可以把同一时刻的,这个进程的 dmabuf_dump给 dump下来,如下所示。

wj@wj:~$ adb shell ps -e | grep camera
cameraserver  1601     1   14307344 680656 binder_ioctl_write_read 0 S vendor.qti.camera.provider-service_64
cameraserver  2785     1    2720288  25620 binder_ioctl_write_read 0 S cameraserver
u0_a139      11065  1444    9305388 343752 do_epoll_wait       0 S com.android.camera
wj@wj:~$ adb shell dmabuf_dump 1601
 vendor.qti.came:1601 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1              134
                system             4 kB             4 kB                1              135
                system             4 kB             4 kB                1              723
                system             4 kB             4 kB                1              724
                system             4 kB             4 kB                1              725
                system          4320 kB          4320 kB                1              727
                system           736 kB           736 kB                1              729
                system           148 kB           148 kB                1              731
                system         32768 kB         32768 kB                1              733
                system             4 kB             4 kB                1              996
                system             4 kB             4 kB                1             1010
                system             4 kB             4 kB                1             1011
                system           736 kB           736 kB                1             1017
                system           148 kB           148 kB                1             1019
                system          6848 kB          6848 kB                1             1342
                system          1024 kB          1024 kB                1             1359
                system         32768 kB         32768 kB                1             1363
                system             4 kB             4 kB                1             1367
                system             4 kB             4 kB                1             1371
                system             4 kB             4 kB                1             1372
         PROCESS TOTAL         79540 kB         79540 kB                 
----------------------
dmabuf total: 298652 kB kernel_rss: 219112 kB userspace_rss: 79540 kB userspace_pss: 79540 kB

然后我们可以用 grep -nr 命令进行查看,如下所示:

aurora:/proc/1601/fdinfo # grep -nr 733                                                                                                                                                                           
./124:4:ino:	733
aurora:/proc/1601/fdinfo # grep -nr 1372                                                                                                                                                                          
./751:4:ino:	1372

 inode为733的dmabuf 所对应的进程为:124

 inode为1372的dmabuf所对应的进程为:751

bufinfo

我们可以通过获取 bufferinfo 来获取 dmabuf的详细信息。

adb shell cat /sys/kernel/debug/dma_buf/bufinfo

wj@wj:~/Downloads$ adb shell cat /sys/kernel/debug/dma_buf/bufinfo

Dma-buf Objects:
size    	flags   	mode    	count   	exp_name	ino     	name
00032768	00000002	00080007	00000002	qcom,system	00002275	qcom,system
	Attached Devices:
Total 0 devices attached

00770048	00000002	00080007	00000001	qcom,system	00002274	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000002	qcom,system	00002273	qcom,system
	Attached Devices:
Total 0 devices attached

00770048	00000002	00080007	00000001	qcom,system	00002272	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000002	qcom,system	00002271	qcom,system
	Attached Devices:
Total 0 devices attached

00770048	00000002	00080007	00000001	qcom,system	00002270	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000004	qcom,system	00002269	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000004	qcom,system	00002268	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000002	qcom,system	00002267	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000001	qcom,system	00002266	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000002	qcom,system	00002265	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000001	qcom,system	00002264	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000002	qcom,system	00002263	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000001	qcom,system	00002262	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000004	qcom,system	00002261	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000004	qcom,system	00002260	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00002249	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000003	qcom,system	00002248	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00032768	00000002	00080007	00000004	qcom,system	00002188	qcom,system
	Attached Devices:
Total 0 devices attached

10444800	00000002	00080007	00000003	qcom,system	00002187	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00002039	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00002034	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00002033	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

33554432	00000002	00080007	00000003	system	00002029	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00151552	00000002	00080007	00000003	system	00002025	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00106496	00000002	00080007	00000002	system	00002018	system
	Attached Devices:
Total 0 devices attached

00753664	00000002	00080007	00000003	system	00002017	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

07012352	00000002	00080007	00000003	system	00002008	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00002005	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00002004	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00001958	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb5
Total 1 devices attached

00032768	00000002	00080007	00000002	qcom,system	00001953	qcom,system
	Attached Devices:
Total 0 devices attached

10444800	00000002	00080007	00000001	qcom,system	00001952	qcom,system
	Attached Devices:
Total 0 devices attached

00032768	00000002	00080007	00000002	qcom,system	00001502	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000002	qcom,system	00001501	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00073728	00000002	00080007	00000002	qcom,system	00001460	qcom,system
	Attached Devices:
Total 0 devices attached

02506752	00000002	00080007	00000002	qcom,system	00001459	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00001372	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00001371	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00001367	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

33554432	00000002	00080007	00000003	system	00001363	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

01048576	00000002	00080007	00000003	system	00001359	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

07012352	00000002	00080007	00000003	system	00001342	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00151552	00000002	00080007	00000003	system	00001019	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00753664	00000002	00080007	00000003	system	00001017	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00004096	00000002	00080007	00000002	system	00001011	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00001010	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00000996	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb4
Total 1 devices attached

33554432	00000002	00080007	00000003	system	00000733	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

00151552	00000002	00080007	00000003	system	00000731	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

00753664	00000002	00080007	00000003	system	00000729	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

04423680	00000002	00080007	00000003	system	00000727	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

00004096	00000002	00080007	00000002	system	00000725	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000724	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00000723	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb3
Total 1 devices attached

00032768	00000002	00080007	00000002	qcom,system	00000669	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000002	qcom,system	00000668	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000665	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000005	qcom,system	00000664	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000663	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000004	qcom,system	00000662	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000343	qcom,system
	Attached Devices:
Total 0 devices attached

00491520	00000002	00080007	00000004	qcom,system	00000342	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000341	qcom,system
	Attached Devices:
Total 0 devices attached

00491520	00000002	00080007	00000004	qcom,system	00000340	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000339	qcom,system
	Attached Devices:
Total 0 devices attached

00491520	00000002	00080007	00000004	qcom,system	00000338	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000337	qcom,system
	Attached Devices:
Total 0 devices attached

00491520	00000002	00080007	00000004	qcom,system	00000336	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000002	qcom,system	00000321	qcom,system
	Attached Devices:
Total 0 devices attached

00131072	00000002	00080007	00000003	qcom,system	00000320	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000319	qcom,system
	Attached Devices:
Total 0 devices attached

00212992	00000002	00080007	00000004	qcom,system	00000318	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000317	qcom,system
	Attached Devices:
Total 0 devices attached

00212992	00000002	00080007	00000004	qcom,system	00000316	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000315	qcom,system
	Attached Devices:
Total 0 devices attached

00212992	00000002	00080007	00000004	qcom,system	00000314	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000313	qcom,system
	Attached Devices:
Total 0 devices attached

00212992	00000002	00080007	00000004	qcom,system	00000312	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000311	qcom,system
	Attached Devices:
Total 0 devices attached

00352256	00000002	00080007	00000004	qcom,system	00000310	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000309	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000308	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000307	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000306	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000305	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000304	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000303	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000302	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000293	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000292	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000291	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000290	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000289	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000288	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000286	qcom,system
	Attached Devices:
Total 0 devices attached

00974848	00000002	00080007	00000004	qcom,system	00000285	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000258	qcom,system
	Attached Devices:
Total 0 devices attached

00352256	00000002	00080007	00000004	qcom,system	00000257	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000220	qcom,system
	Attached Devices:
Total 0 devices attached

00393216	00000002	00080007	00000004	qcom,system	00000219	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000218	qcom,system
	Attached Devices:
Total 0 devices attached

00393216	00000002	00080007	00000004	qcom,system	00000217	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000216	qcom,system
	Attached Devices:
Total 0 devices attached

00393216	00000002	00080007	00000004	qcom,system	00000215	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000214	qcom,system
	Attached Devices:
Total 0 devices attached

00393216	00000002	00080007	00000004	qcom,system	00000213	qcom,system
	Attached Devices:
	kgsl-3d0
	kgsl-3d0
Total 2 devices attached

00020480	00000002	00080007	00000003	qcom,system	00000172	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,system	00000171	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,system	00000170	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
Total 1 devices attached

00032768	00000002	00080007	00000002	qcom,system	00000167	qcom,system
	Attached Devices:
Total 0 devices attached

14745600	00000002	00080007	00000003	qcom,system	00000166	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
Total 1 devices attached

02097152	00000002	00080007	00000002	qcom,qseecom	00000165	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000002	qcom,qseecom	00000164	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00012288	00000002	00080007	00000002	qcom,qseecom	00000162	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00262144	00000002	00080007	00000003	system	00000160	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb1
Total 1 devices attached

00004096	00000002	00080007	00000003	system	00000158	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb1
Total 1 devices attached

00262144	00000002	00080007	00000003	system	00000157	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb10
Total 1 devices attached

00004096	00000002	00080007	00000002	system	00000156	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000155	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb10
Total 1 devices attached

00032768	00000002	00080007	00000003	system	00000154	<none>
	Attached Devices:
	soc:spf_core_platform:qcom,msm-audio-ion
Total 1 devices attached

00032768	00000002	00080007	00000004	qcom,system	00000153	qcom,system
	Attached Devices:
Total 0 devices attached

10522624	00000002	00080007	00000005	qcom,system	00000152	qcom,system
	Attached Devices:
	soc:qcom,smmu_sde_unsec_cb
	kgsl-3d0
Total 2 devices attached

00004096	00000002	00080007	00000002	system	00000135	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000134	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb11
Total 1 devices attached

00004096	00000002	00080007	00000002	system	00000079	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000078	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb12
Total 1 devices attached

00032768	00000002	00080007	00000002	qcom,system	00000074	qcom,system
	Attached Devices:
Total 0 devices attached

00065536	00000002	00080007	00000002	qcom,system	00000073	qcom,system
	Attached Devices:
	kgsl-3d0
Total 1 devices attached

00004096	00000002	00080007	00000002	system	00000072	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000071	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb11
Total 1 devices attached

00004096	00000002	00080007	00000002	qcom,qseecom	00000057	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000002	system	00000048	system
	Attached Devices:
Total 0 devices attached

00004096	00000002	00080007	00000003	system	00000047	system
	Attached Devices:
	soc:qcom,msm_fastrpc:qcom,msm_fastrpc_compute_cb2
Total 1 devices attached

00008192	00000002	00080007	00000002	qcom,qseecom	00000046	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00008192	00000002	00080007	00000002	qcom,qseecom	00000045	qcom,qseecom
	Attached Devices:
Total 0 devices attached

01200128	00000002	00080007	00000001	qcom,system	00000043	<none>
	Attached Devices:
	soc:qcom,cam_smmu:msm_cam_smmu_icp
Total 1 devices attached

00024576	00000002	00080007	00000002	qcom,qseecom	00000036	qcom,qseecom
	Attached Devices:
Total 0 devices attached

01048576	00000000	00080005	00000001	qcom,system	00000018	<none>
	Attached Devices:
	ab00000.qcom,cvp:cvp_non_secure_cb
Total 1 devices attached

03141632	00000000	00080005	00000001	qcom,system	00000017	<none>
	Attached Devices:
	ab00000.qcom,cvp:cvp_non_secure_cb
Total 1 devices attached

00004096	00000002	00080007	00000002	qcom,qseecom	00000016	qcom,qseecom
	Attached Devices:
Total 0 devices attached

00028672	00000002	00080007	00000003	qcom,qseecom	00000013	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00004096	00000002	00080007	00000003	qcom,qseecom	00000012	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00028672	00000002	00080007	00000003	qcom,qseecom	00000011	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,qseecom	00000010	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00516096	00000002	00080007	00000003	qcom,qseecom	00000009	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,qseecom	00000008	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,qseecom	00000007	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,qseecom	00000006	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00020480	00000002	00080007	00000003	qcom,qseecom	00000005	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00028672	00000002	00080007	00000003	qcom,qseecom	00000004	qcom,qseecom
	Attached Devices:
	firmware:qcom_smcinvoke
Total 1 devices attached

00004096	00000000	00080005	00000001	qcom,system	00000003	<none>
	Attached Devices:
	aa00000.qcom,vidc:non_secure_cb
Total 1 devices attached

00004096	00000000	00080005	00000001	qcom,system	00000002	<none>
	Attached Devices:
	aa00000.qcom,vidc:non_secure_cb
Total 1 devices attached

03133440	00000000	00080005	00000001	qcom,system	00000001	<none>
	Attached Devices:
	aa00000.qcom,vidc:non_secure_cb
Total 1 devices attached


Total 154 objects, 305819648 bytes

可以看到有更多的dmabuf信息输出:size 、 flags、Attached Devices、mode  、count  、exp_name  、ino  、name

Dump整个手机系统的dmabuf

wj@wj:~/Downloads$ adb shell
aurora:/ # dmabuf_dump
   binder:3072_2:3072 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom            12 kB            12 kB                1              160
         PROCESS TOTAL            12 kB            12 kB                 
----------------------
      mfp-daemon:3041 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom             4 kB             4 kB                1              163
          qcom,qseecom          2048 kB          2048 kB                1              164
         PROCESS TOTAL          2052 kB          2052 kB                 
----------------------
        cdsprpcd:2824 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1              139
                system           256 kB           256 kB                1              141
                system           104 kB           104 kB                1             1994
         PROCESS TOTAL           364 kB           364 kB                 
----------------------
   binder:1817_2:1817 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom             8 kB             8 kB                1               37
         PROCESS TOTAL             8 kB             8 kB                 
----------------------
 .android.camera:8920 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1             1979
                system             4 kB             4 kB                1             1987
                system             4 kB             4 kB                1             1988
                system          6848 kB          6848 kB                1             1990
                system           736 kB           736 kB                1             1993
                system           148 kB           148 kB                1             1996
                system         32768 kB         32768 kB                1             1997
                system             4 kB             4 kB                1             2000
                system             4 kB             4 kB                1             2001
                system             4 kB             4 kB                1             2002
           qcom,system          2392 kB          2392 kB                1             2415
           qcom,system            72 kB            72 kB                1             2416
           qcom,system          2448 kB          2448 kB                1             2636
           qcom,system            72 kB            72 kB                1             2637
         PROCESS TOTAL         45508 kB         45508 kB                 
----------------------
 iui.miwallpaper:4872 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system         10276 kB          5138 kB                2             3711
           qcom,system            32 kB            16 kB                2             3712
           qcom,system         10276 kB          5138 kB                2             3723
           qcom,system            32 kB            16 kB                2             3724
         PROCESS TOTAL         20616 kB         10308 kB                 
----------------------
          fidoca:1813 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom            24 kB            24 kB                1               25
         PROCESS TOTAL            24 kB            24 kB                 
----------------------
   binder:1808_2:1808 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1               43
                system             4 kB             4 kB                1               44
         PROCESS TOTAL             8 kB             8 kB                 
----------------------
   binder:3079_2:3079 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system         14400 kB         14400 kB                1              165
           qcom,system            32 kB            32 kB                1              166
         PROCESS TOTAL         14432 kB         14432 kB                 
----------------------
 android.hardwar:1607 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom             4 kB             4 kB                1               22
         PROCESS TOTAL             4 kB             4 kB                 
----------------------
  surfaceflinger:1929 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system            64 kB            64 kB                1               71
           qcom,system            32 kB            32 kB                1               72
           qcom,system         10276 kB          5138 kB                2              133
           qcom,system            32 kB            16 kB                2              134
           qcom,system           384 kB           192 kB                2              225
           qcom,system            32 kB            16 kB                2              226
           qcom,system           384 kB           192 kB                2              227
           qcom,system            32 kB            16 kB                2              228
           qcom,system           384 kB           192 kB                2              229
           qcom,system            32 kB            16 kB                2              230
           qcom,system           384 kB           192 kB                2              231
           qcom,system            32 kB            16 kB                2              232
           qcom,system           344 kB           172 kB                2              247
           qcom,system            32 kB            16 kB                2              248
           qcom,system           952 kB           476 kB                2              292
           qcom,system            32 kB            16 kB                2              293
           qcom,system           952 kB           476 kB                2              298
           qcom,system            32 kB            16 kB                2              299
           qcom,system           952 kB           476 kB                2              302
           qcom,system            32 kB            16 kB                2              303
           qcom,system           952 kB           476 kB                2              304
           qcom,system            32 kB            16 kB                2              305
           qcom,system           952 kB           476 kB                2              308
           qcom,system            32 kB            16 kB                2              309
           qcom,system           952 kB           476 kB                2              310
           qcom,system            32 kB            16 kB                2              311
           qcom,system           952 kB           476 kB                2              312
           qcom,system            32 kB            16 kB                2              313
           qcom,system           952 kB           476 kB                2              314
           qcom,system            32 kB            16 kB                2              315
           qcom,system           344 kB           172 kB                2              323
           qcom,system            32 kB            16 kB                2              324
           qcom,system           208 kB           104 kB                2              325
           qcom,system            32 kB            16 kB                2              326
           qcom,system           208 kB           104 kB                2              327
           qcom,system            32 kB            16 kB                2              328
           qcom,system           208 kB           104 kB                2              329
           qcom,system            32 kB            16 kB                2              330
           qcom,system           208 kB           104 kB                2              331
           qcom,system            32 kB            16 kB                2              332
           qcom,system           128 kB           128 kB                1              333
           qcom,system            32 kB            32 kB                1              334
           qcom,system           480 kB           240 kB                2              349
           qcom,system            32 kB            16 kB                2              350
           qcom,system           480 kB           240 kB                2              351
           qcom,system            32 kB            16 kB                2              352
           qcom,system           480 kB           240 kB                2              353
           qcom,system            32 kB            16 kB                2              354
           qcom,system           480 kB           240 kB                2              355
           qcom,system            32 kB            16 kB                2              356
           qcom,system         10276 kB          5138 kB                2              645
           qcom,system            32 kB            16 kB                2              646
           qcom,system         10276 kB          5138 kB                2              647
           qcom,system            32 kB            16 kB                2              648
           qcom,system         10276 kB         10276 kB                1              829
           qcom,system            32 kB            32 kB                1              830
           qcom,system         10276 kB         10276 kB                1             2694
           qcom,system            32 kB            32 kB                1             2695
           qcom,system         10276 kB          5138 kB                2             3711
           qcom,system            32 kB            16 kB                2             3712
           qcom,system         10276 kB          5138 kB                2             3723
           qcom,system            32 kB            16 kB                2             3724
           qcom,system         10276 kB          5138 kB                2             3731
           qcom,system            32 kB            16 kB                2             3732
         PROCESS TOTAL         96016 kB         58444 kB                 
----------------------
            mrmd:1809 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom             8 kB             8 kB                1               27
         PROCESS TOTAL             8 kB             8 kB                 
----------------------
   binder:1671_2:1671 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system         10276 kB          5138 kB                2              133
           qcom,system            32 kB            16 kB                2              134
           qcom,system            20 kB            20 kB                1              169
           qcom,system            20 kB            20 kB                1              170
           qcom,system            20 kB            20 kB                1              171
           qcom,system         10276 kB          5138 kB                2              645
           qcom,system            32 kB            16 kB                2              646
           qcom,system         10276 kB          5138 kB                2              647
           qcom,system            32 kB            16 kB                2              648
         PROCESS TOTAL         30984 kB         15522 kB                 
----------------------
 vendor.qti.came:1650 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1              142
                system             4 kB             4 kB                1              143
                system             4 kB             4 kB                1             1180
                system             4 kB             4 kB                1             1194
                system             4 kB             4 kB                1             1195
                system           736 kB           736 kB                1             1201
                system           148 kB           148 kB                1             1203
                system          6848 kB          6848 kB                1             1601
                system          1024 kB          1024 kB                1             1620
                system         32768 kB         32768 kB                1             1621
                system             4 kB             4 kB                1             1625
                system             4 kB             4 kB                1             1627
                system             4 kB             4 kB                1             1628
         PROCESS TOTAL         41556 kB         41556 kB                 
----------------------
        adsprpcd:2822 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1              136
                system             4 kB             4 kB                1              137
                system           256 kB           256 kB                1              138
         PROCESS TOTAL           264 kB           264 kB                 
----------------------
   system_server:2293 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system         10200 kB          5100 kB                2             3693
           qcom,system            32 kB            16 kB                2             3694
         PROCESS TOTAL         10232 kB          5116 kB                 
----------------------
 ndroid.systemui:5329 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system           952 kB           476 kB                2              292
           qcom,system            32 kB            16 kB                2              293
           qcom,system           952 kB           476 kB                2              298
           qcom,system            32 kB            16 kB                2              299
           qcom,system           952 kB           476 kB                2              302
           qcom,system            32 kB            16 kB                2              303
           qcom,system           952 kB           476 kB                2              304
           qcom,system            32 kB            16 kB                2              305
           qcom,system           952 kB           476 kB                2              308
           qcom,system            32 kB            16 kB                2              309
           qcom,system           952 kB           476 kB                2              310
           qcom,system            32 kB            16 kB                2              311
           qcom,system           952 kB           476 kB                2              312
           qcom,system            32 kB            16 kB                2              313
           qcom,system           952 kB           476 kB                2              314
           qcom,system            32 kB            16 kB                2              315
           qcom,system           208 kB           104 kB                2              325
           qcom,system            32 kB            16 kB                2              326
           qcom,system           208 kB           104 kB                2              327
           qcom,system            32 kB            16 kB                2              328
           qcom,system           208 kB           104 kB                2              329
           qcom,system            32 kB            16 kB                2              330
           qcom,system           208 kB           104 kB                2              331
           qcom,system            32 kB            16 kB                2              332
           qcom,system           480 kB           240 kB                2              349
           qcom,system            32 kB            16 kB                2              350
           qcom,system           480 kB           240 kB                2              351
           qcom,system            32 kB            16 kB                2              352
           qcom,system           480 kB           240 kB                2              353
           qcom,system            32 kB            16 kB                2              354
           qcom,system           480 kB           240 kB                2              355
           qcom,system            32 kB            16 kB                2              356
           qcom,system           752 kB           752 kB                1              463
           qcom,system            32 kB            32 kB                1              464
           qcom,system           752 kB           752 kB                1              465
           qcom,system            32 kB            32 kB                1              466
           qcom,system           752 kB           752 kB                1              467
           qcom,system            32 kB            32 kB                1              468
           qcom,system         10276 kB         10276 kB                1             3725
           qcom,system            32 kB            32 kB                1             3726
           qcom,system         10276 kB         10276 kB                1             3727
           qcom,system            32 kB            32 kB                1             3728
           qcom,system         10276 kB         10276 kB                1             3729
           qcom,system            32 kB            32 kB                1             3730
           qcom,system         10276 kB          5138 kB                2             3731
           qcom,system            32 kB            16 kB                2             3732
           qcom,system           752 kB           752 kB                1             3733
           qcom,system            32 kB            32 kB                1             3734
           qcom,system           752 kB           752 kB                1             3735
           qcom,system            32 kB            32 kB                1             3736
           qcom,system           752 kB           752 kB                1             3737
           qcom,system            32 kB            32 kB                1             3738
         PROCESS TOTAL         56816 kB         46222 kB                 
----------------------
         sscrpcd:1281 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1               76
                system             4 kB             4 kB                1               77
         PROCESS TOTAL             8 kB             8 kB                 
----------------------
   binder:1589_2:1589 
                  Name              Rss              Pss         nr_procs            Inode
             <unknown>            32 kB            32 kB                1              135
         PROCESS TOTAL            32 kB            32 kB                 
----------------------
   com.miui.home:5380 
                  Name              Rss              Pss         nr_procs            Inode
           qcom,system           384 kB           192 kB                2              225
           qcom,system            32 kB            16 kB                2              226
           qcom,system           384 kB           192 kB                2              227
           qcom,system            32 kB            16 kB                2              228
           qcom,system           384 kB           192 kB                2              229
           qcom,system            32 kB            16 kB                2              230
           qcom,system           384 kB           192 kB                2              231
           qcom,system            32 kB            16 kB                2              232
           qcom,system           344 kB           172 kB                2              247
           qcom,system            32 kB            16 kB                2              248
           qcom,system           344 kB           172 kB                2              323
           qcom,system            32 kB            16 kB                2              324
           qcom,system         10200 kB         10200 kB                1             3665
           qcom,system            32 kB            32 kB                1             3666
           qcom,system         10200 kB          5100 kB                2             3693
           qcom,system            32 kB            16 kB                2             3694
         PROCESS TOTAL         22880 kB         16556 kB                 
----------------------
        qseecomd:1079 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom            28 kB            28 kB                1                1
          qcom,qseecom            20 kB            20 kB                1                2
          qcom,qseecom            20 kB            20 kB                1                3
          qcom,qseecom            20 kB            20 kB                1                4
          qcom,qseecom            20 kB            20 kB                1                5
          qcom,qseecom           504 kB           504 kB                1                6
          qcom,qseecom            20 kB            20 kB                1                7
          qcom,qseecom            28 kB            28 kB                1                8
          qcom,qseecom             4 kB             4 kB                1                9
          qcom,qseecom            28 kB            28 kB                1               10
         PROCESS TOTAL           692 kB           692 kB                 
----------------------
  tee-supplicant:1525 
                  Name              Rss              Pss         nr_procs            Inode
          qcom,qseecom             4 kB             4 kB                1               16
         PROCESS TOTAL             4 kB             4 kB                 
----------------------
   audioadsprpcd:490  
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1               79
                system             4 kB             4 kB                1               80
         PROCESS TOTAL             8 kB             8 kB                 
----------------------
dmabuf total: 265484 kB kernel_rss: 8332 kB userspace_rss: 342528 kB userspace_pss: 257152 kB

Dump某个进程的dmabuf

下面Dump Camera Provider进程的dmabuf使用情况。

wj@wj:~/Downloads$ adb shell ps -e | grep camera
cameraserver  1650     1   14121844 661800 binder_ioctl_write_read 0 S vendor.qti.camera.provider-service_64
cameraserver  2691     1    3069520  23404 binder_ioctl_write_read 0 S cameraserver
u0_a139       8920  1478    9591760 333440 do_epoll_wait       0 S com.android.camera
wj@wj:~/Downloads$ adb shell dmabuf_dump 1650
 vendor.qti.came:1650 
                  Name              Rss              Pss         nr_procs            Inode
                system             4 kB             4 kB                1              142
                system             4 kB             4 kB                1              143
                system             4 kB             4 kB                1             1180
                system             4 kB             4 kB                1             1194
                system             4 kB             4 kB                1             1195
                system           736 kB           736 kB                1             1201
                system           148 kB           148 kB                1             1203
                system          6848 kB          6848 kB                1             1601
                system          1024 kB          1024 kB                1             1620
                system         32768 kB         32768 kB                1             1621
                system             4 kB             4 kB                1             1625
                system             4 kB             4 kB                1             1627
                system             4 kB             4 kB                1             1628
         PROCESS TOTAL         41556 kB         41556 kB                 
----------------------
dmabuf total: 265484 kB kernel_rss: 223928 kB userspace_rss: 41556 kB userspace_pss: 41556 kB

以Table[buffer x process]方式呈现dmabuf

 注意,该方式只能看整个系统的dambuf

wj@wj:~/Downloads$ adb shell
aurora:/ # dmabuf_dump -a
    Dmabuf Inode |            Size |   Fd Ref Counts |  Map Ref Counts |   audioadsprpcd:499   |        qseecomd:1012  |         sscrpcd:1254  |  tee-supplicant:1491  |   binder:1548_2:1548  | android.hardwar:1568  | vendor.qti.came:1601  |   binder:1611_2:1611  |   binder:1734_2:1734  |            mrmd:1735  |          fidoca:1743  |   binder:1750_2:1750  |  surfaceflinger:1846  |        adsprpcd:2891  |        cdsprpcd:2895  |      mfp-daemon:3096  |   binder:3104_2:3104  |   binder:3118_2:3118  | iui.miwallpaper:4832  | ndroid.systemui:5265  |   com.miui.home:5302  |
              78 |            4 kB |               1 |               1 |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              79 |            4 kB |               1 |               1 |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               4 |           28 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               5 |           20 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               6 |           20 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               7 |           20 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               8 |           20 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
               9 |          504 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              10 |           20 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              11 |           28 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              12 |            4 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              13 |           28 kB |               1 |               0 |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              71 |            4 kB |               1 |               1 |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              72 |            4 kB |               1 |               1 |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              16 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             154 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              57 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             134 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             135 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             170 |           20 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             171 |           20 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             172 |           20 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             152 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        2(     0) refs |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             153 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              47 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              48 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              46 |            8 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              36 |           24 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              45 |            8 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              62 |        18500 kB |               1 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              63 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              64 |        18500 kB |               1 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              65 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              73 |           64 kB |               1 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
              74 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             320 |          128 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             215 |          384 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             213 |          384 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             214 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             216 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             217 |          384 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             218 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             219 |          384 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             220 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             257 |          344 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             258 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             285 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             286 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             302 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             303 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             321 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             310 |          344 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |
             311 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |
             292 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             293 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             308 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             309 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             318 |          208 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             319 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             328 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             329 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             342 |          480 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             343 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             326 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             327 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             348 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |
             349 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |
             316 |          208 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             317 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             340 |          480 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             341 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             324 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             325 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             314 |          208 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             315 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             322 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             323 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             338 |          480 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             339 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             312 |          208 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             313 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             332 |          752 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             333 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             330 |          752 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             331 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             336 |          480 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             334 |          752 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             335 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             337 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             288 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             289 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             290 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             291 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             306 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             307 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             433 |        10276 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |
             434 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |
             304 |          952 kB |               2 |               0 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     0) refs |                    -- |
             305 |           32 kB |               2 |               2 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |
             155 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             156 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             157 |          256 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             158 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             159 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             160 |          256 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |
             164 |            4 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |
             165 |         2048 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |                    -- |
             162 |           12 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |                    -- |
             166 |        14400 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |
             167 |           32 kB |               1 |               1 |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |                    -- |        1(     1) refs |                    -- |                    -- |                    -- |
------------------------------------
TOTALS                   143012 kB |             n/a |             n/a |                  8 kB |                692 kB |                  8 kB |                  4 kB |                 32 kB |                  4 kB |                  8 kB |              10368 kB |                  8 kB |                  8 kB |                 24 kB |                  8 kB |             125124 kB |                264 kB |                264 kB |               2052 kB |                 12 kB |              14432 kB |              20616 kB |              54464 kB |               2416 kB |

上述dump说明:

  • Fd Ref Counts :表示该FD有多少个进程在引用
  • Map Ref Counts:表示该FD当前有多少个进程已经做过Map
  • FD( Map) refs : 该进程持有该Buffer的参考计数的总数量以及Map的总次数

Dump整个系统DMA-BUF per-buffer, per-exporter and per-device statistics

在kernel版本>= 5.10上生效。

执行:dmabuf_dump -b

会从sysfs(/sys/kernel/dmabuf/buffers)中dump dmabuf统计信息,显示如下内容:

wj@wj:~/Downloads$ adb shell
aurora:/ # dmabuf_dump -b


----------------------- DMA-BUF per-buffer stats -----------------------
    Dmabuf Inode |     Size(bytes) |             Exporter Name             |
            2262 |10522624 |      qcom,system 
            2017 |753664 |           system 
            1372 |4096 |           system 
             315 |32768 |      qcom,system 
              17 |3141632 |      qcom,system 
             343 |32768 |      qcom,system 
             220 |32768 |      qcom,system 
             164 |4096 |     qcom,qseecom 
              45 |8192 |     qcom,qseecom 
             305 |32768 |      qcom,system 
              73 |65536 |      qcom,system 
             154 |32768 |           system 
             663 |32768 |      qcom,system 
               7 |20480 |     qcom,qseecom 
            2270 |770048 |      qcom,system 
            2025 |151552 |           system 
            1342 |7012352 |           system 
            2260 |10522624 |      qcom,system 
             172 |20480 |      qcom,system 
             313 |32768 |      qcom,system 
             257 |352256 |      qcom,system 
             134 |4096 |           system 
             341 |32768 |      qcom,system 
             285 |974848 |      qcom,system 
             219 |393216 |      qcom,system 
             162 |12288 |     qcom,qseecom 
            2005 |4096 |           system 
              43 |1200128 |      qcom,system 
             303 |32768 |      qcom,system 
            2033 |4096 |           system 
            1501 |10522624 |      qcom,system 
              71 |4096 |           system 
             152 |10522624 |      qcom,system 
               5 |20480 |     qcom,qseecom 
            2269 |32768 |      qcom,system 
             321 |32768 |      qcom,system 
            1010 |4096 |           system 
             293 |32768 |      qcom,system 
             170 |20480 |      qcom,system 
             311 |32768 |      qcom,system 
              13 |28672 |     qcom,qseecom 
             217 |393216 |      qcom,system 
            2249 |32768 |      qcom,system 
             160 |262144 |           system 
            1359 |1048576 |           system 
            1952 |10444800 |      qcom,system 
            1019 |151552 |           system 
               3 |4096 |      qcom,system 
            2267 |32768 |      qcom,system 
             291 |32768 |      qcom,system 
            1367 |4096 |           system 
              78 |4096 |           system 
              11 |28672 |     qcom,qseecom 
             338 |491520 |      qcom,system 
             215 |393216 |      qcom,system 
            2247 |32768 |      qcom,system 
             724 |4096 |           system 
             668 |10522624 |      qcom,system 
            2275 |32768 |      qcom,system 
            1017 |753664 |           system 
               1 |3133440 |      qcom,system 
            2265 |32768 |      qcom,system 
             318 |212992 |      qcom,system 
             167 |32768 |      qcom,system 
              48 |4096 |           system 
             308 |974848 |      qcom,system 
             336 |491520 |      qcom,system 
             213 |393216 |      qcom,system 
             157 |262144 |           system 
             996 |4096 |           system 
            2273 |32768 |      qcom,system 
            2263 |32768 |      qcom,system 
            2018 |106496 |           system 
             316 |212992 |      qcom,system 
              18 |1048576 |      qcom,system 
             288 |974848 |      qcom,system 
             165 |2097152 |     qcom,qseecom 
            2008 |7012352 |           system 
              46 |8192 |     qcom,qseecom 
            1363 |33554432 |           system 
             306 |974848 |      qcom,system 
              74 |32768 |      qcom,system 
             155 |4096 |           system 
            2187 |10444800 |      qcom,system 
             664 |10522624 |      qcom,system 
              36 |24576 |     qcom,qseecom 
               8 |20480 |     qcom,qseecom 
            2271 |32768 |      qcom,system 
            2261 |32768 |      qcom,system 
            1371 |4096 |           system 
             314 |212992 |      qcom,system 
             258 |32768 |      qcom,system 
             135 |4096 |           system 
              16 |4096 |     qcom,qseecom 
             342 |491520 |      qcom,system 
             286 |32768 |      qcom,system 
             729 |753664 |           system 
             304 |974848 |      qcom,system 
            2034 |4096 |           system 
            1502 |32768 |      qcom,system 
              72 |4096 |           system 
             153 |32768 |      qcom,system 
             662 |10522624 |      qcom,system 
               6 |20480 |     qcom,qseecom 
            1011 |4096 |           system 
             171 |20480 |      qcom,system 
             312 |212992 |      qcom,system 
             340 |491520 |      qcom,system 
             218 |32768 |      qcom,system 
             727 |4423680 |           system 
            2004 |4096 |           system 
             302 |974848 |      qcom,system 
            1953 |32768 |      qcom,system 
               4 |28672 |     qcom,qseecom 
            2268 |10522624 |      qcom,system 
             320 |131072 |      qcom,system 
             292 |974848 |      qcom,system 
             310 |352256 |      qcom,system 
              79 |4096 |           system 
              12 |4096 |     qcom,qseecom 
             339 |32768 |      qcom,system 
             216 |32768 |      qcom,system 
            2248 |10522624 |      qcom,system 
             725 |4096 |           system 
             669 |32768 |      qcom,system 
               2 |4096 |      qcom,system 
            2266 |10522624 |      qcom,system 
             319 |32768 |      qcom,system 
            1460 |73728 |      qcom,system 
             290 |974848 |      qcom,system 
             733 |33554432 |           system 
             309 |32768 |      qcom,system 
            2039 |4096 |           system 
              10 |20480 |     qcom,qseecom 
             337 |32768 |      qcom,system 
             214 |32768 |      qcom,system 
            2246 |10444800 |      qcom,system 
             158 |4096 |           system 
             723 |4096 |           system 
            2274 |770048 |      qcom,system 
            2029 |33554432 |           system 
            2264 |10522624 |      qcom,system 
              57 |4096 |     qcom,qseecom 
             317 |32768 |      qcom,system 
            1459 |2506752 |      qcom,system 
             289 |32768 |      qcom,system 
             166 |14745600 |      qcom,system 
             731 |151552 |           system 
              47 |4096 |           system 
             307 |32768 |      qcom,system 
            1958 |4096 |           system 
             156 |4096 |           system 
            2188 |32768 |      qcom,system 
             665 |32768 |      qcom,system 
               9 |516096 |     qcom,qseecom 
            2272 |770048 |      qcom,system 


----------------------- DMA-BUF exporter stats -----------------------
      Exporter Name              | Total Count |     Total Size(bytes)   |
                     qcom,system |           95| 189779968
                          system |           43| 123645952
                    qcom,qseecom |           18| 2871296


----------------------- DMA-BUF total stats --------------------------
Total DMA-BUF count: 156, Total DMA-BUF size(bytes): 316297216

DMA_BUF 在内核中的实现

源代码位置:kernel_platform/msm-kernel/drivers/dma-buf/

这篇文章不深入这块内容,后面有时间可以专门写文章进行深入分析。

dmabuf_dump原理分析

源码路径:

system/memory/libmeminfo/libdmabufinfo/

DmaBuffer

DmaBuffer结构体定义如下:

struct DmaBuffer {
  public:
    DmaBuffer(ino_t inode, uint64_t size, uint64_t count, const std::string& exporter,
              const std::string& name)
        : inode_(inode), size_(size), count_(count), exporter_(exporter), name_(name) {
        total_refs_ = 0;
    }
    DmaBuffer() = default;
    ~DmaBuffer() = default;

    // Adds one file descriptor reference for the given pid
    void AddFdRef(pid_t pid) {
        AddRefToPidMap(pid, &fdrefs_);
        total_refs_++;
    }

    // Adds one map reference for the given pid
    void AddMapRef(pid_t pid) {
        AddRefToPidMap(pid, &maprefs_);
        total_refs_++;
    }

    // Getters for each property
    uint64_t size() const { return size_; }
    const std::unordered_map<pid_t, int>& fdrefs() const { return fdrefs_; }
    const std::unordered_map<pid_t, int>& maprefs() const { return maprefs_; }
    ino_t inode() const { return inode_; }
    uint64_t total_refs() const { return total_refs_; }
    uint64_t count() const { return count_; };
    const std::set<pid_t>& pids() const { return pids_; }
    const std::string& name() const { return name_; }
    const std::string& exporter() const { return exporter_; }
    void SetName(const std::string& name) { name_ = name; }
    void SetExporter(const std::string& exporter) { exporter_ = exporter; }
    void SetCount(uint64_t count) { count_ = count; }
    uint64_t Pss() const { return size_ / pids_.size(); }

    bool operator==(const DmaBuffer& rhs) {
        return (inode_ == rhs.inode()) && (size_ == rhs.size()) && (name_ == rhs.name()) &&
               (exporter_ == rhs.exporter());
    }

  private:
    ino_t inode_;
    uint64_t size_;
    uint64_t count_;
    uint64_t total_refs_;
    std::set<pid_t> pids_;
    std::string exporter_;
    std::string name_;
    std::unordered_map<pid_t, int> fdrefs_;
    std::unordered_map<pid_t, int> maprefs_;
    void AddRefToPidMap(pid_t pid, std::unordered_map<pid_t, int>* map) {
        // The first time we find a ref, we set the ref count to 1
        // otherwise, increment the existing ref count
        auto [it, inserted] = map->insert(std::make_pair(pid, 1));
        if (!inserted) it->second++;
        pids_.insert(pid);
    }
};

主要成员变量

  • name_ : 该dmabuf的name,如果读不到name,默认为 ‘<unknown>’

  • pids_: 有dup或map该dmabuf的pid 集合

  • count_: fdinfo里面的count,目前看dambuf_dump并没有用。

  • size_: 该dmabuf占用的内存大小,单位是byte。

  • inode_: 该dmabuf的inode。

  • exporter_: 申请该dmabuf的name,如果读不到name,默认为'<unknown>’。

  • total_refs_: fdrefs 个数 + maprefs 个数,目前看dambuf_dump并没有用。

  • fdrefs_: 有open或dup该dmabuf的pid集合。注:一个pid对同一个dmabuf(inode)可能有多个reference。

  • maprefs_: 有map该dmabuf的pid集合。注:一个pid对同一个dmabuf(inode)可能有多个reference。

FD和Inode的关系

为了实现buffer的共享,在内核中将DMA-BUF将buffer与file关联起来,一个Buffer对应唯一一个File,一个File对应唯一一个 inode,将这个file的fd返回给应用层,通过binder实现进程之间的fd传递(dup),进而拿到唯一的File 和 Buffer。
 

dump整个系统流程原理

直接执行dmabuf_dump会dump 整个系统的dmabuf 信息,代码执行流程如下:

ReadDmaBufFdRefs

// Public methods
bool ReadDmaBufFdRefs(int pid, std::vector<DmaBuffer>* dmabufs,
                             const std::string& procfs_path) {
    constexpr char permission_err_msg[] =
            "Failed to read fdinfo - requires either PTRACE_MODE_READ or root depending on "
            "the device kernel";
    static bool logged_permission_err = false;

    std::string fdinfo_dir_path =
            ::android::base::StringPrintf("%s/%d/fdinfo", procfs_path.c_str(), pid);
    std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(fdinfo_dir_path.c_str()), &closedir);
    if (!dir) {
        // Don't log permission errors to reduce log spam on devices where fdinfo
        // of other processes can only be read by root.
        if (errno != EACCES) {
            PLOG(ERROR) << "Failed to open " << fdinfo_dir_path << " directory";
        } else if (!logged_permission_err) {
            LOG(ERROR) << permission_err_msg;
            logged_permission_err = true;
        }
        return false;
    }
    struct dirent* dent;
    while ((dent = readdir(dir.get()))) {
        int fd;
        if (!::android::base::ParseInt(dent->d_name, &fd)) {
            continue;
        }

        // Set defaults in case the kernel doesn't give us the information
        // we need in fdinfo
        std::string name = "<unknown>";
        std::string exporter = "<unknown>";
        uint64_t count = 0;
        uint64_t size = 0;
        uint64_t inode = -1;
        bool is_dmabuf_file = false;

        auto fdinfo_result = ReadDmaBufFdInfo(pid, fd, &name, &exporter, &count, &size, &inode,
                                              &is_dmabuf_file, procfs_path);
        if (fdinfo_result != OK) {
            if (fdinfo_result == NOT_FOUND) {
                continue;
            }
            // Don't log permission errors to reduce log spam when the process doesn't
            // have the PTRACE_MODE_READ permission.
            if (errno != EACCES) {
                LOG(ERROR) << "Failed to read fd info for pid: " << pid << ", fd: " << fd;
            } else if (!logged_permission_err) {
                LOG(ERROR) << permission_err_msg;
                logged_permission_err = true;
            }
            return false;
        }
        if (!is_dmabuf_file) {
            continue;
        }
        if (inode == static_cast<uint64_t>(-1)) {
            // Fallback to stat() on the fd path to get inode number
            std::string fd_path =
                    ::android::base::StringPrintf("%s/%d/fd/%d", procfs_path.c_str(), pid, fd);

            struct stat sb;
            if (stat(fd_path.c_str(), &sb) < 0) {
                if (errno == ENOENT) {
                  continue;
                }
                PLOG(ERROR) << "Failed to stat: " << fd_path;
                return false;
            }

            inode = sb.st_ino;
            // If root, calculate size from the allocated blocks.
            size = sb.st_blocks * 512;
        }

        auto buf = std::find_if(dmabufs->begin(), dmabufs->end(),
                                [&inode](const DmaBuffer& dbuf) { return dbuf.inode() == inode; });
        if (buf != dmabufs->end()) {
            if (buf->name() == "" || buf->name() == "<unknown>") buf->SetName(name);
            if (buf->exporter() == "" || buf->exporter() == "<unknown>") buf->SetExporter(exporter);
            if (buf->count() == 0) buf->SetCount(count);
            buf->AddFdRef(pid);
            continue;
        }

        DmaBuffer& db = dmabufs->emplace_back(inode, size, count, exporter, name);
        db.AddFdRef(pid);
    }

    return true;
}

读取 /proc/<pid>/fdinfo/ 下面的所有fd,针对每个fd读取如下信息

  • count
  • exp_name,有exp_name则表示是 dmabuf 的file。
  • name
  • size
  • ino:inode

如果是dmabuf file,但没有读到inode,则:

读取 /proc/<pid>/fdinfo/fd的stat,从里面去读取size和inode

        if (inode == static_cast<uint64_t>(-1)) {
            // Fallback to stat() on the fd path to get inode number
            std::string fd_path =
                    ::android::base::StringPrintf("%s/%d/fd/%d", procfs_path.c_str(), pid, fd);

            struct stat sb;
            if (stat(fd_path.c_str(), &sb) < 0) {
                if (errno == ENOENT) {
                  continue;
                }
                PLOG(ERROR) << "Failed to stat: " << fd_path;
                return false;
            }

            inode = sb.st_ino;
            // If root, calculate size from the allocated blocks.
            size = sb.st_blocks * 512;
        }

最后,调用DmaBuffer的AddFdRef,添加到fdrefs_ map里面去。

AddFdRef
    // Adds one file descriptor reference for the given pid
    void AddFdRef(pid_t pid) {
        AddRefToPidMap(pid, &fdrefs_);
        total_refs_++;
    }

ReadDmaBufMapRefs

bool ReadDmaBufMapRefs(pid_t pid, std::vector<DmaBuffer>* dmabufs,
                              const std::string& procfs_path,
                              const std::string& dmabuf_sysfs_path) {
    std::string mapspath = ::android::base::StringPrintf("%s/%d/maps", procfs_path.c_str(), pid);
    std::ifstream fp(mapspath);
    if (!fp) {
        LOG(ERROR) << "Failed to open " << mapspath << " for pid: " << pid;
        return false;
    }

    // Process the map if it is dmabuf. Add map reference to existing object in 'dmabufs'
    // if it was already found. If it wasn't create a new one and append it to 'dmabufs'
    auto account_dmabuf = [&](const android::procinfo::MapInfo& mapinfo) {
        // no need to look into this mapping if it is not dmabuf
        if (!FileIsDmaBuf(mapinfo.name)) {
            return;
        }

        auto buf = std::find_if(
                dmabufs->begin(), dmabufs->end(),
                [&mapinfo](const DmaBuffer& dbuf) { return dbuf.inode() == mapinfo.inode; });
        if (buf != dmabufs->end()) {
            buf->AddMapRef(pid);
            return;
        }

        // We have a new buffer, but unknown count and name and exporter name
        // Try to lookup exporter name in sysfs
        std::string exporter;
        bool sysfs_stats = ReadBufferExporter(mapinfo.inode, &exporter, dmabuf_sysfs_path);
        if (!sysfs_stats) {
            exporter = "<unknown>";
        }

        // Using the VMA range as the size of the buffer can be misleading,
        // due to partially mapped buffers or VMAs that extend beyond the
        // buffer size.
        //
        // Attempt to retrieve the real buffer size from sysfs.
        uint64_t size = 0;
        if (!sysfs_stats || !ReadBufferSize(mapinfo.inode, &size, dmabuf_sysfs_path)) {
            size = mapinfo.end - mapinfo.start;
        }

        DmaBuffer& dbuf = dmabufs->emplace_back(mapinfo.inode, size, 0, exporter, "<unknown>");
        dbuf.AddMapRef(pid);
    };

    for (std::string line; getline(fp, line);) {
        if (!::android::procinfo::ReadMapFileContent(line.data(), account_dmabuf)) {
            LOG(ERROR) << "Failed to parse " << mapspath << " for pid: " << pid;
            return false;
        }
    }

    return true;
}

读取/proc/<pid>/maps下面的信息,只处理name以 /dmabuf 开头的map(也就是dmabuf的map)

注:如果从maps里面读到的inode不在fdrefs_ 里面,则会尝试到 /sys/kernel/dmabuf/buffers 里面去读该dmabuf的size,name,exp_name。 

然后调用DmaBuffer的AddMapRef,添加到maprefs_ map里面去。

AddMapRef
    // Adds one map reference for the given pid
    void AddMapRef(pid_t pid) {
        AddRefToPidMap(pid, &maprefs_);
        total_refs_++;
    }

dmabuf_dump <pid>

流程跟dump 整個系统的dmabuf info类似,只是这里只dump指定pid的dmabuf info。

dmabuf_dump -a

以Table[buffer x process]方式呈现dmabuf info。

跟dmabuf_dump相比,只是打印DmaBuffer的方式不一样。

dmabuf_dump -b

Dmabuf Sysfs Stats统计,有三个相关类:

定义作用
DmabufSysfsStats

dambuf_dump_b

Dmabuf sysfs 统计信息每一块Dmabuf信息exporter信息总Dmabuf信息
DmabufInfo

dambuf_dump_b

统计一块Dmabuf 信息,包括inode、exporter name、size
DmabufTotal

dambuf_dump_b

统计整个系统的Dmabuf信息,包括buffer总数、buffer总大小

代码流程

dmabuf的运用

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/310858.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C#,入门教程(15)——类(class)的基础知识

上一篇&#xff1a; C#&#xff0c;入门教程(14)——字符串与其他数据类型的转换https://blog.csdn.net/beijinghorn/article/details/124004562 物以类聚&#xff0c;凡物必类。 类的使用&#xff0c;须遵循几个简单的原则&#xff1a; &#xff08;1&#xff09;能类则类&a…

宏集案例丨宏集PC Runtime软件助推食品行业生产线数字化革新

来源&#xff1a;宏集科技 工业物联网 宏集案例丨宏集PC Runtime软件助推食品行业生产线数字化革新 原文链接&#xff1a;https://mp.weixin.qq.com/s/DwzVzifUiidNr-FT3Zfzpg 欢迎关注虹科&#xff0c;为您提供最新资讯&#xff01; 01 前言 近年来&#xff0c;中国食品行业…

想进入游戏开发领域,应该先学习C++编程还是C#编程?

想进入游戏开发领域&#xff0c;应该先学习C编程还是C#编程&#xff1f; 当你决心踏入游戏开发者的行列时&#xff0c;最先迎接你的将是引擎的选择。引擎是游戏的心脏&#xff0c;所有精彩的画面和内容都是脉脉游戏血液从引擎中流淌而出。Unity、Unreal Engine、Cocos等引擎盛…

牛客字符串

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、pandas是什么&#xff1f;二、使用步骤 1.引入库2.读入数据总结 前言 提示&#xff1a;这里可以添加本文要记录的大概内容&#xff1a; 例如&#xff1a;…

存储卷(数据卷)—主要是nfs方式挂载

1、定义 容器内的目录和宿主机的目录进行挂载 容器在系统上的生命周期是短暂的&#xff0c;一旦容器被删除&#xff0c;数据会丢失。k8s基于控制器创建的pod&#xff0c;delete相当于重启&#xff0c;容器的状态会恢复到原始状态。一旦回到原始状态&#xff0c;后天编辑的文件…

二叉树的层序遍历(C++详解)

文章目录 写在前面解题思路具体做法 写在前面 本篇文章使用C实现了二叉树的层序遍历。在实现二叉树层序遍历时&#xff0c;一般情况下&#xff0c;大家可能直接输出遍历结果。然而&#xff0c;在解决在线评测&#xff08;OJ&#xff09;问题时&#xff0c;有时要求将每一层的遍…

这7个设计素材网站太好用了,特别是第一款!

网页设计师在使用网页设计素材时&#xff0c;会优先考虑那些免费优质的网页设计素材网站。找到一个免费优质的网页设计素材网站并不容易。有些网站要么需要开设材料网站的会员&#xff0c;要么设计素材质量差。即时设计整理总结了 7 个免费的网页设计素材网站&#xff0c;对 “…

GENMARK控制器维修SMALL SMC4092

晶圆转移机器人SMALL CONTROLLER控制器维修 SMC1100 半导体设备机械臂GENMARK控制器维修 eSensor特点&#xff1a; &#xff08;1&#xff09;基于DNA杂交和电化学检测原理&#xff1b; &#xff08;2&#xff09;电化学传感检测&#xff0c;并非荧光或光学检测。 电子信号的…

中国光伏展

中国光伏展是中国最大的光伏产业展览会&#xff0c;每年在国内举办一次。该展览会汇集了国内外光伏行业的领先企业和专业人士&#xff0c;展示最新的光伏技术、产品和解决方案。 中国光伏展旨在促进光伏行业的发展和创新&#xff0c;提升光伏产业的国际竞争力。展览会涵盖了光伏…

一、Sharding-JDBC系列01:整合SpringBoot实现分库分表,读写分离

目录 一、概述 二、案例演示-水平分表 (1)、创建springboot工程 (2)、创建数据库和数据表 (3)、application.yaml配置分片规则 (4)、测试数据插入、查询操作 4.1、插入-控制台SQL日志 4.2、查询-控制台SQL日志 三、案例演示-水平分库 (1)、创建数据库和数据表 (2…

React07-路由管理器react-router-dom(v6)

react-router 是一个流行的用于 React 应用程序路由的库。它使我们能够轻松定义应用程序的路由&#xff0c;并将它们映射到特定的组件&#xff0c;这样可以很容易地创建复杂的单页面应用&#xff0c;并管理应用程序的不同视图。 react-router 是基于 React 构建的&#xff0c;…

离线安装telnet-server

telnet下载地址&#xff1a; https://vault.centos.org/ 需要下载telnet 和 telnet-server 确认自己的服务器版本&#xff0c;我这里使用的是&#xff08;Red Hat Enterprise Linux Server release 7.0 (Maipo)&#xff09;对应的是Centos 7.0,所有到 https://vault.centos.or…

平面光波导_三层均匀平面光波导_射线分析法

平面光波导_三层均匀平面光波导_射线分析法 三层均匀平面光波导&#xff1a; 折射率沿 x x x 方向有变化&#xff0c;沿 y y y、 z z z 方向没有变化三层&#xff1a;芯区( n 1 n_1 n1​) > > > 衬底( n 2 n_2 n2​) ≥ \geq ≥ 包层( n 3 n_3 n3​)包层通常为空…

许战海矩阵战略洞察:如何解决3亿调味品企业朱老六的增长难题

​长春市朱老六食品股份有限公司&#xff0c;是一家以生产腐乳、酸菜等生物发酵品为主的民营企业。 创始人团队自1991年起开发腐乳产品&#xff0c;并于1997年创立“朱老六”品牌。公司专研地道东北味&#xff0c;有着多年的专业经验和深厚的行业积淀&#xff0c;2019年腐乳产…

创建ROS模型与小机器人地图规划

1、打开自己的VM系统 2、安装小机器人的安装包&#xff0c;输入如下命令&#xff0c;回车输入密码(自己设的)&#xff1a; sudo apt install ros-noetic-turtlebot3-simulations ros-noetic-turtlebot3-slam ros-noetic-turtlebot3-navigation 提示我之前安装过了 3、用rosla…

Redis相关报错信息:Could not connect to Redis at 127.0.0.1:6379: 由于目标计算机积极拒绝,无法连接。

报错信息&#xff1a; Could not connect to Redis at 127.0.0.1:6379: 由于目标计算机积极拒绝&#xff0c;无法连接。 报错原因&#xff1a; 访问不到Redis服务 解决方案&#xff1a; 将Redis服务打开&#xff01; 使用cmd命令行打开本机服务管理&#xff1a; services…

全志T113开发板Qt远程调试

1引言 通常情况下工程师在调试Qt程序时&#xff0c;需要频繁制作镜像烧录到核心板来测试Qt程序是否完善&#xff0c;这样的操作既费时又费力。这时我们可以通过QtCreator设备功能&#xff0c;定义设备后&#xff0c;在x86_64虚拟机上交叉编译qt程序&#xff0c;将程序远程部署到…

el-form中一个el-form-item需要规则校验多个input

我的数据的格式&#xff1a; formData: {ipAddress: {one: ,two: ,}, }, 代码结构&#xff1a; <el-form-item label"IP地址" prop"ipAddress"><el-input-numberv-model"formData.ipAddress.one"class"ip-address":contro…

万能字符单词拼写 - 华为OD统一考试

OD统一考试(C卷) 分值: 100分 题解: Java / Python / C++ 题目描述 有一个字符串数组 words 和一个字符串 chars。假如可以用 chars 中的字母拼写出 words 中的某个"单词"(字符串),那么我们就认为你掌握了这个单词。 words 的字符仅由 a-z 英文小写宁母组成,…

003-10-02【Spark官网思维笔记】香积寺旁老松树边马大爷家女儿大红用GPT学习Spark入门知识

003-10-02【Spark官网思维笔记】香积寺旁老松树边马大爷家女儿大红用GPT学习Spark入门知识. Spark 快速入门快速开始使用 Spark Shell 进行交互式分析&#xff1a;独立的应用程序其他 1, 使用 Spark Shell 进行交互式分析1.1 基本1.2 有关Dataset操作的更多信息1.3 缓存 2&…