4.
モチベーション (Why)
新しい用途でも、実績のあるソフトウェアが利用したい
ネットワークスタック(618K LoC, Linux)
ファイルシステム(752K LoC, Linux)
アプリケーション(a lot)
VM は重い(再現性向上=> 機動性低下)
抽象化の場所(プロセッサ、OS、システムコール、etc)
仮想化技術から前進させて、変形させる
Poll: "When you download and run software, how often do you use a virtual machine (to reduce security risks)?"
Jon Howell, Galen Hunt, David Molnar, and Donald E. Porter, Living Dangerously: A Survey of Software Download
Practices, no. MSR-TR-2010-51, May 2010
5.
Poll: "When you download and run software, how often do you use a
virtual machine (to reduce security risks)?"
Jon Howell, Galen Hunt, David Molnar, and Donald E. Porter, Living Dangerously: A Survey of Software Download
Practices, no. MSR-TR-2010-51, May 2010
7.
Any problem in computer science can be solved with
another level of indirection.
(Wheeler and/or Lampson)
img src: https://www. ickr.com/photos/thomasclaveirole/305073153
8.
モノリシックカーネルの再利用とは (What ?)
Anykernel: NetBSD rump kernel に由来
We de ne an anykernel to be an organization of
kernel code which allows the kernel's unmodi ed
drivers to be run in various con gurations such as
application libraries and microkernel style servers,
and also as part of a monolithic kernel. -- Kantee
2012.
実績あるモノリシックカーネルのソースコードをそのまま利用
(unmodi ed)
追加具材を糊付けし変形させ、ライブラリ化
14.
Linux Kernel Library
Linux カーネルのライブラリ
ハードウェア非依存のアーキテクチャ
下位ホストのインターフェースを規定
依存部をアウトソース
Windows, Linux, FreeBSDで動作
デバイスI/Oを簡素化
virtio ホスト実装
Linux カーネル内のドライバ利用
Purdila et al., LKL: The Linux kernel library, RoEduNet
2010.
15.
歴史
rump: 2007 (NetBSD)
LKL: 2007 (Linux)
DCE/LibOS: 2008 (Linux/FreeBSD)
LibOS/LKL revival: 2015
LibOS merged to LKL
20.
2. CPU 非依存アーキテクチャ
アーキテクチャ(arch/lkl)
CPU アーキテクチャと同等に扱える
他コードへの影響をなくす
2400 LoC
スレッド構造体(struct thread_info) 定義
irq, timer, syscall handler を実装
下位層リソースへのアクセス(環境依存)は、
host_opsにて表現
21.
3. アプリケーションインターフェー
ス
Case 1: use exposed API (LKL syscall)
Case 2: use host libc (LD_PRELOAD)
Case 3: extend (alternative) libc
22.
Case 1: use exposed API (LKL
syscall)
カーネル内のシステムコール入り口を直接call
lkl_sys_open(), lkl_sys_socket()
通常のシステムコールとほぼ同じ
復帰値、エラー番号の通知が違う
アプリケーションはこのAPI と、ホストの持つ
API を両方利用可能
LKL でext4 ファイルをlkl_sys_read() =>
ホスト(Windows) でwrite()
23.
Case 2: ホスト標準ライブラリのハ
イジャック
ホストの標準ライブラリ(libc) を
LKL システムコールに実行時に置きかえ
LD_PRELOAD
socket() => lkl_sys_socket()
ホストのプログラムバイナリをそのまま利用可能
置きかえ可能なシンボルに制限あり
非Linux ホストでのシステムコール変換は必要
24.
Case 3: extend (alternative) libc
LKL システムコールのみを呼びだす
標準ライブラリ
カーネルに対応して、(仮想的な)
CPU アーキテクチャ拡張
プログラムは、通常の標準ライブラリとして
リンクする
システムコールを経由して直接ホストの
資源アクセスは不可
musl libc の拡張として実装
25.
使い方 (アプリケーション)
Use Case 1: ネットワークシミュレータとの結合
Use Case 2: 簡易カーネルバイパス
Use Case 3: カーネルコードを再利用したアプリケーション開発
Use Case 4: Unikernel
26.
Use Case 1: ネットワークシミュレータとの結合
Linux Multipath-TCP の実験
可視化
ネットワーク状態の調査
ns-3 ネットワークシミュレータ
多種のモデル
NIC
ノード移動
トラフィック
タイミング
単一プロセスにて複数ノード動作
dlmopen(3) にて実現(シンボル退避)
システムコール再実装(ノード振り分け)
再現性100 % (実験・バグの再現)
27.
Use Case 1: ネットワークシミュレータとの結合
カーネルのネットワークスタックテストツールとしても利用
Regression テスト(を複雑なネットワークで)
再現率100 % (仮想クロックを利用)
コードカバレッジ測定(シミュレータの疑似乱数利用)
Valgrind でデバッグ
28.
Use Case 2: 簡易カーネルバイパス
LD_PRELOAD により、実行時にシステムコール迂回
置きかえ可能なシステムコール(シンボル) に制限あり
LKL と外界(ホストOS)の両方のシステムコールを利用可能
ホストカーネルに影響なく新機能を導入可能
LD_PRELOAD=liblkl-super-tcp++.so firefox
29.
Use Case 3: カーネルコードを再利
用したアプリケーション開発
カーネルのコードを移植なしにユーザ空間でライブラリとして利用
LKL と外界(ホストOS)の両方のシステムコールを利用可能
カーネル実装を利用したファイルシステムアクセス
例: ext4 フォーマットのディスクイメージにアクセス
1. ディスクイメージを開く(CreateFile())
2. lkl_sys_mount()
3. lkl_sys_read()
4. ホストの別ファイルへ書きこみ(WriteFile())
30.
Use Case 4: Unikernel
単一アプリケーションにリンクさせるLKL
python + LKL, nginx + LKL
LKL システムコールのみ利用可能
musl libc 移植
rump ハイパーコール利用(frankenlibc)
OS のないホスト上でも動作(rumprun)
(on Xen Mini-OS)
Work in progress
- http://www.linux.com/news/enterprise/cloud-
computing/751156-are-cloud-operating-
systems-the-next-big-thing-
31.
demos with linux kernel library
Unikernel on Linux (ping6 command
embedded kernel library)
Unikernel on qemu-arm (hello
world)
39.
参考資料
Linux Kernel Library
Purdila et al., LKL: The Linux kernel library, RoEduNet 2010.
Rumpkernel (dissertation)
Kantee, Flexible Operating System Internals: The Design and
Implementation of the Anykernel and Rump Kernels, Ph.D Thesis,
2012
Linux LibOS 一般
Tazaki et al. Direct Code Execution: Revisiting Library OS
Architecture for Reproducible Network Experiments, CoNEXT 2013
(LibOS in general)
https://github.com/lkl/linux
http://libos-nuse.github.io/
https://lwn.net/Articles/637658/
Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.
Be the first to comment