Protoss

千金散尽还复来,莫使金樽空对月


星期四 十一月 20, 2008

NPort ID Virtualization

What is NPort ID Virtulation
N_Port ID Virtualization (NPIV) is a technology that allows one physical HBA to login multiple times to a switch, with different WWN.
This is useful especially for virtualized server environments, such as xVM, LDom or VMWare.
By using virtual N Ports for each virtual server, the administrator can use traditional zoning and LUN masking techniques for SAN management.
However, it can also be useful for non xVM environment. In this way, one application could be given its own WWN.
A complimentary project is to do quality of service for the different NPIV ports.
This would allow one physical port to be fairly shared among devices.

Why use NPIV
1. Leverage Existing Fabric tools for storage management. For example: switch zoning, lun masking based on WWN
2. Broken HBA - no problem, replace HBA, and use the old WWN in the new HBA
3. Migrate virtual Severs from one physical server to another, zoning just works, because WWN follows virtual server. Currently, xVM must use open zoning, or at least zoning which includes all HBAs.
4. QOS. Use tools to segregate traffic based on WWN. Another implementation is to do per virtual port throttling - guarantee certain bandwidth to a certain port. This could be very useful in some environments, for example if a ISP sells a "virtual server"
5. Why do we need to access at SCSI layer This is important, because today xVM does not support SCSI access; in particular there is no easy way to use tape devices.

Hardware Support
Emulex : 4 Gb
Qlogic : 4 Gb, some 2 Gb
Brocade, Cisco, McData switches with recent firmware

How to use
You can use new user command fcadm to configure npiv port
# fcadm
Usage:  fcadm -?,-V,--help
Usage:  fcadm create-npiv-port [-?]
Usage:  fcadm delete-npiv-port [-?]
Usage:  fcadm hba-port [-?]
Usage:  fcadm remote-port [-?]
Usage:  fcadm create-port-list [-?]
For more information, please see fcadm(1M)

1. create a virtual port with random WWN
First we need check if the HBA card supports NPIV feature, we cann't create virtual port on a HBA card without supporting NPIV.
HBA port information shows "NPIV Not Supported" if it does not support NPIV,
otherwise it will show the maximum number of npiv ports it can support.

show physical ports on this system
bash-3.2# luxadm -e port            
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,emlxs@1/fp@0,0:devctl    CONNECTED
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@0,0:devctl      CONNECTED

show physical ports info on this system
bash-3.2# fcadm hba-port
HBA Port WWN: 10000000c96dff32
        Port Mode: Initiator
        Port ID: 20a00
        OS Device Name: /dev/cfg/c4
        Manufacturer: Emulex
        Model: LP11002-S
        Firmware Version: 2.72a2 (B3F2.72A2)
        FCode/BIOS Version: 1.50a9
        Serial Number: 0999BG0-07460001HN
        Driver Name: emlxs
        Driver Version: 2.31j (2008.07.22.16.03)
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 2Gb
        Node WWN: 20000000c96dff32
        NPIV Not Supported
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:

show physical ports attach point link to the devices path
bash-3.2# ls -l /dev/cfg/c3
lrwxrwxrwx   1 root     root          62 Sep  5 11:53 /dev/cfg/c3 -> ../../devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@0,0:fc
bash-3.2# ls -l /dev/cfg/c4
lrwxrwxrwx   1 root     root          64 Sep  5 11:53 /dev/cfg/c4 -> ../../devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,emlxs@1/fp@0,0:fc

create a virtual port with random WWN (no WWN assigned)
bash-3.2# fcadm  create-npiv-port 210000e08b84e3ea
bash-3.2# fcadm hba-port
HBA Port WWN: 10000000c96dff32
        Port Mode: Initiator
        Port ID: 20a00
        OS Device Name: /dev/cfg/c4
        Manufacturer: Emulex
        Model: LP11002-S
        Firmware Version: 2.72a2 (B3F2.72A2)
        FCode/BIOS Version: 1.50a9
        Serial Number: 0999BG0-07460001HN
        Driver Name: emlxs
        Driver Version: 2.31j (2008.07.22.16.03)
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 2Gb
        Node WWN: 20000000c96dff32
        NPIV Not Supported
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:
          Virtual Port1:
                Node WWN: c0007d5dc67c75f9
                Port WWN: c0007d5dc67c75f8

show new created virtual port info
bash-3.2# fcadm hba-port c0007d5dc67c75f8
HBA Port WWN: c0007d5dc67c75f8
        Port Mode: Initiator
        Port ID: 10301
        OS Device Name: /dev/cfg/c6
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: c0007d5dc67c75f9
        NPIV Not Supported
bash-3.2# luxadm -e port
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,emlxs@1/fp@0,0:devctl    CONNECTED
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@0,0:devctl      CONNECTED
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@1,0:devctl      CONNECTED
bash-3.2# ls -l /dev/cfg/c6
lrwxrwxrwx   1 root     root          62 Sep  5 14:18 /dev/cfg/c6 -> ../../devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@1,0:fc

2. create a virtual port with assigned WWN
bash-3.2# fcadm  create-npiv-port -p 1000000000000021 -n 1000000000000020 210000e08b84e3ea
bash-3.2# fcadm hba-port 210000e08b84e3ea
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:
          Virtual Port1:
                Node WWN: 1000000000000020
                Port WWN: 1000000000000021

3. delete a virtual port
bash-3.2# fcadm hba-port 210000e08b84e3ea
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:
          Virtual Port1:
                Node WWN: c0007d5dc67c75f9
                Port WWN: c0007d5dc67c75f8
bash-3.2# fcadm delete-npiv-port -p c0007d5dc67c75f8 210000e08b84e3ea
bash-3.2# fcadm hba-port 210000e08b84e3ea
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:
bash-3.2# luxadm -e port
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,emlxs@1/fp@0,0:devctl    CONNECTED
/devices/pci@7c0/pci@0/pci@1/pci@0,2/SUNW,qlc@2/fp@0,0:devctl      CONNECTED

NPIV and Sun xVM Server
Generally, and for most efficient operation, xVM requires device drivers to be modified to support xVM.
Device drivers operate either in the guest domain (called DOMU) or the device driver domain (usually DOM0).
Device drivers communicate between DOMU and DOM0 via descriptor rings.
These rings, or circular queues, are similar to what device drivers traditionally use to access hardware.
It's important to note that there is no way to directly call between DOM0 and DOMU.
The layer we're choosing is NPIV implemented entirely in DOM0.
The advantage is that it exposes a SCSI interface to DOMU, so devices such as tape can be used.
Issues (only cover NPIV in DOM0) DOMU does not have visibility into FC layer - hence no fcinfo, luxadm, cfgadm. However, DOM0 would have all this information.
1. Multipathing is simpler. All multipathing is done by Solaris DOM0. Could potentially be a negative, if customer wants to use a device for which Solaris does not support multipathing.
2. FCIP maybe is more complicated - have to interact with xVM networking?
3. Code should be simpler - no complicated interface. No need for agreement with other xVM operating systems on interface. Also, Leadville driver is identical between xVM and non xVM implementations. See

npiv&xVM

How to play it with xVM
For xVM supported NPIV, we use virsh to attach a LUN of FC target to the guest domain as a disk.

Attach a LUN of FC target to the guest domain.
virsh attach-disk <domian-name> <npiv:physical port wwn/virtual port wwn/array port wwn/LUN number> <target>
On Dom0 run
bash-3.2# virsh attach-disk 4632dom  npiv:210000e08b84e3ea/1000000000000020/20030003ba13f3fa/1 5
bash-3.2# fcadm hba-port 210000e08b84e3ea
HBA Port WWN: 210000e08b84e3ea
        Port Mode: Initiator
        Port ID: 10300
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3294-01
        Firmware Version: 04.04.01
        FCode/BIOS Version:  BIOS: 1.4; fcode: 1.11; EFI: 1.0;
        Serial Number: 0402F00-0549112906
        Driver Name: qlc
        Driver Version: 20080617-2.30
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb 4Gb
        Current Speed: 4Gb
        Node WWN: 200000e08b84e3ea
        Max NPIV Ports: 63
        NPIV port list:
          Virtual Port1:
                Node WWN: 1000000000000020
                Port WWN: 1000000000000021
On Domain 4632dom run format, you can find new LUNs attached to this domain
bash-3.2# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0d5 <DEFAULT cyl 1024 alt 0 hd 128 sec 32>
          /xpvd/xdf@5
       1. c0t0d0 <DEFAULT cyl 2559 alt 0 hd 128 sec 32>
          /xpvd/xdf@51712
Specify disk (enter its number):

Detach a LUN of FC target to the guest domain.
bash-3.2# virsh detach-disk 4632dom 5

Enjoy it :)

星期六 三月 22, 2008

用kmdb调试系统panic一例

 

[Read More]

星期二 十一月 27, 2007

Solaris thread limites

Solaris中LWP的数量限制可以这样计算:
Maximum = segkp_size / LWP内核堆栈大小
segkp_size是segkp内核地址空间段的大小,我们可以这样得到:
# kstat -n segkp
 module:vmem
 ...
       mem_total      2144879797   <- segkp_size
LWP内核堆栈的大小对于不同的操作系统是不一样的,
在UltraSPARC和x64体系结构中,LWP的内核堆栈大小是24k

对于32位应用程序来说,最大用户线程的数量受限于程序地址空间大小,
每个用户线程的堆栈大小是1Mb,32位应用程序的地址空间是4Gb,
这样最大用户线程数量就是4Gb/1Mb = 4000多个
而对于64位应用程序因为其地址空间的巨大,所以其数量限制基本上是不存在的. 

星期一 十一月 26, 2007

System Hang

用mdb去调试system hang[Read More]

星期三 八月 15, 2007

专家号

近日咽部总是感觉不适,咽干、灼热感、吞咽有异物感(很专业的说),
料来应该是咽炎犯啦,无甚大碍,
以往有此感觉,就是多饮热水,也不必吃药,三两天下来也就ok了。
谁知这次不同,几天下来,
这销魂的感觉非但没有减弱的迹象,反而是大有星火燎原之势,
莫不是老顽疾发生了病变?不是吧,这下玩大啦,
想我年纪轻轻,风华正茂,风流倜傥,玉树临风...
于是昨夜痛下决心,义无反顾,誓要独闯同仁医院。

临晨7点起床,
刷牙,洗脸,吃早餐;
搭黑车,挤轻轨,钻地铁,
我跋山涉水呀,我翻山越岭呦,
九点整终于到达同仁挂号处。

“看什么病”,护士mm长相soso,但是态度还算可以,
“咽喉疼痛”
“挂什么号”,近几年看过病的同志们都知道,
借着医疗改革的东风,北京各大医院都采取了专家号与普通号的规定,
至于何为专家,咱们平头百姓是不知道的。
当然既然是专家,总是有别于普通的,对于我们这些消费者来说区别就在几元钱之间,
想我年纪正轻,身体是革命的本钱,看病之事当然马虎不得,
“专家号”我爽快的回答,
“专家号只有下午1点的啦”,
我晕,7点起床都没赶上上午这拨!我忍,为了专家,1点就1点。

终于熬过漫长的等待,12点半,我来到专家会诊区,
只见不大的候诊区,人头攒动,心中不觉感叹,真是生意兴隆呀!
人虽然不少,但是还是要感谢北京同仁医院制定的FIFO(先进先出)的排队策略,
每个人只要将手中的病例以及挂号序号交给护士mm,就可以找位置坐下等待啦,
什么时候护士mm叫到你的名字,你就可以近诊室就诊了。
我找了个近电视的位置坐下,无聊的看着电视。
(个人感觉,其实现在医院的卫生情况没有太大的改观,但是装备倒是越来越先进啦)

身边的病友们一个一个被叫走,
“欧蜀甲”,一个熟悉而又陌生的名字在我耳边响起,
我faint~~,一定是拙劣的笔迹又一次将我推到一个尴尬的境地,
需要澄清的是,鄙人的大名是“欧蜀军”,
但是本人的笔迹着实够恶,以至于很多同志都无法辨别清楚,
记得上一次做体检的时候,一个漂漂的护士mm就亲切的称呼我“欧蜀早”
实事求是的说我的“军”字从某总字体来看确实与“早”字无异,
但是这次竟然有人将其念作“甲”字,我真的是出离愤怒了,
同志,我明明还多写了一横嘛!

“欧蜀甲”,“欧蜀甲在不在”,护士mm还在呼喊着,
我真是连劈了她的心都有啦,
急忙三步并作两步,“在在,我是哪个诊室”,我笑里藏刀的问道
“4诊室”,
算你回答的快,要不然,哼哼...

推开诊室的门,我被眼前的景象惊呆啦,
里面前前后后,男男女女站了三个白衣长衫,÷
专家身边还坐了一碧眼虬须白衣长者,两人时而俯首低语,时而谈笑风色,
再说专家,上身长3尺(他一直坐着,不好估计全身),
豹头环眼,燕颔虎须,声若巨雷,势如奔马,
一口明晃晃护心镜悬挂额前,
右手一乌黑釉亮8寸派客金笔,左手斜插胸前!

我连忙含胸垂首,嘴角微颤,“钱老”
我有一个专业的医师朋友,
从他哪里学了一招,他们医师之间往往以什么什么老相称(年纪大小不总要),以示尊敬,
为了表明我的敬意以及我内部人士的身份,并获得最高看病规格的接待,
这对专家的称呼上当然不能与普通病患一样。
这一招果然受用,
钱老嘴角微微一笑,当然这就是刹那间的事,
估计连身边的小大夫们都未必察觉,
但以我天赋异秉的超常观察力,这样的细节还是不会错过的。

“哪里不适?”,“有多久啦”
钱老边问边写,我是诚惶诚恐的回答着,
基本病史查询完毕,
钱老忽的抽出一银灿灿方天画戟直向我咽喉索了来,
“张嘴”,“吸气”“呼气,啊”
钱老这杆方天画戟在我口中天马行空,并教我一番吞云纳气,
只四分之一注香的时间,钱老收回兵器,右手换作派客金笔上下翻飞狂书一番
吾正感慨钱老专家风范,等待第二次过招之际,
钱老身边一贴身侍卫走过来,向我低语“先去把这笔钱交咯,然后再回来”

一种似曾相识的感觉涌上心头,好像哪里经过这种场面?
突然灵光一显,原来是在乌镇的古刹,
想当日,我和妻子在导游哄骗之下各抽了一只签并交由大师兄释签,
大师兄对我一番天南地北之后,对我说“施主你先去上注香,回来我再与你仔细道来...”

闪回渐渐消退,一则消费明细印入眼帘,
原来是刚才的方天画戟要啦老夫14大元,
难道进了这口腔科看病还有不需要方天画戟的?
如果需要何不将消费直接打入挂号费岂不是方便许多?
当然咱们不是专家,况且看病交钱天经地义嘛。
匆匆交了钱,回转身形,发现另一个病人已经开始诊治,
这才明白,原来我的诊断已经结束了,
正伸手去接病例和处方,突然想起自己到底是什么病还不知道呢。
“大夫,我是什么病”,“没什么大不了的,就是咽炎”
“能治么”,“呵呵,当然能治了”
“吃了这两副药就能治好了”,“哦,哪就不好说了”
“那要还是不好呢”,“哪就再回来看看”
“哪我需要注意什么嘛”,“少抽烟喝酒”

离开医院,回到家已经是4点多了
历经9个多小时,路费16元,医药费58.75
见护士mm若干,白衫大夫若干,专家一名
得到两盒冲剂,两瓶液剂,
一个不确定的答案,
一条至理名言:
“少抽烟喝酒”

PS:虽然答案不确定,但是至少专家确诊说是简单的咽炎,只是希望不是误诊!

星期一 八月 13, 2007

关于protoss

Protoss(神族)是暴雪开发的即时战略游戏星际争霸(StarCraft)中设定的三大种族之一。另两个是Zerg(虫族)和Terran(人族)
Protoss科技发达,善于运用精神能力,在战斗中十分强悍。他们是Zerg的主要对手。Protoss都严格信奉Khala。Protos在希腊语中是“第一”的意思。
在《星际争霸 》对战中,Protoss一般简写为Toss(或者Pross),对于经验更丰富的人来说一般只简写为一个字母——P

历史:
  Aiur是被忙于创造完美种族的Xel'Naga改造的诸多星球之一。Xel'Naga这些位于银河系外的遗传学家们一直在追寻“纯净的种族形态”,在经历了无数次失败之后来到了Aiur。
  他们发现了一些独特的种族,这些种族的猎人和战士们的确拥有纯净的种族形态,而且拥有极强的力量和速度。然而这个种族最有意思的能力是整个部族的成员都拥有心灵链接,这是一种本能的精神感应,使得他们能够迅速地和其他成员交流,所以即使是很大规模的族群也能保持极高的集体工作效率。
  Xel'Naga开始用他们的Khaydarin水晶慢慢改变这些种族,但是依然没有亲自在Protoss面前现身长达数个年代。Xel'Naga感觉达成了目的,将这个新种族命名为Protoss,或者叫做“初生者(the First Born)”。Aiur最终被文明的Protoss掌握,Xel'Naga决定降临Aiur来更仔细地研究他们。有一座神庙(The Lost Temple)标志着Xel'Naga第一次降临Aiur的位置。
  一开始Xel'Naga被尊奉为神,Protoss膜拜他们的创造者,同时开始求知。但是随着年轻的Protoss的知识以及个人意识的增长,他们逐渐开始把自我放于团体之上。部落之间逐渐疏远,他们开始向在宇宙中寻求自己的定位,而不是在Protoss社会之中。
  部落们开始担忧自己的忘恩负义,开始寻找切断和其他部落联系的方法,最终,无论是部落成员之间还是整个社会上都共同享有的心灵链接被他们切断了。Xel'Naga发现Protoss最主要的特征已经丧失了,于是开始撤离Aiur。这一举动使得怀疑Xel'Naga的Protoss对其发动了进攻,摧毁了数艘世界级舰只。Xel'Naga的其他船舰躲避开这次鲁莽的攻击,离开了星系。之后的Protoss部落们开始互相敌对,引发了银河史上最惨烈的内战——万世浩劫。

迷人的Solaris

Solaris是Sun公司开发和发布的操作系统,是UNIX系统的一个重要分支。

起源:首先从BSD Unix移植而来,随后逐渐转移到了System V标准。

支持平台:目前,Solaris除可以运行在SPARC CPU上外,还可以运行在X86 (IA32)的CPU上。最近又被移植到了最新的AMD64位CPU Opteron上.

市场地位:在服务器市场上,Sun的硬件平台具有高可用性和高可靠性,Solaris是当今市场上处于支配地位的Unix类操作系统。

下载:这些版本都可以从Sun的官方网站下载,也可以从国内外其他一些站点免费下载。对于难以接触到Sun SPARC架构计算机的用户可以通过使用Solaris x86体验世界知名大厂的商业Unix的风采。当然Solaris x86也可以用于实际生产应用的服务器。在遵守Sun的有关许可条款的情况下,Solaris x86可以免费用于学习研究或商业应用。

参考书目:国内关于Solaris的书籍还是比较多,从一些网上书店可以搜索到不少的关于Solaris的书籍,
强烈推荐《Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture, Second Edition》

Solaris的DTrace:
就像奥黛丽.赫本那清澈的明牟,
就像玛丽莲那性感的乌痣,
谈到Solaris10,我们不得不谈DTrace,华尔街时报2006年科技创新金奖得主。
再多华丽的辞藻,再多洋溢的赞美,再多羡慕的目光赠予这一项创新软件设计都不过分。
当然广告做的好没有用,要看它的疗效,
谁用谁知道呀~~~~

DTrace是一种故障诊断软件,
她是不同于我们以前用过的Debuger(调试工具),
什么单步跟踪,什么设置断点统统的没有,
使用DTrace检测,将对程序执行的影响降到最低,她就那样默默的注视着,注视着...
个人认为她更像是printf或printk,
她可以打印所有函数调用参数、所有内核全局变量、函数执行时的时间戳、函数调用的堆栈、调用函数的进程或线程,我靠太多东东啦(不好意思说了个dirty word,太激动了)

DTrace的设计理念是这样的:
各位程序员兄弟姐妹们,我呢为你们提供一些检测点(专业的说是 probe),你们可以用这些检测点记录也好、打印也罢显示内核或用户进程运行的相关信息。当然这些检测点会被一些特定的行为激活,激活之后你就可以定义一些动作,比如打印函数的调用参数值等等。

当然设计理念之类的东东都是很抽象地,
就像马克思主义理论、毛泽东思想,都是总结之总结、概括之概括、集大成之集大成
不是你我这类凡夫俗子所能理解的,还是举个例子来的直接,
下面就是一个简单的DTrace脚本
#!/usr/sbin/dtrace -s

syscall::write:entry
{
trace(timestamp);
}
这里“syscall”是检测点提供者(provider),“write”就是检测点(probe),“entry”就是检测点被激活的条件,当write被调用的时候激活,定义的动作(action)就是打印函数被调用时的时间戳。

更多细节可以参考
《Dtrace User Guide》和《Solaris Dynamic Tracing Guide》(强烈推荐)
可以在 http://docs.sun.com下载到


今日点击: 20