2008年11月30日 星期日

Using Bonnie++

file creates
metadata benchmarks

The number of seeks per second should be fairly bound by your hardware

The rewrite test is important if you are running applications that modify data in place

benchmarks reported as +++++
when that particular benchmark completes too quickly
use the -n option to specify that more files should be used for the metadata tests
-n file_num:file_size_max:file_size_min:dir_num
default is 16:0:0:1

#!/bin/sh
target=/home/test/tmp;
logfile=bonnie.log;

mkdir $target -p; rm $logfile -rf;

size=0;
step=10000;
while [ $size -le 1000000 ] ; do
bonnie++ -d $target -n 32:$size:$size:10 -q -u 0 >> $logfile
size=$(($size+$step));
done;




http://www.coker.com.au/bonnie++/

Benchmark Tool - bonnie++
http://vk-work.blogspot.com/2006/06/benchmark-tool-bonnie_115124950416203700.html

使用Bonnie++进行系统IO性能测试
http://www.eygle.com/archives/2004/10/use_bonnie_plus2_test_iospeed.html

Using Bonnie++ for filesystem performance benchmarking
http://www.linux.com/feature/139742

A new utility for quickly interpreting multiple Bonnie++ benchmarks
http://www.linux.com/feature/139743

SSD vs. SATA RAID: A performance benchmark
http://www.linux.com/feature/142657

SSD vs. SATA benchmarks, round 2: Server applications
http://www.linux.com/feature/142658

Benchmarking hardware RAID vs. Linux kernel software RAID
http://www.linux.com/feature/140734

2008年11月24日 星期一

Linux PCI (linux-2.6.27.4)

include/linux/init.h

/*
* Early initcalls run before initializing SMP.
*
* Only for built-in code, not modules.
*/
#define early_initcall(fn) __define_initcall("early",fn,early)

/*
* A "pure" initcall has no dependencies on anything else, and purely
* initializes variables that couldn't be statically initialized.
*
* This only exists for built-in code, not for modules.
*/
#define pure_initcall(fn) __define_initcall("0",fn,0)

#define core_initcall(fn) __define_initcall("1",fn,1)
#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
#define postcore_initcall(fn) __define_initcall("2",fn,2)
#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s)
#define arch_initcall(fn) __define_initcall("3",fn,3)
#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s)
#define subsys_initcall(fn) __define_initcall("4",fn,4)
#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s)
#define fs_initcall(fn) __define_initcall("5",fn,5)
#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s)
#define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs)
#define device_initcall(fn) __define_initcall("6",fn,6)
#define device_initcall_sync(fn) __define_initcall("6s",fn,6s)
#define late_initcall(fn) __define_initcall("7",fn,7)
#define late_initcall_sync(fn) __define_initcall("7s",fn,7s)

#define __initcall(fn) device_initcall(fn)

(..................)

/**
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion
*
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/
#define module_init(x) __initcall(x);


The PCI initial sequence: (arch specific not included)

drivers/pci/pci.c: early_param("pci", pci_setup);
drivers/pci/pci-driver.c: postcore_initcall(pci_driver_init);
drivers/pci/pci-acpi.c: arch_initcall(acpi_pci_init);
drivers/pci/slot.c: subsys_initcall(pci_slot_init);
drivers/pci/pcie/aspm.c: fs_initcall(pcie_aspm_init);
drivers/pci/pci.c: device_initcall(pci_init);
drivers/pci/proc.c: device_initcall(pci_proc_init);
drivers/pci/pci-sysfs.c: late_initcall(pci_sysfs_init);






http://blog.csdn.net/fudan_abc/category/345294.aspx

Linux 2.6.10内核下PCI Express Native热插拔框架的实现机制
http://www.ibm.com/developerworks/cn/linux/l-pcie/

System and method for balancing pci-express bandwidth
http://www.freshpatents.com/System-and-method-for-balancing-pci-express-bandwidth-dt20081023ptan20080263246.php

Rather than taking advantage of multiple traffic classes and virtual lanes, existing PCI-Express adapters only support one virtual channel and one traffic class. Moreover, the primary operating systems, i.e. Microsoft Windows and Linux, only use one traffic channel and one virtual lane. As a result, currently known environments often encounter problems where the total possible bandwidth of a set of PCI-Express adapter cards within an I/O drawer attached to a CPU complex via an I/O hub or switch may far exceed the capabilities of the I/O hub, switch, and/or the front-side bus.


include/linux/ioport.h
/*
* Resources are tree-like, allowing
* nesting etc..
*/
struct resource {
resource_size_t start;
resource_size_t end;
const char *name;
unsigned long flags;
struct resource *parent, *sibling, *child;
};

2008年11月23日 星期日

2008年11月19日 星期三

便當 = Lunch box (meal box)

公司來了個印度人...
也不知道是怎麼搞的變成我帶他去吃飯...
我本來自以為英文不算差的...
可是字彙太少...
常常某個關鍵詞不知道怎麼說~~

2008年11月17日 星期一

偽春菜

核心程式 ==> 如以下的SSP

除了前文歷史所說的伺か(materia)系列,現今通行的大多是依據Sakura語法為標準所製成的其他核心程式。而其中又因為作業系統的不同而有不同的核心程式。另外在比喻上,就如同同一個軟體可能無法同時在Windows或Unix上作業,有時特定人格(程式)遇上特定核心程式(平台),也會發生一些衝突的狀況。不過因為主要還是依據Sakura語法,以及目前各核心程式的開發者們也有相互交流,所以通常都只是些小問題。


Ghost (人格) & Shell (外表)
如: 愛理&都馬


「絕對領域」的起源
http://lordmi.memory-off.org/wordpress/archives/1148

[wiki]偽春菜
http://zh.wikipedia.org/wiki/%E5%81%BD%E6%98%A5%E8%8F%9C

中文偽春菜後援會論壇
http://cuc2.idv.tw/index.php

SSP CERS 臨時頁面
http://cers.cuc2.idv.tw/
http://cers.cuc2.idv.tw/files/tssp2.01.54.zip


[繁中]愛理&都馬
http://cuc.moe.hm/attachment.php?aid=373&k=15212df1a839a3546217c9ccad1628eat=1226986256

[日文]愛理&都馬
http://www.aqrs.jp/cgi-bin/ghostdb/entryview2.cgi?ID=31

追蹤最新 Linux Kernel 開發狀況

http://people.debian.org.tw/~chihchun/2008/09/29/following-kernel-development/


http://lkml.org/rss.php

Groupie(Linus Torvalds)
http://lkml.org/groupie.php

Groupie(Andrew Morton)
http://lkml.org/groupie.php?author=Andrew+Morton
http://lkml.org/groupie.php?author=<keyword1>+<keyword1>

http://gmane.org/
http://dir.gmane.org/index.php?prefix=gmane.comp.handhelds.openmoko
http://dir.gmane.org/gmane.comp.handhelds.openmoko.community
4. Topics from the list, with complete texts.

我是只看topic,有興趣的topic就點進去看其他的回文,才不會被一堆沒興趣的回文洗.....

但是linux.kernel實在太多了,只看topic也看不完,就只看Linus,意思到了就好...^^""

2008年11月13日 星期四

Freerunner USB host mode

我一直以為OTG不是應該可以自己偵測是device還是host mode嗎?

You may want to run ifconfig usb0 down prior to switching to USB host mode

USB host/device mode setting
/sys/devices/platform/s3c2410-ohci/usb_mode
echo "host" > /sys/devices/platform/s3c2410-ohci/usb_mode

Enable USB 5 volt USB power to an attached USB device
/sys/devices/platform/neo1973-pm-host.0/hostmode
echo "1" > /sys/devices/platform/neo1973-pm-host.0/hostmode

script

#!/bin/sh
grep -q 'host' /sys/devices/platform/s3c2410-ohci/usb_mode
if [ $? -eq 0 ]
then
echo "0" > /sys/devices/platform/neo1973-pm-host.0/hostmode
echo "device" > /sys/devices/platform/s3c2410-ohci/usb_mode
echo USB-Port is in device-mode now.
else
ifconfig usb0 down
echo "host" > /sys/devices/platform/s3c2410-ohci/usb_mode
echo "1" > /sys/devices/platform/neo1973-pm-host.0/hostmode
echo USB-Port is in host-mode now.
fi


desktop icons is at
/usr/share/applications for non-QT?
/opt/Trolltech/Qtopia/services for Qt


http://blogs.thehumanjourney.net/finds/entry/20080716
http://wiki.openmoko.org/wiki/USB_host
http://blogs.thehumanjourney.net/finds/entry/usb_host_mode_the_button
http://wiki.openmoko.org/wiki/Specialized_USB_cables

2008年11月12日 星期三

利率一碼=0.25%

利率一碼=0.25%

貸款100萬20年(240期)固定月繳
每月還本金4166
每1%每個月大約差500 (根據實際利息會不一樣,1%: 432~10%: 653)
每1碼每個月大約差125

存款100萬
利息 每1%每月差833(每年~10000) (固定的,不會不一樣)
利息 每1碼每月差208(每月~2500)

2008年11月11日 星期二

Openmoko accelerometer

http://wiki.openmoko.org/wiki/Accelerometer_data_retrieval
http://www.jollen.org/blog/2008/11/programming_freerunner_accelerometer.html

debian: no usbethernet
fdom: no usb ethernet
qte: no python/perl

想看看debian有什麼問題,卻一直無法login
http://wiki.openmoko.org/wiki/Manual_Debian

2008年11月10日 星期一

Python & Perl

[wiki] Python
http://zh.wikipedia.org/wiki/Python
http://en.wikipedia.org/wiki/Python_(programming_language)

[wiki] Perl
http://zh.wikipedia.org/w/index.php?title=Perl&variant=zh-hant
http://en.wikipedia.org/wiki/Perl

[wiki] GTK+
http://zh.wikipedia.org/w/index.php?title=GTK%2B&variant=zh-hant
http://en.wikipedia.org/wiki/GTK%2B

[wiki] Enlightenment Foundation Libraries (EFL)
http://en.wikipedia.org/wiki/Enlightenment_Foundation_Libraries

2008年11月6日 星期四

Linux kernel module parameters

modprobe usbcore autosuspend=2
=> grub kernel option
usbcore.autosuspend=2

檢視module有多少parameter
modinfo -p ${modulename}

已經insert的module的參數在
/sys/module/${modulename}/parameters/

2008年11月5日 星期三

Understanding Fabless IC Technology

This book talks mostly about the bussiness model, than technique of the fabless semiconductor industry.


Fabless Semiconductor Association(FSA)
Integrated Device Manufacturer(IDM)
Electronic Design Automation(EDA)
foundry
Original Equipment Manufacturer(OEM)

Semiconductor Processes
Complimentary Metal Oxide Semiconductor(CMOS)
Specialty/Compound
  • Silicon Germanium (SiGe)
  • Gallium Arsenide (GaAs)
  • Indium Phosphide (InP)
  • BiCMOS
  • Gallium Nitride (GaN)

Semiconductor Manufacturing Steps
  • Wafer Production
  • Wafer Processing
    • Thermal Oxidation
    • Photolithography
    • Etching
    • Doping
  • Dicing
  • Assembly/Packaging
  • Test
Wafer size
The cost factor is the sole reason companies choose to use larger wafers.

Non-Recurring Engineering (NRE)

Design cycle
  • front-end design
    • architectural, system register-transfer-level (RTL) design
    • verification
    • logical synthesis
  • back-end design (physical design)
    • floorplanning
    • placement
    • routing
    • timing closure
    • physical verification

EDA is the bridge between manufacturing and design.

Semiconductor Intellectual Property (SIP)
  • Soft SIP
  • Hard SIP
  • Foundation SIP
  • Memory SIP
  • Connectivity SIP
  • Processor SIP
  • Analog SIP
  • Platform SIP
Verilog, GDSII, SPICE, EDIF, ASCII

Intel AHCI

ABAR is at PCI Header[0x24(36)], 9th 32-bit register, 5th BAR register (BAR5)

2008年11月4日 星期二

Linux SATA

ata_init
subsys_initcall(ata_init);
--do nothing but simply create a workqueue "ata"(ata_wq) and a single thread workqueue "ata_aux"(ata_aux_wq)

struct pci_driver ahci_pci_driver::probe=ahci_init_one
--each host driver would register a pci_driver to kernel, once the devid/vendorid matches, the probe function will be ran, which is ahci_init_one in this case

ahci_init_one
--if any host controller found, it would register devices with scsi layer

ata_host_activate(ahci_sht)
ata_host_activate(scsi_host_template )
--It would call scsi_host_add to get hooked into scsi layer


--Upon used to queue up a scsi command block to the low-level device driver (LLDD)
struct scsi_host_template ahci_sht::queuecommand = ata_scsi_queuecmd
ata_scsi_queuecmd

ata_qc_issue
struct ata_port_operation ahci_ops::qc_prep = ahci_qc_prep
--write command slot


ahci_qc_prep
--convert taskfile to fis, and fill the command slot


ata_port_operations inherits relations

SFF: Small Form Factor committee
http://en.wikipedia.org/wiki/Small_Form_Factor_committee

Hardware description language


http://en.wikipedia.org/wiki/Verilog

Verilog
比較像C, 美國亞洲
我們也是用verilog

http://en.wikipedia.org/wiki/VHDL

VHDL
多歐洲使用

2008年11月3日 星期一

電視的訊號接頭 Interfaces on TV

[wiki] Composite video
http://en.wikipedia.org/wiki/Composite_video
[wiki] AV端子
http://zh.wikipedia.org/wiki/AV%E7%AB%AF%E5%AD%90
analog,


[wiki] S-Video
http://en.wikipedia.org/wiki/S-Video
[wiki] S-端子
http://zh.wikipedia.org/wiki/S-%E7%AB%AF%E5%AD%90
analog, 480i~576i


[wiki] D-Terminal
http://en.wikipedia.org/wiki/D-Terminal
types: D1~D5
D5: 1080p(1920x1080)


[wiki] Digital Visual Interface
http://en.wikipedia.org/wiki/Digital_Visual_Interface
[wiki] DVI
http://zh.wikipedia.org/wiki/DVI
digital, WQUXGA(3840x2400), ~165MHz, 3.96Gbps(single)/7.92Gbps(dual)



[wiki] HDMI
http://en.wikipedia.org/wiki/Hdmi
[wiki] 高清晰度多媒體介面
http://zh.wikipedia.org/wiki/%E9%AB%98%E6%B8%85%E6%99%B0%E5%BA%A6%E5%A4%9A%E5%AA%92%E9%AB%94%E4%BB%8B%E9%9D%A2
1600p, 10.2Gbps, 340MHz

Can RAID 5 read detect bad blocks?

[Wiki] Standard RAID levels
http://en.wikipedia.org/wiki/Standard_RAID_levels

The parity blocks are not read on data reads, since this would be unnecessary overhead and would diminish performance. The parity blocks are read, however, when a read of blocks in the stripe and within the parity block in the stripe are used to reconstruct the errant sector. The CRC error is thus hidden from the main computer.

Fails
  1. totally failed, can't read
  2. partially failed, but write-then-read check would failed


Parity check on read is very expensive, a read would require N(disks amount) read.

Can RAID 5 detect 2nd type fails, if no parity check on read?

Shone, my colleague, says that HD itself should be capable of detecting the fail first, while some hardware RAID do have a option to turn on "parity check on read".
Does HD have the ability to detect the 2nd type failure?
(My guessing)
check parity on read, if failed:
  1. write-then-read check for each relative block on each disk, in order to know which block fails
  2. move the whole stripe to another location
  3. regenerate the failed block data

http://linas.org/linux/raid.html
Bad Blocks on Disk Drive
The most common form of disk drive failure is a slow but steady loss of 'blocks' on the disk drive. Blocks can go bad in a number of ways: the thin film of magnetic media can separate or slide on its underlying disk platter; the film of magnetic media can span a pit or gouge in the underlying platter, and eventually, like a soap bubble, it can pop. Although disk drives have filters that prevent dust from entering, the filters will not keep out humidity, and slow corrosion can set in. Mechanical abrasion can occur in several ways: the disk head can smash into the disk; alternately, a piece of broken-off media can temporarily jam under the head, or can skitter across the disk patter. Disk head crashes can be caused by kicking or hitting the CPU cabinet; they can also be caused by vibration induced by cooling fans, construction work in the room, etc. There are many other mechanical causes leading to (permanent) bad blocks. In addition, there are also "soft" or corrupted blocks: in modern hard drives, the size of one bit is so small that ordinary thermal noise (Boltzmann noise) is sufficient to occasionally flip a bit. This occurs so frequently that it is normally handled by the disk firmware: modern disk drives store ECC bits to detect and correct such errors. The number of ECC-corrected errors on a disk can be monitored with smartmon tools. Although on-disk ECC correction is sufficient to correct most soft errors, a tiny fraction will remain uncorrectable. Such soft errors damage the data, but do not render the block permanently (physically) unusable. Other soft errors are described in the next section below.

Over time, bad blocks can accumulate, and, from personal experience, do so as fast as one a day. Once a block is bad, data cannot be (reliably) read from it. Bad blocks are not uncommon: all brand new disk drives leave the factory with hundreds (if not thousands) of bad blocks on them. The hard drive electronics can detect a bad block, and automatically reassign in its place a new, good block from elsewhere on the disk. All subsequent accesses to that block by the operating system are automatically and transparently handled by the disk drive. This feature is both good, and bad. As blocks slowly fail on the drive, they are automatically handled until one day the bad-block lookup table on the hard drive is full. At this point, bad blocks become painfully visible to the operating system: Linux will grind to a near halt, while spewing dma_intr: status=0x51 { DriveReady SeekComplete UnrecoverableError } messages.

Using RAID can mitigate the effect of bad blocks. A Linux md-based software RAID array can be forced to run a check/repair sequence by writing the appropriate command to /sys/block/mdX/md/sync_action (see RAID Administration commands, and also below, for details). During repairs, if a disk drive reports a read error, the RAID array will attempt to obtain a good copy of the data from another disk, and then write the good copy onto the failing disk. Assuming the disk has spare blocks for bad-block relocation, this should trigger the bad-block relocation mechanism of the disk. If the disk no longer has spare blocks, then syslog error messages should provide adequate warning that a hard drive needs to be replaced. In short, RAID can protect against bad blocks, provided that the disk drive firmware is correctly detecting and reporting bad blocks. For the case of general data corruption, discussed below, this need not be the case.


BTW, I don't see any field that is related to the number of ECC-corrected errors on a disk:
root@test-laptop# smartctl --all /dev/sda
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model: WDC WD1600BEVS-22RST0
Serial Number: WD-WXE108Y89770
Firmware Version: 04.01G04
User Capacity: 160,041,885,696 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Mon Nov 3 19:02:24 2008 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (6780) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 87) minutes.
Conveyance self-test routine
recommended polling time: ( 6) minutes.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 200 200 051 Pre-fail Always - 0
3 Spin_Up_Time 0x0003 187 186 021 Pre-fail Always - 1641
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 509
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 100 253 051 Pre-fail Always - 0
9 Power_On_Hours 0x0032 098 098 000 Old_age Always - 1796
10 Spin_Retry_Count 0x0013 100 100 051 Pre-fail Always - 0
11 Calibration_Retry_Count 0x0012 100 100 051 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 479
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 215
193 Load_Cycle_Count 0x0032 154 154 000 Old_age Always - 138390
194 Temperature_Celsius 0x0022 106 085 000 Old_age Always - 41
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0012 200 200 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 253 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0009 100 253 051 Pre-fail Offline - 0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 0 -

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

root@test-laptop#

2008年11月2日 星期日

小梅硬體倉庫 的 CCD & 自己做轉接頭

http://www.pcdvd.com.tw/showthread.php?t=800501

1.標準防水型(金屬外殼)mini CCD攝影機
全黑色金屬鐵殼,標準鏡頭,具備14個固定螺絲孔。

所需輸入電源規格~12V(伏特) / 80mA(毫安培)
實際測試: 12VDC 62mA
攝影機尺寸~高3.7公分、寬3.3公分、縱深4公分
線長度~近195公分
接線定義~
紅色: (+) 正電
黑: (-) 接地(共用負極)
黃色:影像訊號線





2.廣角型(鋁合金外殼)(不防水) mini CCD攝影機
所需輸入電源規格~12V(伏特) / 200mA(毫安培)
實際測試: 12VDC 184mA
攝影機尺寸~高4.7公分、寬4.3公分、縱深5公分
線長度~近52公分
接線定義~
紅色: (+) 正電
黑: (-) 接地(共用負極)
白色:影像訊號線





自己去買幾接頭轉接一下,他那種 類S端子(S-Video)接頭有很多種,最好直接拿去對;我是轉成AV端子(Composite video)接頭與手上現有的12VDC變壓器的母座

正面


背面