kantarow
    • 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 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

    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 1章 Linux入門(イントロダクション&雑談回) * [カーネルとユーザランドの入れ替え](https://www.openrtm.org/openrtm/ja/content/%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB%E3%81%A8%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%A9%E3%83%B3%E3%83%89%E3%81%AE%E5%85%A5%E3%82%8C%E6%9B%BF%E3%81%88) * 基本的に2章以降の流れの説明で目新しいこと無いので気になったところ議論 * shellってどこにある? * ユーザーランドにいる * kernel(核)を覆うshell(殻) * appとカーネルがやりとりしている図を見ながら * Appとカーネルの間になにか挟まってる? * 挟まってるというより、カーネルがシステムコールを提供しているよ * Linuxカーネルはモノリシックらしい * コードベースがでかい * ビルド時間が長い * バイナリもでかい * デバイスドライバを書くときは、動的にロードできるモジュールドライバで作る * 全体をコンパイルし直さなくていい * モノリシックとは ![image](https://hackmd.io/_uploads/Bkg7cbkvT.png) * [システムコールとは何なのか](https://qiita.com/sxarp/items/aff43dd83b0da69b92ce) * Q. 仕事でカーネルいじってるとき、毎回コンパイルするの? * カーネルはいじってなくて、DPDKという技術がある * カーネルバイパスしてユーザー空間で動作する * カーネル空間で色々やるオーバーヘッドを避けられる * アプリケーション向けの最適化を行える。こういうのはデバイスドライバでやるのに向かない * [DPDK](https://www.ntt-tx.co.jp/column/dpdk_blog/20180920/) * そうじゃなくてもデバドラは動的にロードできる * カーネルをコンパイルするのってどんな仕事なんだろ * カーネルはコンパイル不要の設定の変更で最適化できたりもする(ISUCON本の知識) * ハイパーバイザって何を抽象化してるの?(宿題) * オーバーコミットという動作がある * CPU切り替えまくると遅くなる * ゲストOSを特定のCPUに紐付けることをCPUピニングと呼ぶ * つまりハードウェアの利用をゲスト向けに最適化しつつ抽象化するってこと? * AppleシリコンのMacでは、qemuってやつがx86向けの諸々をやってくれていた * CPUエミュレーションっぽいことをやっている * 命令セットの変換? * 予想 * ハイパーバイザは仮想のマシンとして命令セットを提供している? * ゲストOSのカーネルから見えるリソースをコントロールしている? * 読んだ:[VM環境のCPU仮想化はどうやって実現しているのか ハードウェア仮想化支援機構の仕組み](https://logmi.jp/tech/articles/323956) * 素朴なCPUエミュレーションとかはあまりやらないらしい。遅いので * 実際はCPUが仮想化支援機構を持っていて、直接実行できる命令が多い * 仮想化が必要なのはIOなどの命令 * 仮想化が不要な命令の場合 * qemu->KVM この命令を実行してくれ * 仮想化支援により実行される * IOなどの命令の場合(センシティブ命令) * qemu->KVM この命令を実行してくれ * VCPU->KVM できないよー(VMEXIT) * KVM->qemu エミュレーションしてくれー * qemu->KVM エミュレーションした結果だよ * 実行される # 二章 Linuxカーネル * Linuxカーネルとはなにか * アーキテクチャの全体 * カーネルが果たす本質的な役割 ## 2.1 Linuxアーキテクチャ * 三つの階層に分ける * ハードウェア * カーネル * ユーザ空間 * カーネルとユーザ空間の間 * システムコール * ハードウェアとカーネルの間 * システムコールとは異なり、ハードウェアの種類ごとにグループ化されている * CPUインターフェイス * メインメモリとのインターフェイス * ネットワークインターフェイスとドライバ * ファイルシステムとブロックデバイスのドライバインターフェイス * キーボード、ターミナル、その他IOなど入力デバイスにおけるキャラクタデバイス、ハードウェア割込み、デバイスドライバ * シェルやその他コマンドなどのユーティリティはカーネルでなくユーザー空間の一部 * ユーザ空間のトピック * ユーザーモードとカーネルモードの比較 * カーネルモードでは数少ない抽象化で高速な実行 * ユーザーモードは低速だが安全で便利な抽象化 ![image](https://hackmd.io/_uploads/SJzQmurDp.png) ## 2.2 CPUアーキテクチャ * Linuxカーネルには汎用的なコードやドライバ以外にも、CPUアーキテクチャに特化したコードが含まれる * この分離により移植が容易となる * 新しいハードウェアに素早く対応できる * BIOSからハードウェア情報を取得する`dmidecode` * [Manpages](https://man.cx/dmidecode) > dmidecode is a tool for dumping a computer’s DMI (some say SMBIOS ) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safeness, this also makes the presented information possibly unreliable. * 無理なら`lscpu` * `cat /proc/cpuinfo`でも確認可能 ### 2.2.1 x86アーキテクチャ * Intelが開発した命令セットファミリ * のちにAMDにライセンス供与 * よく見かけるやつ * x86_64 -> Intel * amd64 -> AMD * デスクトップやラップトップなどのコンシューマから、サーバーまで広く使われる * エネルギー効率はあまりよくない * [アウトオブオーダー実行](https://ja.wikipedia.org/wiki/%E3%82%A2%E3%82%A6%E3%83%88%E3%83%BB%E3%82%AA%E3%83%96%E3%83%BB%E3%82%AA%E3%83%BC%E3%83%80%E3%83%BC%E5%AE%9F%E8%A1%8C) ### 2.3.2 メモリ管理 * 仮想メモリとページテーブルは何が違う? * 仮想メモリとは、プロセスに仮想的なメモリ空間を割り当てる仕組み * メモリテーブルとは、仮想メモリ空間をページごとに物理メモリにマッピングする仕組み ### 2.3.6 システムコール * ユーザーモードからカーネルモードに切り替わるので、コンテキストスイッチが行われる * ハードウェアコンテキストとは? * [ハードウェアコンテキスト](https://wikiwiki.jp/north2006/%E3%83%8F%E3%83%BC%E3%83%89%E3%82%A6%E3%82%A7%E3%82%A2%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88) * [コンテキスト (計算機科学)](https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88_(%E8%A8%88%E7%AE%97%E6%A9%9F%E7%A7%91%E5%AD%A6)) * スイッチしているもの * CPUのレジスタの値 * 仮想メモリ->実メモリアクセスのためのテーブル * tsk->active_mm * [まじでわからんActiveMMの説明(メーリングリスト)](https://www.kernel.org/doc/html/v5.0/vm/active_mm.html) ### 脱線。ActiveMMってなんだろう * 構造 # 余談、メタ * アイコスはくさいらしい * ↑うるさいですね

    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