天天看點

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

linux核心需要為臨時對象如任務或者裝置結構和節點配置設定記憶體,緩存配置設定器管理着這些類型對象的緩存。現代linux核心部署了該緩存配置設定器以持有緩存,稱之為片。不同類型的片緩存由片配置設定器維護。本文集中讨論slabtop指令,該指令顯示了實時核心片緩存資訊。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

<a target="_blank"></a>

該指令用起來很簡單,預設執行時不要求任何參數。但是它要求root特權來讀取核心片資訊。以普通使用者執行該指令會出現以下錯誤:

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

run slabtop as non-privileged user

你可以在前面設定“sudo”來運作該指令,預設輸出見下圖:

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

slabtop default output

要退出slabtop,隻需敲‘q’,就像在top指令中那樣。

預設情況下,slabtop每隔3秒重新整理一次。但是,如果你想要調整,可以使用-d或者--delay=n選項來調整重新整理間隔,以秒為機關:

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

custom delay interval 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

custom delay interval 02

在slabtop輸出中有很多字段,-s或--sort=s選項可以根據指定的排序标準對這些字段排序。該選項将在下一節中詳細講述。

-o或--once選項不會重新整理輸出,它僅僅将一次輸出結果丢給stdout,然後退出。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

output once and exit

-v或--version選項顯示指令的版本并退出。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

slabtop version

常見選項,-h或--help顯示指令的使用幫助。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

slabtop help options

排序标準确定了哪個片緩存顯示在頂部,下面是slabtop的排序标準:

緩存可以通過‘a’來對活躍對象編号進行排序。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by active 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by active 02

每分片對象數可以使用“b”來選擇。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by objects per slab 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by objects per slab 02

要選擇緩存大小,你需要提供“c”選項。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache size 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache size 02

分片數量,使用“l”來選擇。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by number of slabs 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by number of slabs 02

活躍分片數量。(注意:這不同于上面講得活躍對象數量。)使用“v”來根據該标準排序。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by active slabs 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by active slabs 02

緩存名稱。相關字元是“n”。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache name 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache name 02

要根據對象數量排序,使用“o”。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by number of objects 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by number of objects 02

“p”将根據每分片頁面數排序。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by pages per slab 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by pages per slab 02

對象大小排序由“s”來指定。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by object size 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by object size 02

“u”選項根據緩存使用量排序。

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache utilization 01

Linux slabtop指令——顯示核心片緩存資訊Linux slabtop指令——顯示核心片緩存資訊

sort by cache utilization 02

原文釋出時間:2014-08-28

本文來自雲栖合作夥伴“linux中國”

繼續閱讀