2014-08-06 11:46:26 +08:00
|
|
|
|
Linux slabtop命令——显示内核片缓存信息
|
2014-07-14 17:42:02 +08:00
|
|
|
|
================================================================================
|
|
|
|
|
|
2014-08-26 16:30:55 +08:00
|
|
|
|
Linux内核需要为临时对象如任务或者设备结构和节点分配内存,缓存分配器管理着这些类型对象的缓存。现代Linux内核部署了该缓存分配器以持有缓存,称之为片。不同类型的片缓存由片分配器维护。本文集中讨论slabtop命令,该命令显示了实时内核片缓存信息。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
### 1. 命令用法: ###
|
|
|
|
|
|
|
|
|
|
该命令用起来很简单,默认执行时不要求任何参数。但是它要求root特权来读取内核片信息。以普通用户执行该命令会出现以下错误:
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
你可以在前面设置“sudo”来运行该命令,默认输出见下图:
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
2014-08-26 16:30:55 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
要退出slabtop,只需敲‘q’,就像在top命令中那样。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
### 2. Slabtop选项: ###
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 2.1 显示间隔: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
默认情况下,slabtop每隔3秒刷新一次。但是,如果你想要调整,可以使用-d或者--delay=N选项来调整刷新间隔,以秒为单位:
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 2.2 排序标准: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
在slabtop输出中有很多字段,-s或--sort=S选项可以根据指定的排序标准对这些字段排序。该选项将在下一节中详细讲述。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 2.3 输出一次: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-26 15:35:09 +08:00
|
|
|
|
-o或--once选项不会刷新输出,它仅仅将一次输出结果丢给STDOUT,然后退出。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 2.4 版本信息: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
-V或--version选项显示命令的版本并退出。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 2.5 帮助: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
常见选项,-h或--help显示命令的使用帮助。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
### 3. 排序标准: ###
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
排序标准确定了哪个片缓存显示在顶部,下面是slabtop的排序标准:
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.1 活跃: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
缓存可以通过‘a’来对活跃对象编号进行排序。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.2 对象/分片: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
每分片对象数可以使用“b”来选择。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.3 缓存大小: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
要选择缓存大小,你需要提供“c”选项。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.4 分片: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
分片数量,使用“l”来选择。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.5 活跃分片: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
活跃分片数量。(注意:这不同于上面讲得活跃对象数量。)使用“v”来根据该标准排序。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.6 名称: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
缓存名称。相关字符是“n”。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.7 对象: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
要根据对象数量排序,使用“o”。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.8 每分片页面数: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
“p”将根据每分片页面数排序。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.9 对象大小: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
对象大小排序由“s”来指定。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
#### 3.10 使用: ####
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
“u”选项根据缓存使用量排序。
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
via: http://linoxide.com/linux-command/kernel-slab-cache-information/
|
|
|
|
|
|
2014-08-06 11:46:26 +08:00
|
|
|
|
译者:[GOLinux](https://github.com/GOLinux) 校对:[校对者ID](https://github.com/校对者ID)
|
2014-07-14 17:42:02 +08:00
|
|
|
|
|
2014-08-06 11:09:59 +08:00
|
|
|
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|