sar -W 和 sar -B 之间的区别?

sar -W 和 sar -B 之间的区别?

sar -W 和 sar -B 的输出有什么区别,它们看起来很相似,但手册页只会让我在这个问题上进一步困惑,有谁为我澄清这一点吗?

答案1

-W开关看起来是原来的开关,而该-B开关是后来出现的。手册页中的注释似乎也表明了这一点。该-B交换机具有较新的统计信息,这些统计信息在更高版本的 Linux 内核(2.5 后)中公开。

-W用法

-W 报告交换统计信息。显示以下值:

   pswpin/s
          Total number of swap pages the system brought in per second.
   pswpout/s
          Total number of swap pages the system brought out per second.

-B用法

-B 报告分页统计信息。下面的一些指标仅适用于 2.5 以后的内核。显示以下值:

   pgpgin/s
          Total number of kilobytes the system paged in from disk per second.  Note: With old  kernels  (2.2.x)  this
          value is a number of blocks per second (and not kilobytes).

   pgpgout/s
          Total  number  of  kilobytes  the system paged out to disk per second.  Note: With old kernels (2.2.x) this
          value is a number of blocks per second (and not kilobytes).

   fault/s
          Number of page faults (major + minor) made by the system per second.  This is not a count  of  page  faults
          that generate I/O, because some page faults can be resolved without I/O.

   majflt/s
          Number of major faults the system has made per second, those which have required loading a memory page from
          disk.

   pgfree/s
          Number of pages placed on the free list by the system per second.

   pgscank/s
          Number of pages scanned by the kswapd daemon per second.

   pgscand/s
          Number of pages scanned directly per second.

   pgsteal/s
          Number of pages the system has reclaimed from cache (pagecache and swapcache) per  second  to  satisfy  its
          memory demands.

   %vmeff
          Calculated as pgsteal / pgscan, this is a metric of the efficiency of page reclaim. If it is near 100% then
          almost every page coming off the tail of the inactive list is being reaped. If it gets too low  (e.g.  less
          than  30%)  then the virtual memory is having some difficulty.  This field is displayed as zero if no pages
          have been scanned during the interval of time.

例子

-B如果您查看和开关的输出-W,可能有助于阐明其中的差异。

-W

$ sar -W
02:50:01 PM  pswpin/s pswpout/s
03:00:01 PM      0.57      1.71
03:10:01 PM      0.31      0.02
03:20:01 PM      0.80      1.25
03:30:01 PM      0.41      0.68
03:40:01 PM      0.57      1.02
03:50:01 PM      0.88      0.00

-B

$ sar -B
02:50:01 PM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
03:00:01 PM     96.10    615.25   6113.00      0.44   7612.77    105.80      0.00     96.48     91.19
03:10:01 PM     14.91    562.47   5250.07      0.17   7029.09     26.63      0.00     23.72     89.08
03:20:01 PM     16.95    620.39   7265.82      0.26   9115.73     92.36      0.11     83.01     89.77
03:30:01 PM     28.84    566.17   8768.76      0.21  10750.77     63.20      0.21     58.65     92.49
03:40:01 PM     16.05    641.84  10343.84      0.31  12473.88     45.40      0.11     41.01     90.11
03:50:01 PM     18.20    647.99  10272.98      0.25  12187.26      0.00      0.00      0.00      0.00

不同之处在于,-W数据与一秒内换入和换出的页面数有关,而开关-B则显示一秒内换入/换出的数据总量(以千字节为单位)。

答案2

sar -B在我看来,手册页是不正确的。根据 Linux 源代码http://lxr.free-electrons.com/source/mm/page_io.c?v=4.6,PSWPIN 在 中递增swap_readpage()。如果单击该swap_readpage()函数,您可以看到它被直接调用来处理经典的虚拟内存内核分页(不要与交换混淆)。也就是说,当磁盘用作系统内存的附件时使用它。

PGPGIN 的维护submit_bio()如下所示:http://lxr.free-electrons.com/source/block/blk-core.c?v=4.6。单击它,您可以看到它用于更通用的磁盘 I/O。

Sosar -W的计数器指定与虚拟内存有关的页面(“交换”是一个术语,现在似乎使用得相当宽松,我相信它通常意味着“与将进程内存块保存到硬盘有关”磁盘”)。

sar -B的计数器(至少有几个)在有任何磁盘 I/O 时更新。其他计数器,例如fault/s,处理进程无法立即访问的任何内存页(请参阅http://linoxy.com/linux-command/commands-to-understand-page-faults-in-linux/,“...如果请求的页面驻留在主内存中,但由于未初始化的内存或 COW(写入时复制)页面,进程无法访问它,则称为次要页面错误...”)。 Google 可以帮助您更好地了解他们到底在计算什么。

相关内容