HotMercury
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 2024q1 Homework5 (assessment) contributed by < `HotMercury` > :::danger 注意作業書寫規範,包含標題。 ::: ## 作業改進 [第四週測驗三](https://hackmd.io/@sysprog/linux2024-quiz4#%E6%B8%AC%E9%A9%97-3) 預期目標 : 充分理解 linux 內部的紅黑樹,以及測試效能的方式 [第二週測驗一](https://hackmd.io/@sysprog/linux2024-quiz2#%E6%B8%AC%E9%A9%97-1) 預期目標:了解 linux 中 cgroup 設計目的,以及演化 [第三週測驗四](https://hackmd.io/@sysprog/linux2024-quiz3#%E6%B8%AC%E9%A9%97-4) 預期目標:嘗試理解無線網路裝置驅動程式並整理 ## 閱讀〈[因為自動飲料機而延畢的那一年](https://blog.opasschang.com/the-story-of-auto-beverage-machine-1/)〉的啟發 這篇文章當頭棒喝的敲醒我對學習的認知,學習路上總是順著"應該"的道路前進,很少思考自己要的是什麼,順從代表欠缺了決定,以及承受每個決定之後帶來的結果,而對於學習總是屬於被動,沒有真正理解也就無法當作養分,當我們主動踏出決定並著手身體力行,我們才能真正學到與達成目標。 「資工系的學生不會寫程式,機械系的學生不會做機械」這句話在我開始接觸作業的時候深深的體悟到了,我可以在短時間內寫出看似符合作業標準的程式碼,為什麼說看似,因為我沒辦法提出證明,與他人比較,分析各種情況下的表現,這是我投入前不曾想過的,經過幾周的練習,我慢慢開始會構思程式碼並想辦法改進,我學會了使用圖表分析,利用一點點統計學來測量,擴大思考的因素例如:硬體架構,最差狀況問題等等。 這學期我認知道一見很重要的事情:『細節』在查閱資料時都是直接查閱作法以及他人的二手資料,這樣的後果就是無法了解事情的來龍去脈,只是像機器般照做。無法以第一手資料向他人解釋就無法真正了解資訊產業,這是我改變最多的想法。 我在這學期主動學習 linux kernel,我想像作者一樣充滿著熱血奮鬥一次,這次我知道我想投身進 linux kernel 的程式碼,我不是為了貢獻社會這種偉大的想法,而是我想要證明自己,眾多世界高手正在修改著 kernel 內部的程式碼,我卻連閱讀都感到困難,這是必須突破的。這幾周的作業只要牽扯到 lnux kernel 內部程式碼,都會讓我感到棘手,但我不認為我能力只會到這,這學期我必須達到這個目標,如果我不能解決眼前的問題,我就會變成那個有問題的人。 最後勉勵自己:紙上得來終覺淺,絕知此事要躬行 > [name=陸游] ## 前六週問題紀錄 ### cgroup > CPU sched book: Group scheduling and cgroups (Chapter 4) > https://docs.kernel.org/accounting/psi.html 我在閱讀 `fsync` syscall 時為了瞭解 write back 的流程注意到 [Writeback and control groups](https://lwn.net/Articles/648292/), 把資料從 memory 寫入 persistent device 是一件棘手的事,kernel 必須在 dirty pages 與 limited I/O bandwidth 間平衡,以下提出為什麼需要使用 cgroups. > There is a "magical function" called balance_dirty_pages() that will, if need be, throttle processes dirtying a lot of pages in order to match the rate at which pages are being dirtied and the rate at which they can be cleaned. It works reasonably well in current kernels, but it only operates globally; it is not equipped to deal with control groups 然而 block controller 與 memory controller 並不能好好協調 > Writeback is clearly related to both memory use and I/O bandwidth, but the control-group mechanism offers no way to enable controllers to work together 以下是我的問題及總結 :::info block control 並不能得到 memory control 的資訊,因此並不會去執行特定 control group 的資料,這樣會影響 global dirty-page watermarks 但我還是很不能理解 memory control 和 block control 的關西 ::: ### RCU :::info 為什麼 open syscall 通常會先找 rcu 如果沒有再走 REF-walk ::: > check 宋宝华 ### int_sqrt 我在閱讀 `rwb_arm_timer` 感到無力感,我沒辦法透過只看 code 去理解這段的意義,網路上的資料也沒有相關議題,可能必須從 git commit 去理解? > 找 Jens Axboe 的演講和報告 (maintainer of block layer and io_uring) ### 閱讀 linux 程式碼的問題 假設我今天想要理解 open syscall 在 kernel 的流程,在網路上只能找到 csdn 殘體攻略,版本落時,但直接閱讀程式碼時又會遇到很多隱藏的設計問題,思緒會斷斷續續導致大致瀏覽過卻又不清楚。 ## 貢獻 linux kernel - [commit fe12cfc](https://github.com/torvalds/linux/commit/fe12cfc17429a4ddfdf9e71711bd125b8854ed7d) 這是我在閱讀有關 VFS 程式碼時所發現的錯字 - 4/14 有發 patch 現在在等回覆 > [kernel org](https://lore.kernel.org/dm-devel/20240513064700.88178-1-merqqcury@gmail.com/T/#u) [第二次發 linux patch](https://hackmd.io/@NeedSleep/B1RC7fFxA) ## drivers/md/dm-kcopyd.c segment_complete 目前想要往 VFS,ext4,block layer 做出貢獻 在閱讀 driver dmcache 時有注意到一個 funciton [`segment_complete `](https://elixir.bootlin.com/linux/latest/source/drivers/md/dm-kcopyd.c#L693) 裡面註解 fixme 所以我認為這裡是有機會貢獻的 > /* FIXME: tidy this function */ ### 主要流程 這是一個 dm cache driver,可以將 SSD 當作 HDD 的 cache,為了作到這件事,會設計一個 migration 機制,以 work queue 的方式執行 HDD 與 SSD 間的資料搬移,所以會進入 `copy` function #### `copy` 透過設定 `struct dm_io_region` 可以分別定義 HDD and SSD 的實體位置,長度,device。 接下來探討 promotion 的情況進入 `dm_kcopy_copy` #### `dm_kcopyd_copy` *input* - cache->copier : 資料搬移必須要透過 memory,這裡會分配 page pool 給搬移的 data 使用。 - callback function `copy_complete` 負責做完的處理 - mg->k : Reoresents a chunk of future work 設定 `struct kcopyd_job` 這裡用到 GFP_NOIO 分配,GFP 也就是 get free pages,因此先聊解此意義,[GFP masks used from FS/IO context](https://docs.kernel.org/core-api/gfp_mask-from-fs-io.html),在 filesystem or stack io 需要注意 recursion deadlock,還沒很清楚暸解 lock 間的問題。 > Historically, they were used to prevent recursion deadlocks caused by direct memory reclaim calling back into the FS or IO paths and blocking on already held resources. Since 4.12 the preferred way to address this issue is to use new scope APIs described in Documentation/core-api/gfp_mask-from-fs-io.rst. ## 想投入專案 - [simplefs](https://hackmd.io/@sysprog/linux2023-projects#simplefs) 的 journal 開發 - 想參與 rust 相關的專案 ## Action items 1. 執行 [simplefs](https://github.com/sysprog21/simplefs) 內建的測試案例 2. 確認 Linux v5.15+ 和 Linux v6.8 都可正確編譯 simplefs 並通過測試 > 案例探討: https://github.com/sysprog21/simplefs/pull/42 3. [Issue #39](https://github.com/sysprog21/simplefs/issues/39),理解 [jbd2](https://www.kernel.org/doc/html/latest/filesystems/ext4/journal.html) 的原理 4. [Analysis and Evolution of Journaling File Systems](https://www.usenix.org/legacy/event/usenix05/tech/general/full_papers/prabhakaran/prabhakaran.pdf) > 注意 ext3, ReiserFS, JFS (IBM 貢獻), 如何處理 metadata, EXT3 Journal Structure, Checkpointing, Crash Recovery, Summary of Ext3

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully