2012年5月30日 星期三

ARM MMU Cacheable and Bufferable bits

C=0,B=0: NCNB (WB off)
C=0,B=1: NCB (WB on)
C=1,B=0: WriteThrough, no write allocate (WB on)
C=1,B=1: WriteBack, no write allocate (WB on)

[藍森林-自由軟件] - 如果cache打開而MMU不打開,這種情況允許嘛?- 系統管理
http://www.lslnet.com/linux/f/docs1/i56/big5375649.htm

1.WB的設計是為了防止處理器流水線被寫數據總線操作(寫主存,寫外圍設備寄存器等)拉住。典型寫數據總線時機有三種:一是cache處於write through策略下的寫操作;二是cache處於write back策略下,dirty數據由於cache行替換或者被程序主動清空而寫回主存,三是不經過cache,直接對數據總線的寫操作。有了WB之後,被寫回數據總線的內容在進入WB之後,處理器和cache就可以立刻繼續使用了。這就是WB和cache的關係。
2.那個表的含義如下:
ARM各系列的處理器上的cache設計有所不同,所以有的cache只有write through策略,有的cache只有write back策略,還有的cache是write back策略但允許一定的write through行為,因此C和B位的四種組合對這三種cache而言有不同的含義。第一列和第二列分別針對write through型cache和write back型cache進行解釋,其含義可以參考我對第1個問題的回答,第三列針對write back策略但允許一定的write through行為的cache,第一行好理解,第二行之所以在B位為0的情況下依然是bufferable,應該是因為硬件上的設計原因(節省硬件資源或者由於目標設計頻率限制),第三行的含義是,當C==1,B==0時,cache使用write through策略,WB開啟,第四行的含義是,當C==1,B==1時,cache使用write back策略,WB開啟。
可以看到,對第三種類型的cache,C和B位不再「嚴格」是其本來控制cacheable和bufferable的含義,而是利用這兩位的「組合」來控制cache和WB的表現行為,這樣做比另外再增加一位來選擇cache的write back策略和write through策略硬件上節約了資源,效果上卻差不多,少了cache和WB幾種意義不大的組合,應該說還是挺巧妙的。


7.5.3. Cacheable and bufferable flags
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/BABJJDIE.html
If you set a region to be cacheable:

  • When you load from that region, the cache is searched. If the item is found, it is loaded from the cache. If the item is not found, a complete cache line including the required address is loaded. Some other cache line is evicted from the cache, unless there is an unused cache line available.
  • When you save to that region, the cache is searched. If the item is found, the save is made to the cache. If the item is not found, the save is made to memory.

The exact effect of the bufferable flag varies (see the Technical Reference Manual for your processor for details).

2012年5月29日 星期二

Maxium packets per second

Maximum packets per second of Gbe
64-byte: 1000000/((64+20)*8) = 1488kpps
128-byte: 1000000/((128+20)*8) = 844kpps
1500-byte: 1000000/((1500+20)*8) = 82kpps



pps与bps之间的换算 - 知识库文章 - 艾泰科技
http://www.utt.com.cn/reference.php?id=253
此处给出千兆环境下有单向转发包长为64字节的理论PPS
1Gbps = 1000M bits/((84字节)*8(bit 每字节))=1.488095 Mpps
(根据IEEE802.3规范, 100Mbps=100,000,000bps即以太网速率的单位是以10进制为单位的。)
根据Ethernet的CSMA/CD的工作原理,报文在发送之前,要先侦听一段时间线路是否空闲,空闲才能发送。这个监听时间为帧间隙(IPG Inter-Packet Gap),为发送12个字节的时间。为了能接受同步,在以太网帧结构前增加了8个字节的前导码(Preamble),其中7个字节为AA(其二进制形式为01010101)用于与接收端同步,第8个字节为AB(帧定界符),用于定界,标明从现在开始后面的是以太网帧。所以,最短帧的实际长度为:
64字节+12(字节帧间隙)+8(前导码)= 84字节


[wiki] Interframe gap
http://en.wikipedia.org/wiki/Interframe_gap
The minimum interframe gap is 96 bit times (the time it takes to transmit 96 bits of raw data on the medium), which is 9.6 us for 10 Mbit/s Ethernet, 0.96 us for 100 Mbit/s (fast) Ethernet, 0.096 us for 1 Gbit/s (gigabit) Ethernet, and 0.0096 us for 10 Gbit/s (10 gigabit) Ethernet.

2012年5月21日 星期一

ARM: DMA-mapping: new extensions for buffer sharing

ARM: DMA-mapping: new extensions for buffer sharing [LWN.net]
https://lwn.net/Articles/497607/

2012年5月9日 星期三

GIT post-commit: Backup commits to "remote branch" of remote repo

Configuration:

  1. gitbackup.remotename: the remote used to backup, default "gitbackup"
  2. gitbackup.myname: the name shown before remote branch of remote repo, default is current git directory "$(pwd)"

Installation:
  1. Copy the following post-commit to .git/hooks
  2. Add remote
    git remote add gitbackup XXX@YYY:/ZZZ
  3. Change configuration if needed
  4. It is suggested to create a ssh key to the remote "gitbackup" to login without password.
    Refer to ssh-keygen.
Done!!! git will also push the commit to remote repo of remote branch while committing:
# git commit -m "update" -a
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 797 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To xxx@XXX.XXX:~/prj/mygit
f3fe00e..d46f950 HEAD -> 101/101
[101 d46f950] update
1 files changed, 37 insertions(+), 0 deletions(-)



post-commit
#!/bin/sh
curbr=$(git branch | grep \* | cut -c 3-)
remotename=$(git config gitbackup.remotename)
myname=$(git config gitbackup.myname)

if [ -z "${myname}" ] ;then
myname=$(readlink -e $(pwd))
git config gitbackup.myname ${myname}
fi
if [ -z "${remotename}" ] ;then
remotename=gitbackup
git config gitbackup.remotename ${remotename}
fi
if echo ${curbr} | grep \( 1>/dev/null 2>&1 ; then
echo
echo Warning: you are not on any branch currently...
echo
curbr=no_branch
fi
git push ${remotename} +HEAD:refs/remotes/${myname##/}/${curbr}
: Nothing



Push to remote branch of remote repo
git push <remote_name> +<br_name>:refs/remotes/<my_name>/<br_name>



7.3 Customizing Git - Git Hooks
http://git-scm.com/book/ch7-3.html

[Git] 利用 post-receive hook 自動發 Email 給團隊成員
http://josephjiang.com/entry.php?id=346

2012年5月4日 星期五

openssl RSA keys

Create RSA key pair

openssl genrsa -out keys.pem 2048
To get public key (modulus)
openssl rsa -text -in keys.pem


HOWTO keys
http://www.openssl.org/docs/HOWTO/keys.txt
Keys are the basis of public key algorithms and PKI.  Keys usually
come in pairs, with one half being the public key and the other half
being the private key.  With OpenSSL, the private key contains the
public key information as well, so a public key doesn't need to be
generated separately.
 
[wiki] RSA (algorithm)
http://en.wikipedia.org/wiki/RSA_%28algorithm%29

[wiki] RSA加密演算法 - 维基百科,自由的百科全书
http://zh.wikipedia.org/wiki/RSA%E5%8A%A0%E5%AF%86%E6%BC%94%E7%AE%97%E6%B3%95