Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
プロセスへのメモリ割り当て(3) 実際に使うときにメモリを獲得するデマンドページング
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Satoru Takeuchi
PRO
July 13, 2024
Technology
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
プロセスへのメモリ割り当て(3) 実際に使うときにメモリを獲得するデマンドページング
以下動画のテキストです。
https://youtu.be/3mpurVs_8Sc
Satoru Takeuchi
PRO
July 13, 2024
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
79
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
110
あなたの知らないバージョン命名規則
sat
PRO
3
920
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
74
Machine Check Exception
sat
PRO
2
71
バイナリダンプの模様を読む
sat
PRO
0
110
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
110
114-ファイルのshallow_copy.pdf
sat
PRO
2
63
113-Btrfsのスナップショット.pdf
sat
PRO
0
47
Other Decks in Technology
See All in Technology
会社紹介資料 / Sansan Company Profile
sansan33
PRO
31
430k
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
190
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
130
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
780
Browser Spec: Testing Hotwire with Ruby
takahashim
1
130
トークン化預金DCJPYの取り組みと活用ユースケース
finengine
0
170
専門領域のAIをどう評価するか
bengo4com
2
300
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
930
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
480
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
670
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
300
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Into the Great Unknown - MozCon
thekraken
41
2.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
WENDY [Excerpt]
tessaabrams
14
40k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
Technical Leadership for Architectural Decision Making
baasie
3
600
Making Projects Easy
brettharned
120
6.8k
エンジニアに許された特別な時間の終わり
watany
109
250k
Producing Creativity
orderedlist
PRO
348
41k
Transcript
プロセスへのメモリ割り当て(3) 実際に使うときにメモリを獲得する デマンドページング Jul. 10th, 2024 Satoru Takeuchi X: satoru_takeuchi
1
はじめに • 過去動画でmmapによってプロセスに物理メモリを割り当てると説明 ◦ 📝 過去動画「プロセスへのメモリ割り当て (1) mmap」 • デマンドページングという機能を使うと少し違った挙動をする
◦ mmapは、新たにmapした領域にプロセスからアクセス可能にするだけ ◦ 実際に物理メモリを割り当てるのは最初に使うとき ◦ メモリ使用量をおさえられる ◦ Linuxはデマンドページングを使っている • むずかしいので例によって図解 2
今回出てくる概念 • (おさらい) present bit ◦ ページに物理メモリが割り当てられているかを示すフラグ ◦ ページテーブルエントリごとに存在 •
vm_area_struct ◦ mmapした領域ごとに存在するカーネルが管理するデータ構造 ◦ ページテーブルとは別の領域 3
それぞれの関係 4 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500 600
700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 × vm_area_struct 範囲 0-200 ページテーブル
mmapを発行すると… 5 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500 600
700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 × vm_area_struct 範囲 0-200 ページテーブル ここを新たにマップしたとする 300
デマンドページングが無い場合 mmap時にメモリマップ更新&物理メモリ割り当て 6 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500
600 700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 〇 800-900 vm_area_struct 範囲 0-300 ページテーブル プロセスのメモリ 800 900 300
デマンドページングがある場合 mmap時にメモリマップ更新&物理メモリは割り当てない 7 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500
600 700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 × - vm_area_struct 範囲 0-300 ページテーブル 300
mmapした領域への初回アクセス時 8 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500 600
700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 × - vm_area_struct 範囲 0-300 ページテーブル 300 ここへのアクセス
ここで物理メモリ割り当て 9 物理メモリ 仮想アドレス空間 0 100 200 プロセスのメモリ 500 600
700 未マップ領域 仮想アドレス present bit 物理アドレス 0-100 〇 500-600 100-200 〇 600-700 200-300 〇 800-900 vm_area_struct 範囲 0-300 ページテーブル プロセスのメモリ 800 900 300 ここへの初回アクセス
まとめ • デマンドページングによってメモリ使用量を抑えられる ◦ マップしたものの、まだ使ってない領域には物理メモリは割り当てられない • Linuxはデマンドページングを使っている • 実例は別動画で紹介 •
具体的にどのように実現しているのかも別動画で紹介 ◦ カーネルとCPUの連携によって実現 10