owned this note
owned this note
Published
Linked with GitHub
# 2024-06-25,27 討論簡記
> [課程期末專題](https://hackmd.io/@sysprog/linux2024-projects)
root fs (rootfs)
![image](https://hackmd.io/_uploads/H1zyxguL0.png)
u-boot 是 boot loader,初始化 SRAM, DRAM, flash, eMMC, 等等硬體
root of trust (RoT), initiatated in HW
Trusted Firmware for A profile (TF-A)
> https://hackmd.io/@sysprog/linux-kvm
> https://hackmd.io/@sysprog/linux-pid0
SMP: multi-processor
multi-core : 未必對稱 (如 Arm big.LITTLE)
multi-core 相對的硬體組態不是 single core,而是 uniprocessor
single => island
`[_]` `[_]` `[Active]`
`[_]` `[_]`
Microsoft Xbox, CE, Mobile, NT, ...
我的問題:
https://hackmd.io/@Henry0922/linux-final-question-list
> 先分析遇到的問題,例如 Mailbox 的中斷處理以及佇列配置,不要急著下手寫程式。
---
https://github.com/sysprog21/concurrent-programs
如何擴充為 MPMC?
```c
-/* Returns an index to push or -1 on failure (Queue is full) */
-static inline int mp_try_prepare_push(uint queue_size,
- atomic_uint *tail_committed,
- atomic_uint *head_pending)
-{
- /* Tail needs to be loaded first, otherwise we might overestimate the amount
- * of free space */
- uint tail = atomic_load(tail_committed);
- uint head = atomic_load(head_pending);
-
- while (1) {
- if (queue_get_free_explicit(queue_size, head, tail) <= 0)
- return -1;
-
- /* As this is an MP queue another thread might have taken our index. */
- /* This will update `head` on failure */
- if (atomic_compare_exchange_strong(head_pending, &head, head + 1))
- return head;
- }
-}
```
```c
-/* Returns an index to consume */
-static inline int mc_prepare_consume(atomic_uint *head_committed,
- atomic_uint *tail_pending,
- atomic_uint *head_waiters)
-{
- /* Head needs to be loaded first, otherwise we might overestimate the amount
- * of committed space */
- uint head = atomic_load(head_committed);
- uint tail = atomic_load(tail_pending);
-
- while (1) {
- while (queue_get_committed_explicit(head, tail) == 0) {
- QUEUE_WAIT_FOR_HEAD(head_waiters, head_comitted, head);
- tail = atomic_load(tail_pending);
- }
-
- /* As this is an MC queue another thread might have taken our index. */
- /* This will update `tail` on failure */
- if (atomic_compare_exchange_strong(tail_pending, &tail, tail + 1))
- return tail;
- }
-}
-static inline void mc_commit_consume(uint prepared_index,
- atomic_uint *tail_committed,
- atomic_uint *tail_waiters)
-{
- uint tail = atomic_load(tail_committed);
-
- /* Wait for sequential increment */
- while (prepared_index != tail)
- QUEUE_WAIT_FOR_TAIL(tail_waiters, tail_committed, tail);
-
- atomic_fetch_add(tail_committed, 1);
-
- if (atomic_load(tail_waiters))
- QUEUE_WAKE_ALL_TAIL_WAITERS(tail_committed);
-}
```
https://github.com/facebook/folly/blob/main/folly/docs/Synchronized.md
MPMC
SPSC (specialized)
---
quick sort 的 stability
> https://github.com/sysprog21/linux-list
---
老師好,我的 github 帳號名稱是 jujuegg,我的期末專題的開發紀錄還沒被放至課程期末專題的頁面中,我在昨日 13:00 左右有發電子郵件給老師,但老師尚未回覆。
> 知道!我要建立新的 HackMD 頁面 -- jserv
https://wiki.csie.ncku.edu.tw/User/HenryChaing
* 沒有針對作業共筆/測驗進行檢討,投入的狀況 (不要說「我花了大量時間」) ,儘量列舉客觀事實
> 首先是作業的部份,雖然並未達成全部老師的要求,但是我認為不論是我<s>投入的時間</s>或是產出都有達到一定的要求,因此會在這點自評高分。再來是上課與老師的互動,主要是針對測驗題目以及期末專題進行討論,測驗檢討雖然上課當下一知半解,但是在經過與老師的互動下有了表現自己的機會(雖然還是不盡人意),最後課堂結束也有機會好好再研究題目,甚至將其改寫成不同版本但原理相同的程式, <s>也謝謝老師還有批改課後我所加上的紀錄。</s>
$\to$ 客觀事實在哪?
## Kuanch
https://hackmd.io/@sysprog/rkJd7TFX0
EEVDF since Linux v6.6 => 解決 CFS 的哪些問題?
用 stress-ng 創造 workload
Linux v5.1 引入 Energy-Aware Scheduling (EAS),當時的 CPU scheduler 是 CFS
$\to$ load balancing, task migration
## weihsinyeh
https://github.com/sysprog21/concurrency-primer/pull/7
Fetch and…
Transform RMW to directly modify the shared variable (such as addition, subtraction, or bitwise AND, OR, XOR)
and return its previous value, all as part of a single atomic operation. Compare with Exchange §5.1, when programmers
only need to make simple modification to the shared variable, they can use Fetch and….
哪裡 weird ?
## yeh-sudo
https://hackmd.io/@sysprog/B1W2HKTER
根據[測試結果](https://github.com/yeh-sudo/mt-redis?tab=readme-ov-file#performance) ,吞吐量雖然上升,但是延遲也顯著增加,不知道延遲跟什麼因素有關係?
```
============================================================================================================================
Type Ops/sec Hits/sec Misses/sec Avg. Latency p50 Latency p99 Latency p99.9 Latency KB/sec
----------------------------------------------------------------------------------------------------------------------------
Sets 38465.04 --- --- 4.11819 2.28700 23.80700 30.71900 2962.48
Gets 384227.73 0.00 384227.73 0.52990 0.27900 16.31900 24.31900 14967.33
Waits 0.00 --- --- --- --- --- --- ---
Totals 422692.77 0.00 384227.73 0.85643 0.28700 18.04700 26.36700 17929.81
```
如何對 Redis 作效能評比?
```python
--*-- cpu0 >>>>>>> |
--*-- cpu1 >>> | Redis
--*-- cpu2 >>> | urcu
--*-- cpu2 >>>>> | concurrency level = 4
(concurrency level = 4)
4 4
```
taskset : https://man7.org/linux/man-pages/man1/taskset.1.html
HT (hyperthreading) 開啟的狀況,找出 logical core
https://man7.org/linux/man-pages/man1/chrt.1.html (選擇 RT class)
git-bisect
ln -s (symbolic) : inode