barrier相關問題 - Linux

Frederic avatar
By Frederic
at 2016-07-12T15:04

Table of Contents

開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux-3.18 @ ARMv8 CPU

額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
X

問題(Question):
大家好, 最近在研究barrier, 搜尋之後好像沒找到相近的討論串, 想請教一點問題..

在linux-3.18/arch/arm64/include/asm/io.h裡面

看到它對readl/writel的定義:
/*
* I/O memory access primitives. Reads are ordered relative to any
* following Normal memory access. Writes are ordered relative to any prior
* Normal memory access.
*/
#define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; })

#define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c)); })

readl這邊感覺比較好理解, 在__v承接readl_relaxed的return value之後,
卡一個read的barrier, 然後才return __v出來,
所以能確保最後的__v真的是得到從最後一級所傳回來的data
(假設中間的interconnect不會提前做response或把自己cache裡的東西傳回來)

但是writel這邊, 它在執行writel_relaxed之前就先卡了個write barrier,
那我在呼叫這個macro之後,
也只能確保這個write被執行之前, 前面的write跟這個write是區隔開的,
但是不能確保這個write已經被執行完成了, 不是嗎?

這邊我越看越覺得困惑...

發文若有不妥懇請提醒, 也懇請大大幫忙解惑, 感激

--
Tags: Linux

All Comments

Emily avatar
By Emily
at 2016-07-15T09:31
writel的barrier應該是為了保證v,c 的assign 出現在
writel_relaxed之前
William avatar
By William
at 2016-07-16T08:53
kernel Documentation/memory-barriers.txt

Html如何去做讀取伺服器內資料

David avatar
By David
at 2016-07-12T12:03
有個程式在跑,會不定時產生TXT 要怎麼讓我的HTML可以吃到產生出來的TXT 目前是用javascript的方法,但好像沒用(我有用ie開active) ... andlt;script type=and#34;text/javascriptand#34;andgt; var ForReading = ...

readb/readw/readl/readq

Dinah avatar
By Dinah
at 2016-07-11T21:12
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux 3.4 at Cortex-A9/A17 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) X 問題(Question): trace linux-3.4/arch/ar ...

grep 擷取內容

Adele avatar
By Adele
at 2016-07-11T10:32
grep and#34;要搜尋的關鍵字and#34; 檔案名稱 依照上面的例子,就可以將檔案內容符合關鍵字的行數,擷取出來 但是今天我想要多擷取關鍵字加上關鍵字的下一行 比如說: test.txt內容如下: receive Hello Welcome to DSGH Please tell me y ...

讓每個檔案的修改時間差一秒

Carol avatar
By Carol
at 2016-07-11T01:34
※ 引述《LIAR (玻璃做的大叔)》之銘言: : 我因為windows檔案管理的關係,有時要用檔名,有時要用時間排序, : 因此新檔案進來後我會先丟到linux裡面用touch調整時間。 : 現在我希望讓大量檔案的mtime只差一秒,我想過 : find *.mp4 -exec touch {} \; : ...

讓每個檔案的修改時間差一秒

Caroline avatar
By Caroline
at 2016-07-11T00:00
※ 引述《LIAR (玻璃做的大叔)》之銘言: : 我因為windows檔案管理的關係,有時要用檔名,有時要用時間排序, : 因此新檔案進來後我會先丟到linux裡面用touch調整時間。 : 現在我希望讓大量檔案的mtime只差一秒,我想過 : find *.mp4 -exec touch {} \; : ...