2011年4月27日星期三

HOWTO disable failsafe mode in Openwrt

https://forum.openwrt.org/viewtopic.php?id=28227

$ edit package/base-files/files/lib/preinit/30_failsafe_wait


and make ...



intersection and union: find the difference between two directories

SZLUG April monthly meeting

There are three main topics during the meeting.

Rockins's topic is a very good starting-point, even including the study case, TP-LINK's hiring ads.


Bring up Vxworks on a MIPS core, by Rockins Chen

  • why vxworks: see pro and con below
    1. pro: simplicity, high quality code, document everything
    2. con: proprietary, less existed package, inactive community
  • basic:
    1. multi-tasking
    2. inter-task
    3. communication
    4. mm(first-fit)
    5. IO system, UNIX-like file/dir/device, POSIX AIO …
    6. fs: dosFs, rawFs, tapeFs, cdromFs, TSFs, TrueFFS for flash devices
    7. network: TCP/IP, 802.1x, IPSec, NAT/NAPT, OSPF, Firewall, PPP …
  • A glance of VxWorks
    1. libdrv.a, libnet.a, libarch.a, libos.a, libwind.a
    2. all = libxxx.a + BSP = libxxx.a + bootcode + basic device driver
  • bootcode: arch dependent code
    1. Cache, TLB, GRs in CPU, CP0's regs, PLL, DDR
    2. watchdog, Exception/Interrupt, RTC, GPIO
  • case 1: slow loop on SPI flash
  • case 2: busy stuck of interrupt
    1. MIPS CPU has 4 general purpose timer
  • case 3: load delay shot on MIPS R3000
  • case 4: stochastically stuch when jumping to vxworks
  • case 5: stochastically soft reboot failure due to PLL switch
    1. resolution x3
  • importance of bsp:
    1. availablity
    2. reliability
    3. stability
    4. performance
  • things bsp engineer need to know (!!!)
    1. arch: Instuctions, Pipeline, cache, exception/interrupt
    2. Mem: SDRAM, DDR, NOR/NAND
    3. Bus: UART, JTAG, SPI
    4. Misc: PLL, Timer, GPIO, watchdog, DMA
    5. OS & toolchain
    6. Debug: ICE, debugger
  • Time for questions:
    1. cache coherency
    2. SoC problem
    3. how and how hard to be a bsp engineer

SZLUG and the cloud computing platform, by Haibo Zhang

6281 and QNAP system image, by sniperpr

  • Market positioning of 6281
  • Collaborative development with a Shanghai guy
  • Introduction of QNAP image


2011年4月12日星期二

IOWAIT - 测试IO性能的标尺

有个客户给我发邮件,告知我,他们曾对自己的板子和现在正在测试的 Marvell 6281 主板 进行对比测试。发现磁盘I/O操作时候的CPU空闲时间有出入。询问是否是6281的IO效率太低 了。

mpstat 数据如下:

Marvell 6281
CPU %usr %nice %sys %iowait %irq %soft %idle
all 0.00 0.00 5.98 93.69 0.00 0.33 0.00
all 0.00 0.00 3.65 96.01 0.00 0.33 0.00
all 0.66 0.00 7.97 89.37 0.00 1.99 0.00
M5000
CPU %usr %nice %sys %iowait %irq %soft %idle
all 17.67 0.00 22.33 0.00 0.00 0.00 60.00
all 11.33 0.00 22.00 0.00 0.00 0.00 66.67
all 7.33 0.00 16.33 0.00 0.00 0.00 76.33

客户认为M5000的 iowait 为0,那么CPU等待IO完成的时间是没有的,因此他的磁盘性能很 好,CPU不去干预;而6281的iowait%太高,CPU都在等,磁盘效率低下。

误区:CPU在 iowait 的时候傻等

这里最要命的就是 iowait 概念。参考 mpstat 手册

CPU 的时间片在 mpstat 眼中划分为很多种类,在UP(unique processor)系统中

%usr + %nice + %sys + %iwoait + %irq + %soft + %steal + %guest + %idle = 100%

  • %usr, CPU 运行用户程序的时间比
  • %nice, CPU 运行修改过进程优先级的用户程序时间比
  • %sys, CPU 运行内核程序的时间比
  • %iowait, 显示CPU在拥有磁盘I/O请求时候的_空闲_时间比
  • …
  • %idle,现实CPU没有磁盘I/O请求时候的_空闲_时间比

而其中的 %usr + %nice + %sys 是真正CPU在忙的时间,而其他都属于空闲期。 由上可知, 6281 在磁盘测试的时候使用了 0+0+5.98 = 5.98% 的CPU时间来处理I/O请求, 而 M5000 则使用了 17.63+0+22.33 = 40%,很明显 M5000 的磁盘IO更加占用CPU时间。

iowait 指标

%iowait 同样也属于空闲期,但是细分成了属于等待磁盘I/O完成的空闲时间,CPU不会傻等 。一旦CPU有其他请求,他会立刻响应。

高的 iowait 代表 CPU早早完成了IO请求的处理而等待磁盘IO的完成。一旦 iowait 逼近 100%,则代表CPU够闲的同时磁盘IO性能过低,总结为磁盘IO成了系统瓶颈。

而M5000 花费了 40% 的CPU 时间来处理请求,这个时候IO传输已经完成,他根本没有等待 时间。这显得 CPU 性能相对磁盘IO反而心力不足,在密集型IO请求的系统中 CPU 会显得 很吃力。

调校 IO 性能

IO性能的调校有超多的方法

  1. 硬件形成磁盘阵列 raidx
  2. hdparm 微调磁盘性能
  3. 选用合适的 IO scheduler (/sys/block/sda/queue/scheduler)

同样也可以配合以下工具来试试

  1. mpstat,适用于 SMP 系统下的监控工具,包含在 sysstat
  2. iostat,可以察看IO都写请求的次数等详细数据,包含在sysstat
  3. sar, 可以查看网络 IO 性能数据
  4. oprofile,可定制的系统微调工具,工作方式类似与 systemtap
  5. fio
  6. nmon
  7. iozone


2011年3月24日星期四

物理简史 之 爱因斯坦相对论

注明: 略微看了一下物理简史,算是一个科普吧。

背景介绍

二十世纪两大理论,是对牛顿力学的革命

  1. 量子论
  2. 相对论

光波有介质吗?以太的存在?

  1. 波动说,需要介质,christian huygens
  2. 微粒说,不需要介质,newton
  3. 电磁说,麦克斯韦,赫兹
  4. 光子说,解释了电磁说中的光电效应,爱因斯坦

爱因斯坦1905四部论文

  1. 光电效应的解释,引入光子概念 NOBEL
  2. 利用统计力学来解释布朗运动,证明了原子的存在
  3. 狭义相对论
  4. 质能方程式

爱因斯坦1907长篇论文

  1. 运动中的质量会变大,速度越大,加速度越小,这样没有超越光速的可能
  2. 质能方程式 E=mc^2

狭义相对论

狭义相对论原理(公理) by Einstein in 1905

  1. 相对性原理: 所有“惯性参考架构”,对物理而言,无主从之别
  2. 光速不变远离: 真空中的光速,在任何“惯性参考架构”中皆是同值

所谓“惯性参考架构”,适用于牛顿力学中则指重力世界,但是架构不指有一个。狭义相对 论的推导成果有:

  1. 否定以太,因为没有绝对静止和绝对速度
  2. 不能测得的量,不能称之为物理量,也不能成为物理研究的对象
  3. 推导出洛仁兹转换式
  4. “四度空间”。时间和空间是实在的,并且可以有限度的转换,不能截然分别
  5. 物体不可以追上光,光速是所有速度的极限

等效原理: 局部(短时间、小范围)而言,重力场与参考架构的加速度是等效的

广义相对论

广义相对论 by Einstein in 1915

  1. 爱因斯坦方程式 Guv = kMuv
  2. 弯曲的时空
  3. 重力场
  4. 光之红位移与光之偏折

狭义相对性原理虽然把伽利略相对性原理推广到了整个物理领域,但并不能包括非惯性参考 系。爱因斯坦把相对性原理推广到一切参考系。

资料