免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1378 | 回复: 0
打印 上一主题 下一主题

Solaris学习笔记(1) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-06-06 13:16 |只看该作者 |倒序浏览

Solaris学习笔记(1)

作者: Badcoffee
Email: blog.oliver@gmail.com
Blog:
[color="#000080"]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
    [color="#c00000"]mpstat– report per-processor or
    per-processor-set
    statistics
    报告每个处理器或者每个处理器集合的统计数据

SYNOPSIS
    /usr/bin/[color="#c00000"]mpstat [-aq]
    [-p| -Pset] [interval
    [count]]

DESCRIPTION

    The [color="#c00000"]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 [color="#c00000"]mpstat output,
    in one of the following forms:
      
    在执行内核状态命令时,内核的状态会改变。如果相关,状态改变的信息被包括在mpstat的输出里,可以是下面的形式:
      
      
       
          
             
            >
    >
    >
    >
    >
            
          
       
      
      
    The [color="#c00000"]mpstat command
    reports the following information:
    mpstat命令报告如下信息:
       
       
        CPU or SET
          
    Without the -a option, [color="#c00000"]mpstat
    reports CPU statistics for a processor ID. With the -a
    option, [color="#c00000"]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 [color="#c00000"]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% [color="#c00000"]mpstat -ap 5 2
    SET 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   2
    SET 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

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, [color="#c00000"]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来完成所有的性能分析工作。
      
Technorati tags:
OpenSolaris
Solaris


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/768/showart_29466.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP