【问题标题】:What do the counters in /proc/[pid]/io mean?/proc/[pid]/io 中的计数器是什么意思?
【发布时间】:2010-09-03 05:41:24
【问题描述】:

我正在为Munin 创建一个插件来监控命名进程的统计信息。信息来源之一是/proc/[pid]/io。但我很难找出rchar/wcharread_bytes/written_bytes 之间的区别。

它们不一样,因为它们提供不同的值。它们代表什么?

【问题讨论】:

  • 希望你不要介意这些变化,有些(尤其是我)不熟悉少数民族项目,不太熟悉古代语言的项目;)
  • 我可以忍受,但它并没有那么小,真的。我认为它部署得很好。

标签: linux linux-kernel procfs


【解决方案1】:

虽然proc manpage 严重落后(大多数与千篇一律的用户空间开发无关的手册页/文档也是如此),幸运的是,这些内容完全记录在Linux kernel source 下的Documentation/filesystems/proc.rst 中。以下是相关位:

rchar
-----

I/O counter: chars read
The number of bytes which this task has caused to be read from storage. This
is simply the sum of bytes which this process passed to read() and pread().
It includes things like tty IO and it is unaffected by whether or not actual
physical disk IO was required (the read might have been satisfied from
pagecache)


wchar
-----

I/O counter: chars written
The number of bytes which this task has caused, or shall cause to be written
to disk. Similar caveats apply here as with rchar.


read_bytes
----------

I/O counter: bytes read
Attempt to count the number of bytes which this process really did cause to
be fetched from the storage layer. Done at the submit_bio() level, so it is
accurate for block-backed filesystems. <please add status regarding NFS and
CIFS at a later time>


write_bytes
-----------

I/O counter: bytes written
Attempt to count the number of bytes which this process caused to be sent to
the storage layer. This is done at page-dirtying time.

【讨论】:

  • cancelled_write_bytes --------------------- 这里最大的不准确之处是截断。如果一个进程将 1MB 写入文件然后删除该文件,它实际上不会执行写出。但它会被认为造成了 1MB 的写入。换句话说:该进程通过截断页面缓存导致未发生的字节数。任务也可能导致“负面”IO。如果此任务截断了一些脏页缓存,则另一个任务(在其 write_bytes 中)已占用的一些 IO 将不会发生。我们可以从截断任务的 write_bytes 中减去它...
  • 重要的是要知道通过使用 memmap 完成的 IO 不会显示在这些计数器中,并且目前无法轻松测量此类访问
猜你喜欢
  • 1970-01-01
  • 2012-04-12
  • 2018-10-19
  • 1970-01-01
  • 1970-01-01
  • 2018-05-25
  • 2021-09-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多