Yiwei Lin
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: Linux Kernel Internals, 作業系統 --- # Linux 核心設計: 追蹤與測試工具 ## Perfetto ### 安裝 Perfetto [Perfetto](https://perfetto.dev/) 是一款可以針對 Android 和 Linux 環境進行系統追蹤和分析的工具。在 Linux 環境上,可以參考 [Perfetto build instructions](https://perfetto.dev/docs/contributing/build-instructions) 頁面一步步進行安裝。 針對跨平台的環境,則可以參考 [Perfetto build instructions: Cross-compiling for Linux ARM/64](https://perfetto.dev/docs/contributing/build-instructions#cross-compiling-for-linux-arm-64) 的方式。以目標為 ARM64 的平台為例,Perfetto 的跨平台編譯真的很友善。首先我們可以使用下面的命令取得 Perfetto 以及相關的工具。 ``` $ git clone https://android.googlesource.com/platform/external/perfetto/ && cd perfetto $ tools/install-build-deps --linux-arm ``` 接著,透過此命令產生設定檔: ``` $ tools/gn args out/linux ``` 在設定檔中加入以下的參數。更多參數設定的細節可見 [Build configurations](https://perfetto.dev/docs/contributing/build-instructions#build-configurations)。 ``` target_os = "linux" target_cpu = "arm64" is_debug = false ``` 完成設定後,以下的命令即可建立進行基礎追蹤所需的工具! 或者也可以執行 `tools/ninja -C out/linux` 來建立所有 Perfetto 涵蓋的工具。 ``` $ tools/ninja -C out/linux tracebox traced traced_probes perfetto ``` ### 使用 Perfetto 追蹤 Linux 運行 追蹤的方式可以參考如下作法。這裡我們使用範例的 `scheduling.cfg` 設定檔來追蹤與排程器相關的一些事件。參考 [TraceConfig](https://perfetto.dev/docs/reference/trace-config-proto) 可得知設定檔的更多相關語法。 ``` $ sudo chown -R $USER /sys/kernel/tracing $ out/linux/tracebox -o trace_file.perfetto-trace --txt \ -c test/configs/scheduling.cfg ``` 此命令的輸出會被導向到 `trace_file.perfetto-trace` 檔案。將輸出檔案匯入到 [Perfetto UI](https://ui.perfetto.dev/) 即可看到追蹤結果的視覺化展現,相當方便! > * [Perfetto: Swiss Army Knife for Linux Client Tracin](http://lalitm.com/perfetto-swiss-army-knife/) ## Scheduler > * [Hackbench](https://hackmd.io/Rq-sfre_R9aFmG6vaS1z5Q#Hackbench) > * [Schbench](https://hackmd.io/Rq-sfre_R9aFmG6vaS1z5Q?view#Schbench) ## Linux Test Project(LTP) [Linux Test Project](https://github.com/linux-test-project/ltp/tree/master) 是由 IBM, Cisco, Fujitsu, SUSE, Red Hat, Oracle 等等知名公司所一同開發與維護的專案。其整合一系列與測試 Linux kernel 相關的工具,因此可以提供對 Linux 的全面性測試。 安裝方式可參照 README.md 的說明: ``` $ git clone https://github.com/linux-test-project/ltp.git $ cd ltp $ make autotools $ ./configure ``` 如果想要一口氣將所有的 test 都安裝上,可以透過以下方式。 ``` $ make $ make install ``` 不過由於 LTP 測試項目眾多,我們也可以只選擇有興趣的項目來執行。舉例來說,假設我們只對測試 Hackbench 有興趣,可以直接移動到對應資料夾下並 `make` 必要的項目即可: ``` $ cd testcases/kernel/sched/cfs-scheduler $ make $ PATH=$PATH:$PWD ./hackbench ``` ## bpftrace ## retsnoop ## drgn [drgn: 探索與除錯 Linux 核心的利器!](https://hackmd.io/@RinHizakura/r1gEFgprkx)

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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