Chinaunix首页 | 论坛 | 博客
  • 博客访问: 184379
  • 博文数量: 36
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 445
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-26 10:26
文章分类

全部博文(36)

文章存档

2010年(3)

2009年(18)

2008年(15)

我的朋友

分类:

2008-05-25 22:53:11

引言:今天新学到的,以前也知道bindprocessor -q看CPU个数和prtconf看CPU个数的不同,当时以为是双核呢,就没深究,真是汗啊。
 
主题1:介绍bindprocessor的用法

bindprocessor 命令

用途

将进程的内核线程绑定至处理器或取消绑定至处理器。

语法

bindprocessor Process [ ProcessorNum ] | | Process

示例

  1. 要查看哪些处理器可用(可能的 ProcessorNum,输入:

    bindprocessor -q

    对于具有四个处理器的系统,输出与以下内容相似:

    可用的处理器是:0 1 2 3
  2. 要将进程 ID 为 14662 的进程 p1 绑定到处理器 1,可以使用命令: 
  3. # bindprocessor 14662 1  
    要确保该进程已绑定到指定的处理器,可以使用下面的命令进行查看:

    #ps -emo THREAD | grep p1
      USER   PID  PPID   TID ST CP PRI SC    WCHAN        F       TT     BND COMMAND
      root  4460  5428    -  A  0  60  7  f0145c10   240001    -    - /usr/sbin/rpc.mountd
      root  4710  5428    -  A  0  60   4     *       240001    -   - /usr/sbin/tftpd -n
      root 14662 10566    -  A 120 126 0    -     200001   pts/0   1        ./p1
     

    取消进程的绑定:

    # bindprocessor -u 14662
    


  4. 查看上述命令的结果:
    # ps -emo THREAD | grep p1
      USER   PID  PPID   TID   ST CP PRI   SC   WCHAN      F     TT        BND   COMMAND
      root  12672  10566   -    A  1 60    1  50a05e84   200001  pts/0      -      grep p1
      root  14662 10566  -    A  78 111  0      -             200001  pts/0    -     ./p1
    
    
主题2:解释为什么bindprocessor -q看到的CPU个数会是prtconf看到的个数的两倍
就是涉及到一个smt(同步多线程)的技术,简单解释启用smt的话,一个程序执行的时候,可以在一个CPU上用两个线程跑。前提,机器是power5的硬件和5.3的系统,我在p550q上运行smtctl可以看到支持,但是在p630上看是不支持的,因为p630是power4+的处理器。
具体的看看英文吧,写的比较详细:

smtctl Command

 

Purpose

 

       The smtctl command controls the enabling and disabling of processor

       simultaneous multi-threading mode.

 

Syntax

 

       smtctl [ -m off | on [ -w boot | now ]]

 

Description

 

       This command is provided for privileged users and applications to

       control utilization of processors with simultaneous multi-threading

       support. The simultaneous multi-threading mode allows processors to

       have thread level parallelism at the instruction level. This mode can

       be enabled or disabled for all processors either immediately or on

       subsequent boots of the system. This command controls the simultaneous

       multi-threading options.

 

If no options are specified then the following simultaneous multi-

       threading settings will be reported:

       SMT Capability

            Indicator that the physical processors are capable of simultaneous

            multi-threading.

       SMT Mode

            Current runtime simultaneous multi-threading mode of disabled or

            enabled.

       SMT Boot Mode

            Current boot time simultaneous multi-threading mode of disabled or

            enabled.

       SMT Threads

            Number of simultaneous multi-threading threads per physical

            processor.

       SMT Bound

            Indicator that the simultaneous multi-threading threads are bound

            on the same physical processor.

 

下面是我在一台p550q上运行的结果:

szzy2:/ # smtctl

 

This system is SMT capable.

 

SMT is currently enabled.

 

SMT boot mode is not set.

SMT threads are bound to the same physical processor.

 

proc0 has 2 SMT threads.

Bind processor 0 is bound with proc0

Bind processor 1 is bound with proc0

 

 

proc2 has 2 SMT threads.

Bind processor 2 is bound with proc2

Bind processor 3 is bound with proc2

 

 

proc4 has 2 SMT threads.

Bind processor 4 is bound with proc4

Bind processor 5 is bound with proc4

 

proc6 has 2 SMT threads.

Bind processor 6 is bound with proc6

Bind processor 7 is bound with proc6

 

也可以通过查看CPU的属性来看smt是否开启和它的具体设置
szzy2:/ # lsattr -El proc0
frequency   1648350000     Processor Speed       False
smt_enabled true           Processor SMT enabled False
smt_threads 2              Processor SMT threads False
state       enable         Processor state       False
type        PowerPC_POWER5 Processor type        False
同时有点小小的疑惑,为什么是proc0,2,4,6呢,为什么不是proc0,1,2,3呢,看下面,顺便把看CPU个数的命令都列一下:
看到实际CPU个数(4CPU)的命令:
prtconf
szzy2:/ # lsdev -Cc processor           
proc0 Available 00-00 Processor
proc2 Available 00-02 Processor
proc4 Available 00-04 Processor
proc6 Available 00-06 Processor

szzy2:/ # lsdev |grep -i proc
proc0       Available 00-00         Processor
proc2       Available 00-02         Processor
proc4       Available 00-04         Processor
proc6       Available 00-06         Processor

看到的8个LCPU的命令:
bindprocessor -q
szzy2:/ # vmstat 1 1
System configuration: lcpu=8 mem=16000MB
kthr    memory              page              faults        cpu
----- ----------- ------------------------ ------------ -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa
 1  0 2646988 299147   0   0   0   0    0   0  24 17808 13097 36  4 60  0
szzy2:/ # sar 1 1
AIX szzy2 3 5 0001E9F3D600    05/25/08
System configuration: lcpu=8  mode=Capped
22:29:58    %usr    %sys    %wio   %idle   physc
22:29:59       1       1       0      99    3.99
szzy2:/ # pmcycles -m
CPU 0 runs at 1648 MHz
CPU 1 runs at 1648 MHz
CPU 2 runs at 1648 MHz
CPU 3 runs at 1648 MHz
CPU 4 runs at 1648 MHz
CPU 5 runs at 1648 MHz
CPU 6 runs at 1648 MHz
CPU 7 runs at 1648 MHz
查看CPU频率的命令:
prtconf
lsattr -El proc0
pmcycles -m
阅读(1871) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~