Solaris學習筆記(1)

作者: Badcoffee
Email: [email protected]
Blog: http://blog.csdn.net/yayong
2005年6月

 

一直以來就很想深入的學習Solaris,今天就開始這漫長的跋涉
之路吧:)

這方面比較好的參考資料有:
1. Solaris internal

Jim Mauro and Richard McDougall寫的這部書實在是太經典了,第一版是有中文版的,
第二版馬上也要出了。下面是這本書的網站,上面有作者的blog和其它一些有用的資料:

http://www.solarisinternals.com


2. Sun官方文檔站點

http://docs.sun.com

Solaris的man手冊,還有很多有用的學習資料,比如mdb,dtrace的手冊,都可以在這裏找到。

下面就是我學習mpstat命令的筆記,就先從這裏開始吧。


mpstat(1M)
NAME | SYNOPSIS | DESCRIPTION | OPTIONS | EXAMPLES | ATTRIBUTES | SEE ALSO | NOTES

NAME
mpstat- report per-processor or per-processor-set statistics

報告每個處理器或者每個處理器集合的統計數據


SYNOPSIS
/usr/bin/mpstat [-aq] [-p| -Pset] [interval [count]]

DESCRIPTION
The mpstat command reports processor statistics in tabular form. Each row of the table represents the activity of one processor. The first table summarizes all activity since boot. Each subsequent table summarizes activity for the preceding interval. All values are rates listed as events per second unless otherwise noted.

mpstat命令以列表形式報告處理器統計數據。表格的每行對應一個處理器的活動狀態。第一個表格統計了從系統引導以來的所有活動數據。接下來每個順序的表統計了到之前表時間間隔的活動數據。除非特別註明,所有列出的數據是按照每秒種事件速率。

 

During execution of the kernel status command, the state of the kernel can change. If relevant, a state change message is included in the mpstat output, in one of the following forms:


在執行內核狀態命令時,內核的狀態會改變。如果相關,狀態改變的信息被包括在mpstat的輸出裏,可以是下面的形式:

 

<<processor 3 moved from pset: -1 to: 1>><<pset destroyed: 1>><<pset created: 1>><<processors added: 1, 3>><<processors removed: 1, 3>>


The mpstat command reports the following information:

mpstat命令報告如下信息:


CPU or SET
Without the -a option, mpstat reports CPU statistics for a processor ID. With the -a option, mpstat reports SET statistics for a processor set ID.

沒有-a選項,mpstat以處理器ID來報告CPU統計數據。有-a選項,mpstat以SET(處理器集合)ID來報告SET統計數據


問題:什麼是SET?它與CPU差別?

這裏的SET是處理器集合,Solaris允許用戶進程綁定到指定數目的CPU組成的處理
器集合上。詳細信息可以看psrset(1M)。例如,可以創建一個具有兩個 CPU 的處
理器集,將我們的關鍵應用的進程與該處理器集綁定。另外,禁止該處理器集中的
CPU 上的中斷,從而不會有中斷髮生在該處理器集中的處理器上。這樣,這2個
CPU就只爲我們的關鍵應用服務了,從而保證服務穩定而且高效。


minf
minor faults

輔助錯誤minor faults個數


mjf
major faults

主要錯誤major faults個數
問題:什麼是major faults和minor faults?

Solaris虛擬內存管理是藉助MMU來實現的,一般MMU定義了三種異常:
major page faults、minor page faults、protection faults

major page faults發生在試圖訪問一個虛擬內存單元,該單元雖已經被map
到Solaris的某個段映像,但是並不存在於物理內存中,這時,MMU會觸發一個
缺頁中斷(x86)或者trap(sparc),導致內核處理程序比較該內存錯誤地址發生在
哪個段。如果不屬於任何一個段則給進程發送一個段錯誤SIGSEGV。否則,將
調用該段驅動程序的page-fault例程。調用該例程的結果可能是兩種:
1. 該內存存在於swap區,段驅動通過vnode的getpage函數,從swap讀入
到物理內存
2. 該內存從未被使用,需要新生成該頁

minor page faults發生在試圖訪問一個虛擬內存單元,該單元已經被map到
Solaris的某個段映像,並且已經存在於物理內存,但還未建立物理內存與虛擬地址
空間轉換關係。例如系統種的共享庫,就屬於這種情形,實際上多個進程只是共享
同一共享庫的物理內存頁,第一個引用共享庫的進程導致一個major page faults,
而之後的其它進程引用則只是minor page faults,attach在該庫的物理內存上。

protection faults發生在試圖訪問一個虛擬內存單元,該單元訪問方式與所在段的
訪問方式相悖。例如寫程序的代碼段將會導致該錯誤。
xcal
inter-processor cross-calls

交叉調用cross-calls的數目。
問題:什麼是cross-calls?
交叉調用即cross-calls(xcalls),是處理器到處理器的中斷。通常在SMP的系統中,
應用於MMU的TLB coherency任務,CPU控制,或者強制一個CPU進入內核態。
例如,在一個用戶進程提交一個unmap的操作,會通過cross-calls來通知多個CPU
將MMU的TLB中的入口刪除。
intr
interrupts

中斷數。


ithr
interrupts as threads (not counting clock interrupt)

中斷線程,不包括時鐘中斷

csw
context switches

上下文切換數


icsw
involuntary context switches

非主動的上下文切換數
指該上下文切換是調度程序強制切換的,是被其它高優先級的線程搶佔的。


migr
thread migrations (to another processor)

轉移到其它CPU的線程數

smtx
spins on mutexes (lock not acquired on first try)

在互斥鎖mutexes上的自旋(即第一次試圖獲得鎖未果)的次數

 

srw
spins on readers/writer locks (lock not acquired on first try)

在讀/寫鎖上自旋(即第一次試圖獲得鎖未果)的次數
syscl
system calls

系統調用數目

usr
percent user time

CPU用戶時間百分比
sys
percent system time

CPU系統時間百分比


wt
time CPUs are idle pending I/O operations. See the NOTES section for more information on wt time.

CPU等待IO操作的空閒時間。更多信息參考 NOTES小節的wt時間

 

idl
percent idle time

CPU空閒時間百分比

sze
number of processors in the requested processor set

請求的處理器集合中的處理器個數

 

set
processor set membership of each CPU

每個CPU的處理器集合的成員關係


OPTIONS
The following options are supported:

-a
Aggregate output by processor set. Sort the output by set. The default output is sorted by CPU number.

按照處理器集合來輸出結果,不加此選項默認是按照CPU數目來輸出。

-p
Report processor set membership of each CPU. Sort the output by set. The default output is sorted by CPU number.

報告每個CPU與處理器集合的成員關係。輸出按照處理器集排序。不加此選項默認輸出按照CPU號來排序。

-P set
Display only those processors in the specified set.

只顯示指定的處理器集的處理器統計。

-q
Suppress messages related to state changes.

不顯示狀態改變相關的信息。

interval
Report once each interval seconds.

每次報告間隔的秒數

count
Only print count reports.

只顯示指定次數的報告

EXAMPLES

--------------------------------------------------------------------------------

Example 1 Using mpstat to Generate User and System Operation Statistics
例1 使用mpstat產生用戶和系統操作統計數據


The following command generates processor statistics over a five-second interval in two reports. The command shows the processor set membership of each CPU. The default output is sorted by CPU number, aggregated by processor set, for user (usr) and system (sys) operations. See the NOTES section for more information on wt time.


下面的命令以5秒的間隔產生了2個處理器的統計數據報告。命令顯示了處理器集合與每個CPU的成員關係。默認用戶和系統操作的輸出是按照CPU 號,處理器集合排序。關於wt時間的更多信息請看NOTES小節。

 


example% mpstat -ap 5 2SET minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl sze 0 6 0 355 291 190 22 0 0 0 0 43 0 2 55 43 1 1 24 17 534 207 200 70 1 0 2 0 600 4 1 11 84 2 2 19 7 353 325 318 44 0 0 5 0 345 1 1 4 94 3 3 36 2 149 237 236 14 0 0 4 0 97 0 0 1 98 2SET minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl sze 0 1 0 720 405 304 55 0 0 18 0 12 0 15 4 81 1 1 0 69 1955 230 200 313 33 4 41 9 7086 34 10 37 19 2 2 0 46 685 314 300 203 11 0 54 1 5287 36 6 30 28 3 3 0 0 14 386 384 0 0 0 0 0 0 0 0 0 100 2

--------------------------------------------------------------------------------

ATTRIBUTES
See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
Interface Stability See below.

Invocation is evolving. Human readable output is unstable.

SEE ALSO
sar(1), iostat(1M), sar(1M), vmstat(1M), attributes(5)

NOTES
The sum of CPU utilization might vary slightly from 100 due to rounding errors in the production of a percentage figure.

CPU佔用率的統計由於舍入錯誤,也許在百分比數字的總和略有不同,不是100。


The total time used for CPU processing is the sum of usr and sys output values, reported for user and system operations. The wt value reports the time that processors are idle pending I/O operations. The idl value reports the time that the CPU is idle for any reason other than pending disk I/O operations. The total amount of idle CPU time is, therefore, the sum of wt and idl output values.

CPU處理的總時間是用戶和系統操作報告的值usr和值sys的和。值wt報告的是處理器空閒等待IO操作的時間。值idl報告的是CPU除去等待磁盤IO操作外的因爲任何原因而空閒的時間。CPU空閒的時間總數因此應該是wt和idl輸出值之和。


High wt times indicate problems in the disk subsystem, not problems with CPUs or other processing elements. Excessive wt times must be addressed by improving the performance, especially the service times, of the busiest disk devices. Run the iostat command with the -x option to report I/O service times in svc_t output. The iostat utility also reports the same wt, user (us), and system (sy) statistics. See iostat(1M) for more information.

wt的時間高意味着磁盤子系統的問題,不是CPU和其他部分的問題。過高的wt時間必須通過提高性能,特別是最忙的磁盤設備的服務時間來解決。


When executing in a zone and if the pools facility is active, mpstat(1M) will only provide information for those processors which are a member of the processor set of the pool to which the zone is bound.


當在一個zone裏執行,如果pools facility處於活動狀態,mpstat將只提供屬於zone綁定的pool的處理器集合的成員的那些處理器的信息。


個人體會:mpstat與其它統計工具一樣,不能夠僅靠一個工具,或者工具報告的一個值就簡單的給系統下結論。而且,統計數據的值到底達到多少纔算很高,也和系統的 配置,具體環境相關。分析系統性能,需要利用多個工具,相互印證,找出聯繫。Solaris 10推出的dtrace超越了傳統的unix系統提供的性能工具,我們可以用dtrace的sysinfo provider來完成所有的性能分析工作。


本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/yayong/archive/2005/06/07/389903.aspx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章