Proc/wakelocks文件中字段解析

本文解析了Wakelock的统计数据,包括被激活次数、超时次数等关键指标,并探讨了这些数据对于理解系统行为及电池使用的重要性。
count: wakelock被激活次数。如果该数值比较大,说明它处理了大量的事件,而该数值比较小则表示,花了很长的时间来处理这些事件,或wakelock没有正确释放。
expire_count:超时的wakelock的次数。
wake_countactive_since:当前状态下,仍持有锁的wakelock,
total_time:wakelock 锁持有的总时间,该时间最重要。
sleep_time:wakelock 在系统休眠的时候锁持有的时间
max_time:wakelock单次花费最多的时间。
last_change:最后记录的时间。

 

原文

count, tells you how many times the wakelock was activated. If a
wakelock prevented suspend for a long time a large count tells you it
handled a lot of events while a small count tells you it took a long
time to process the events, or the wakelock was not released properly.

expire_count, tells you how many times the timeout expired. For the
input event wakelock in the android kernel (which has a timeout) an
expire count that matches the count tells you that someone opened an
input device but is not reading from it (this has happened several
times).

wake_count, tells you that this is the first wakelock that was
acquired in the resume path. This is currently less useful than I
would like on the Nexus One since it is usually "SMD_RPCCALL" which
does not tell me a lot.

active_since, tells you how long a a still active wakelock has been
active. If someone activated a wakelock and never released it, it will
be obvious here.

total_time, total time the wake lock has been active. This one should
be obvious.

sleep_time, total time the wake lock has been active when the screen was off.

max_time, longest time the wakelock was active uninterrupted. This
used less often, but the battery on a device was draining fast, but
the problem went away before looking at the stats this will show if a
wakelock was active for a long time.
增加原文网址:https://lkml.org/lkml/2010/8/5/731
在 Linux 系统中,`/proc/pagetypeinfo` 文件提供了有关页面类型和内存分配器状态的详细信息。以下是对该文件中各字段信息意义的解析: #### 全局信息部分 在文件开头会有一些全局信息,例如: ```plaintext Page block order: 9 Pages per block: 512 ``` - **Page block order**: 表示页块的阶数。页块是由连续物理页组成的块,页块的大小是 `2^Page block order` 个页。这里 `Page block order` 为 9,意味着每个页块包含 `2^9 = 512` 个页 [^1]。 - **Pages per block**: 明确指出每个页块包含的页数,它是根据 `Page block order` 计算得出的。 #### 页面类型和区域信息部分 接下来是各个页面类型和内存区域的详细信息,格式如下: ```plaintext Node 0, zone DMA per-node stats CPU 0: nr_free_pages 0 nr_zone_inactive_anon 0 nr_zone_active_anon 0 nr_zone_inactive_file 0 nr_zone_active_file 0 nr_zone_unevictable 0 nr_zone_write_pending 0 CPU 1: ... free pages count per migrate type at order order 0: 1 0 0 0 0 0 0 0 order 1: 0 0 0 0 0 0 0 0 ... ``` ##### 节点和区域信息 - **Node 0, zone DMA**: 表示这是节点 0 上的 `DMA` 内存区域。在多节点系统中,每个节点可以有多个内存区域,如 `DMA`、`Normal`、`HighMem` 等 [^1]。 ##### 每个 CPU 的统计信息 - **nr_free_pages**: 该 CPU 上该内存区域中可用的空闲页数。 - **nr_zone_inactive_anon**: 该内存区域中处于非活动状态的匿名页的数量。匿名页是没有映射到文件的页,例如进程的堆和栈使用的页。 - **nr_zone_active_anon**: 该内存区域中处于活动状态的匿名页的数量。 - **nr_zone_inactive_file**: 该内存区域中处于非活动状态的文件映射页的数量。文件映射页是映射到文件的页,例如通过 `mmap` 系统调用创建的映射。 - **nr_zone_active_file**: 该内存区域中处于活动状态的文件映射页的数量。 - **nr_zone_unevictable**: 该内存区域中不可回收的页的数量,这些页通常是被锁定在内存中,不能被换出。 - **nr_zone_write_pending**: 该内存区域中等待写入磁盘的页的数量。 ##### 每个迁移类型和阶数的空闲页计数 - **order**: 表示页块的阶数,与前面的 `Page block order` 概念相关。`order 0` 表示单个页,`order 1` 表示由 2 个页组成的页块,`order 2` 表示由 4 个页组成的页块,以此类推。 - 每一行后面的数字表示对应迁移类型的空闲页块数量。迁移类型包括 `MIGRATE_UNMOVABLE`、`MIGRATE_RECLAIMABLE`、`MIGRATE_MOVABLE` 等,它们分别表示不可移动的页、可回收的页和可移动的页 [^1]。 ### 示例代码 以下是一个简单的 Python 脚本,用于解析 `/proc/pagetypeinfo` 文件并打印出部分信息: ```python with open('/proc/pagetypeinfo', 'r') as f: lines = f.readlines() # 解析全局信息 page_block_order = int(lines[0].split(':')[1].strip()) pages_per_block = int(lines[1].split(':')[1].strip()) print(f"Page block order: {page_block_order}") print(f"Pages per block: {pages_per_block}") # 解析每个节点和区域的信息 for i, line in enumerate(lines): if "Node" in line and "zone" in line: node, zone = line.strip().split(',') print(f"\n{node}, {zone}") # 解析每个 CPU 的统计信息 cpu_start = i + 3 while "CPU" in lines[cpu_start]: cpu_info = lines[cpu_start].strip() nr_free_pages = int(lines[cpu_start + 1].split(':')[1].strip()) print(f"{cpu_info}, nr_free_pages: {nr_free_pages}") cpu_start += 7 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值