linux:kernel:cgroup:単一階層構造

文書の過去の版を表示しています。


単一階層構造

2-1 まで 4.3 カーネルの文書と同期。

Cgroup unified hierarchy

April, 2014		Tejun Heo <tj@kernel.org>

This document describes the changes made by unified hierarchy and
their rationales.  It will eventually be merged into the main cgroup
documentation.

この文書は単一階層構造によって起こる変化とその原理について説明する.こ
の文書は最終的にはメインの cgroup の文書にマージされる予定である.

CONTENTS

1. Background
2. Basic Operation
  2-1. Mounting
  2-2. cgroup.subtree_control
  2-3. cgroup.controllers
3. Structural Constraints
  3-1. Top-down
  3-2. No internal tasks
4. Other Changes
  4-1. [Un]populated Notification
  4-2. Other Core Changes
  4-3. Per-Controller Changes
    4-3-1. blkio
    4-3-2. cpuset
    4-3-3. memory
5. Planned Changes
  5-1. CAP for resource control


1. Background

cgroup allows arbitrary number of hierarchies and each hierarchy can
host any number of controllers.  While this seems to provide high
level of flexibility, it isn't quite useful in practice.

cgroup は任意の数の階層構造を作成可能で,それぞれがいくつもの数のコン
トローラをホスト可能である.これは高度な柔軟性を提供するように見えるが,
実際は役に立たない.

For example, as there is only one instance of each controller, utility
type controllers such as freezer which can be useful in all
hierarchies can only be used in one.  The issue is exacerbated by the
fact that controllers can't be moved around once hierarchies are
populated.  Another issue is that all controllers bound to a hierarchy
are forced to have exactly the same view of the hierarchy.  It isn't
possible to vary the granularity depending on the specific controller.

例えば,コントローラごとに一つのインスタンスのみあるような場合,全ての
階層構造に役に立つ freezer のようなユーティリティタイプのコントローラ
が 1 つでしか使えない.この問題は,一度階層が構築されると,コントロー
ラはあちこち移動することができないという事実によって悪化する.他に,階
層に結びついた全てのコントローラは,全く同じビューの階層をを持つことを
強制されているという問題がある.特定のコントローラに依存するような粒度
に変化することができない.

In practice, these issues heavily limit which controllers can be put
on the same hierarchy and most configurations resort to putting each
controller on its own hierarchy.  Only closely related ones, such as
cpu and cpuacct, make sense to put on the same hierarchy.  This often
means that userland ends up managing multiple similar hierarchies
repeating the same steps on each hierarchy whenever a hierarchy
management operation is necessary.

実際,これらの問題は同じ階層にコントローラを置く事を大きく制限しており,
ほとんどの構成では,各コントローラが自身の階層を持つ構成を用いている.
cpu と cpuacct のように密接に関係したコントローラだけが,同じ階層に置
く意味がある.これにより,ユーザランドでは,階層に対する操作が必要な時
は常に,同じような階層に対して,それぞれの階層に同じような操作を繰り返
すことになっている.

Unfortunately, support for multiple hierarchies comes at a steep cost.
Internal implementation in cgroup core proper is dazzlingly
complicated but more importantly the support for multiple hierarchies
restricts how cgroup is used in general and what controllers can do.

残念ながら、複数階層構造のサポートは法外なコストがかかる。適切な
cgroup コアの内部実装は目もくらむほど複雑であるが、より重要なのは、複
数階層構造のサポートは、一般的な cgroup の使い方やコントローラができる
ことをも制限してしまうことである。

There's no limit on how many hierarchies there may be, which means
that a task's cgroup membership can't be described in finite length.
The key may contain any varying number of entries and is unlimited in
length, which makes it highly awkward to handle and leads to addition
of controllers which exist only to identify membership, which in turn
exacerbates the original problem.

階層構造の数に制限がない事は、タスクが cgroup のメンバーであることが有限の
長さで記述できないということである。このキーポイントは、エントリ数が任
意に変化することと、長さが無制限になる事を含む。このことは、扱いが非常
に複雑になり、メンバーシップの確認のためだけに存在するコントローラの追
加につながる。この問題は巡り巡って元の問題を悪化させる。

Also, as a controller can't have any expectation regarding what shape
of hierarchies other controllers would be on, each controller has to
assume that all other controllers are operating on completely
orthogonal hierarchies.  This makes it impossible, or at least very
cumbersome, for controllers to cooperate with each other.

加えて、コントローラは他のコントローラがどのような階層の形状になるのか
に関しての予測ができないので、他のコントローラがそれぞれ完全に直交する
階層の上で操作されることを仮定しなければならない。コントローラがお互い
に協調して動作するには、これは不可能であるか、少なくとも非常に負荷が大
きくなる。

In most use cases, putting controllers on hierarchies which are
completely orthogonal to each other isn't necessary.  What usually is
called for is the ability to have differing levels of granularity
depending on the specific controller.  IOW, hierarchy may be collapsed
from leaf towards root when viewed from specific controllers.  For
example, a given configuration might not care about how memory is
distributed beyond certain level while still want to control how cpu
cycles are distributed.

ユースケースのほとんどでは、お互い完全に直交している階層構造にコントロー
ラを置く必要はない。通常求められているものは、特定のコントローラに依存
する異なる粒度のレベルを持つ能力である。言い換えると、階層は特定のコン
トローラの視点から見た時、末端からルートに向かって崩壊していくかもしれ
ないということである。例えば、与えられた設定では、あるレベルを超えてメ
モリを配分するかについては設定されないかもしれないが、CPU サイクルの分
配はコントロールしたいかもしれないというような事である。

Unified hierarchy is the next version of cgroup interface.  It aims to
address the aforementioned issues by having more structure while
retaining enough flexibility for most use cases.  Various other
general and controller-specific interface issues are also addressed in
the process.

単一階層構造は cgroup インターフェースの次のバージョンとなる。これは、
ほとんどのユースケースにおいて十分な柔軟性を確保しながら、前述の問題に
取り組むためのものである。

2. Basic Operation

2-1. Mounting

Currently, unified hierarchy can be mounted with the following mount
command.  Note that this is still under development and scheduled to
change soon.

現時点では、単一階層構造は以下のようなマウントコマンドでマウント可能で
ある。これはまだ開発中で、すぐに変更される予定であることに注意すること。

 mount -t cgroup -o __DEVEL__sane_behavior cgroup $MOUNT_POINT

All controllers which support the unified hierarchy and are not bound
to other hierarchies are automatically bound to unified hierarchy and
show up at the root of it.  Controllers which are enabled only in the
root of unified hierarchy can be bound to other hierarchies.  This
allows mixing unified hierarchy with the traditional multiple
hierarchies in a fully backward compatible way.

単一階層構造をサポートしており、他の階層にバインドされない全てのコント
ローラが、自動的に単一階層構造にバインドされ、そのルートに出現する。単
一階層のルート内でだけ有効なコントローラは、他の階層構造にバインドする
ことが可能である。これにより、単一階層構造と従来の複数階層構造を後方互
換性のために同居可能となる。

For development purposes, the following boot parameter makes all
controllers to appear on the unified hierarchy whether supported or
not.

開発目的で、以下のブートパラメータを指定すると、単一階層構造をサポート
している・いないに関わらず、全てのコントローラが単一階層構造下に現れる。

 cgroup__DEVEL__legacy_files_on_dfl

A controller can be moved across hierarchies only after the controller
is no longer referenced in its current hierarchy.  Because per-cgroup
controller states are destroyed asynchronously and controllers may
have lingering references, a controller may not show up immediately on
the unified hierarchy after the final umount of the previous
hierarchy.  Similarly, a controller should be fully disabled to be
moved out of the unified hierarchy and it may take some time for the
disabled controller to become available for other hierarchies;
furthermore, due to dependencies among controllers, other controllers
may need to be disabled too.

コントローラは、現在の階層内で参照されていない場合のみ、階層をまたいで
移動することができる。cgroup ごとのコントローラの状態は非同期で破壊さ
れ、参照が残ったままになる可能性があるので、前にマウントされていた階層
からアンマウントされたあとも、コントローラは単一階層構造にすぐに現れな
いかもしれない。同様に、コントローラが単一階層構造から出て行くには、完
全に無効化する必要がある。そして、無効化されたコントローラが他の階層で
利用可能になるには少し時間がかかるかもしれない。さらに、コントローラ間
の依存関係のために、他のコントローラも無効化する必要があるかもしれない。

While useful for development and manual configurations, dynamically
moving controllers between the unified and other hierarchies is
strongly discouraged for production use.  It is recommended to decide
the hierarchies and controller associations before starting using the
controllers.

開発と手動での設定には役に立つ一方で、単一階層構造と他の階層間でコント
ローラをダイナミックに移動することは、プロダクション利用では全く推奨さ
れない。

2-2. cgroup.subtree_control

All cgroups on unified hierarchy have "cgroup.subtree_control" file
which governs which controllers are enabled on the children of the
cgroup. Let's assume a hierarchy like the following.

単一階層上の全ての cgroup は cgroup.subtree_control ファイルを持つ。こ
れは、どのコントローラが cgroup の子供で有効になるのかを管理する。以下
のような階層を仮定しよう。

  root - A - B - C
               \ D

root's "cgroup.subtree_control" file determines which controllers are
enabled on A.  A's on B.  B's on C and D.  This coincides with the
fact that controllers on the immediate sub-level are used to
distribute the resources of the parent.  In fact, it's natural to
assume that resource control knobs of a child belong to its parent.
Enabling a controller in a "cgroup.subtree_control" file declares that
distribution of the respective resources of the cgroup will be
controlled.  Note that this means that controller enable states are
shared among siblings.

root の "cgroup.subtree_control" はどのコントローラが A で有効かを定義
する。A 上のものは B のを、B のものは C, D を定義する。これは、直近の
サブレベル上のコントローラは、親のリソースを分配するのに使われるという
事実に一致する。実際、親に属する子供のリソースコントロールノブを仮定す
るには自然である。"cgroup.subtree_control" でコントローラが有効化され
ると、それぞれの cgroup のリソースの配分を制御することを宣言することに
なる。コントローラの有効化の状態は兄弟間で共有されることを意味すること
に注意が必要である。

When read, the file contains space-separated list of currently enabled
controllers.  A write to the file should contain spaced-separated list
of controllers with '+' or '-' prefixed (without the quotes).
Controllers prefixed with '+' are enabled and '-' disabled.  If a
controller is listed multiple times, the last entry wins.  The
specific operations are executed atomically - either all succeed or
fail.

このファイルを読むと、現在有効なコントローラのスペース区切りのリストが
含まれる。ファイルへの書き込みは、コントローラの前に '+' か '-' をつけ
たスペース区切りのリストである必要がある (quote は不要)。'+' をつけた
コントローラは有効化され、'-' を付けたコントローラは無効化される。複数
回リストされているコントローラは最後の定義が有効になる。この指定のオペ
レーションはアトミックに実行される。つまり全て成功するか、全て失敗する
かである。

2-3. cgroup.controllers

Read-only "cgroup.controllers" contains space-separated list of
controllers which can be enabled in the cgroup's
"cgroup.subtree_control".

読み取り専用の "cgroup.controllers" はスペース区切りのコントローラのリ
ストが記載されている。このリストは "cgroup.subtree_control" で有効にす
ることのできるコントローラの一覧である。

In the root cgroup, this lists controllers which are not bound to
other hierarchies and the content changes as controllers are bound to
and unbound from other hierarchies.

ルート cgroup では、これは他の階層にバインドされていないコントローラの
リストとなる。また、ファイルの内容はコントローラが他の階層にバインドさ
れたりバインドを解除されたりすると変化する。

In non-root cgroups, the content of this file equals that of the
parent's "cgroup.subtree_control" as only controllers enabled from the
parent can be used in its children.

ルートでない cgroup では、このファイルの内容は親の
"cgroup.subtree_control" の内容に等しい。親で有効になったコントローラ
だけが子供内で使用できるからである。

3. Structural Constraints

3-1. Top-down

As it doesn't make sense to nest control of an uncontrolled resource,
all non-root "cgroup.subtree_control" can only contain controllers
which are enabled in the parent's "cgroup.subtree_control".  A
controller can be enabled only if the parent has the controller
enabled and a controller can't be disabled if one or more children
have it enabled.

コントロールできないリソースのネストされたコントロールに意味がないよう
に、全てのルート以外の "cgroup.subtree_control" は、親の
"cgroup.subtree_control" で有効になったコントローラだけを含む。コント
ローラは親で有効化されている時だけ有効にでき、有効にしている子供がいる
場合は無効化できない。

3-2. No internal tasks

One long-standing issue that cgroup faces is the competition between
tasks belonging to the parent cgroup and its children cgroups.  This
is inherently nasty as two different types of entities compete and
there is no agreed-upon obvious way to handle it.  Different
controllers are doing different things.

cgroup が直面している長年の課題は、親の cgroup に属するタスクと、その
子供に属するタスク間の競合である。これは2つの異なるタイプのエンティティ
の競合であり本質的に扱いにくい。これを扱う明確な同意された方法はない。
異なるコントローラは異なることを行っている。

cpu considers tasks and cgroups as equivalents and maps nice level to
cgroup weights.  This works for some cases but falls flat when
children should be allocated specific ratios of cpu cycles and the
number of internal tasks fluctuates - the ratios constantly change as
the number of competing entities fluctuates.  There also are other
issues.  The mapping from nice level to weight isn't obvious or
universal, and there are various other knobs which simply aren't
available for tasks.

cpu はタスクと cgroup を等価なものとみなし、nice レベルを cgroup のウェ
イトとマップする。これが有効なケースもあるが、子供に特定の割合で CPU
サイクルを割り当てる必要があるとき、そして内部タスクの数が変動するとき、
つまり競合するエンティティの数が変動して、割合が変化するときに破綻する。
他の問題も存在する。nice レベルのウェイトへのマッピングは明確で共通の
方法が存在するわけではない。単純にタスクに利用できない他の様々なノブが
存在する。

blkio implicitly creates a hidden leaf node for each cgroup to host
the tasks.  The hidden leaf has its own copies of all the knobs with
"leaf_" prefixed.  While this allows equivalent control over internal
tasks, it's with serious drawbacks.  It always adds an extra layer of
nesting which may not be necessary, makes the interface messy and
significantly complicates the implementation.

blkio はタスクを扱うために暗黙にそれぞれの cgroup にリーフノードを作成
する。この隠れたリーフは自身のコピーとして、頭に "leaf_" と付いた全て
のノブを持つ。これは同等のコントロールが内部タスクにも可能になるが、重
大な欠点も持つ。常に必要ではないかもしれないネストした余分なレイヤーを
追加し、インターフェースを乱雑にして、実装をかなり複雑にする。

memory currently doesn't have a way to control what happens between
internal tasks and child cgroups and the behavior is not clearly
defined.  There have been attempts to add ad-hoc behaviors and knobs
to tailor the behavior to specific workloads.  Continuing this
direction will lead to problems which will be extremely difficult to
resolve in the long term.

メモリは現時点では内部タスクと子cgroup間で起こっていることをコントロー
ルする方法はない。そして、振る舞いが明確には定義されていない。特定の作
業に振る舞いを合わせるためのアドホックな振る舞いとノブが追加されてきた。
この方向性を続けることは長期間に渡って解決が非常に難しい問題を引き起こ
すだろう。

Multiple controllers struggle with internal tasks and came up with
different ways to deal with it; unfortunately, all the approaches in
use now are severely flawed and, furthermore, the widely different
behaviors make cgroup as whole highly inconsistent.

複数のコントローラが内部タスクと奮闘しており、それを解決する色々な方法
を考えだしてきた。不幸にも、現在使用中の全てのアプローチは重大な欠点が
ある。その上、非常に異なった振る舞いが cgroup 全体を完全に一貫性のない
ものにしている。

It is clear that this is something which needs to be addressed from
cgroup core proper in a uniform way so that controllers don't need to
worry about it and cgroup as a whole shows a consistent and logical
behavior.  To achieve that, unified hierarchy enforces the following
structural constraint.

コントローラがそれについて心配する必要がないように、cgroup が全体とし
て一貫性とロジカルな振る舞いを示すように均一的な方法で cgroup core の
適正化に取り組む必要があるのは明らかある。これを達成するため、単一階層
構造では、以下の構造的な制約を強制する。

 Except for the root, only cgroups which don't contain any task may
 have controllers enabled in "cgroup.subtree_control".

 root を除いて、タスクを持たない cgroup だけが
 "cgroup.subtree_control" で有効になっているコントローラを持つことができる。

Combined with other properties, this guarantees that, when a
controller is looking at the part of the hierarchy which has it
enabled, tasks are always only on the leaves.  This rules out
situations where child cgroups compete against internal tasks of the
parent.

他のプロパティとくみあわせることで、この制約は、コントローラが有効にさ
れている階層の一部を見ているときは、常にタスクは葉ノードにのみ存在する
ことを保証します。これで、子 cgroup は親の内部タスクと競合するシチュエー
ションから逃れられます。

There are two things to note.  Firstly, the root cgroup is exempt from
the restriction.  Root contains tasks and anonymous resource
consumption which can't be associated with any other cgroup and
requires special treatment from most controllers.  How resource
consumption in the root cgroup is governed is upto each controller.

注意すべき点が2つある。root cgroup は制約を免除される。root は、
他の cgroup に関連付けることができないタスクやリソース消費を含んでおり、
ほとんどのコントローラから特別な扱いが必要である。root cgroup 内でどの
ようにしてリソース消費を管理するかは、それぞれのコントローラ次第である。

Secondly, the restriction doesn't take effect if there is no enabled
controller in the cgroup's "cgroup.subtree_control".  This is
important as otherwise it wouldn't be possible to create children of a
populated cgroup.  To control resource distribution of a cgroup, the
cgroup must create children and transfer all its tasks to the children
before enabling controllers in its "cgroup.subtree_control".

2つ目は、cgroup の "cgroup.subtree_control" で有効にされているコントロー
ラがない場合は、制約は効かないことである。でないとタスクが存在する
cgroup の子供を作れないので重要なことである。cgroup のリソース配分をコ
ントロールするために、cgroup は子を作らなければならない。そして
"cgroup.subtree_control" でコントローラを有効にする前に、そのタスクの
全てを子に移動させなければならない。
4. Other Changes

4-1. [Un]populated Notification

cgroup users often need a way to determine when a cgroup's
subhierarchy becomes empty so that it can be cleaned up.  cgroup
currently provides release_agent for it; unfortunately, this mechanism
is riddled with issues.

cgroup ユーザはよく cgroup のサブの階層が空になった際にクリーンアップ
できるように決定する方法が必要になることがある。cgroup は現在、この用
途のために release_agent を提供している。不幸なことに、このメカニズム
は問題に満ちあふれている。

- It delivers events by forking and execing a userland binary
  specified as the release_agent.  This is a long deprecated method of
  notification delivery.  It's extremely heavy, slow and cumbersome to
  integrate with larger infrastructure.
  
- これは release_agent で指定されたユーザランドのバイナリを fork して
  実行することでイベントを伝える。これは長く廃止予定となっている通知配
  信の方法である。大きなインフラで integrate するのが、極めて重く、遅
  い。

- There is single monitoring point at the root.  There's no way to
  delegate management of subtree.

- root に単一モニタリングポイントが存在する。サブツリーの管理を委任す
  る方法がない。

- The event isn't recursive.  It triggers when a cgroup doesn't have
  any tasks or child cgroups.  Events for internal nodes trigger only
  after all children are removed.  This again makes it impossible to
  delegate management of subtree.

- イベントは再帰的ではない。cgroup がタスクや子 cgroup を持っていない
  時にトリガする。内部ノードのイベントは、全ての子が削除された後にだけ
  トリガする。これも、サブツリーの管理の委任を不可能にする。

- Events are filtered from the kernel side.  "notify_on_release" file
  is used to subscribe to or suppress release event.  This is
  unnecessarily complicated and probably done this way because event
  delivery itself was expensive.

- イベントはカーネル側からフィルタされる。"notify_on_release" ファイル
  がリリースイベントを購読したり、やめたりするのに使われる。これは不必
  要に複雑であり、イベント配信自体が高価なのでおそらくこの方法で行われ
  る。

Unified hierarchy implements interface file "cgroup.subtree_populated"
which can be used to monitor whether the cgroup's subhierarchy has
tasks in it or not.  Its value is 0 if there is no task in the cgroup
and its descendants; otherwise, 1.  poll and [id]notify events are
triggered when the value changes.

単一階層構造はインターフェースとして "cgroup.subtree_populated" ファイ
ルを実装する。これは cgroup のサブ階層がタスクを持っているかいないかを
モニタするのに使われる。cgroup と子孫内にタスクがなければその値は 0 と
なる。そうでなければ 1 となる。この値が変わった場合、poll と
[id]notify イベントがトリガされる。

This is significantly lighter and simpler and trivially allows
delegating management of subhierarchy - subhierarchy monitoring can
block further propagation simply by putting itself or another process
in the root of the subhierarchy and monitor events that it's
interested in from there without interfering with monitoring higher in
the tree.

これは大幅に軽く、シンプルで、サブ階層の管理を委任できるのは明らかであ
る。サブ階層のモニタは、自身もしくは他のプロセスをサブ階層のルートに置
くことだけで更なる伝播をブロックできる。また、対象のモニタイベントをツ
リーの上位のモニタリングを妨げることなく、そこから監視できる。

In unified hierarchy, release_agent mechanism is no longer supported
and the interface files "release_agent" and "notify_on_release" do not
exist.

単一階層内では、release_agent メカニズムはもはやサポートされない。
"release_agent" インターフェースファイルと "notify_on_release" インター
フェースファイルも存在しない。

4-2. Other Core Changes

- None of the mount options is allowed.

- マウントオプションなしでも良くなる

- remount is disallowed.

- 再マウントは許可されない

- rename(2) is disallowed.

- rename(2) は許可されない

- "tasks" is removed.  Everything should at process granularity.  Use
  "cgroup.procs" instead.

- "tasks" は消去される。全てはプロセスの粒度でなされるべき。
  "cgroup.procs" が代わりに使われる。

- "cgroup.procs" is not sorted.  pids will be unique unless they got
  recycled in-between reads.

- "cgroup.procs" はソートされない。pid は、読み込み中にリサイクルされ
  た場合を除いてユニークである。

- "cgroup.clone_children" is removed.

- "cgroup.clojne_children" は消去される。

4-3. Per-Controller Changes

4-3-1. blkio

- blk-throttle becomes properly hierarchical.

- blk-throttle が適切に改造構造となる

4-3-2. cpuset

- Tasks are kept in empty cpusets after hotplug and take on the masks
  of the nearest non-empty ancestor, instead of being moved to it.
  
- hotplug 後の空の cpuset 内のタスクは保持され、最も近い祖先に移動する
  代わりに、最も近い祖先のマスクを引き受ける。

- A task can be moved into an empty cpuset, and again it takes on the
  masks of the nearest non-empty ancestor.

- タスクを空の cpuset に移動することは可能である。そしてこの場合も最も
  近い空でない祖先のマスクを引き受ける。

4-3-3. memory

- use_hierarchy is on by default and the cgroup file for the flag is
  not created.

- use_hierarchy はデフォルトでオンになる。このフラグ用の cgroup ファイルは生成されない。

5. Planned Changes

5-1. CAP for resource control

Unified hierarchy will require one of the capabilities(7), which is
yet to be decided, for all resource control related knobs.  Process
organization operations - creation of sub-cgroups and migration of
processes in sub-hierarchies may be delegated by changing the
ownership and/or permissions on the cgroup directory and
"cgroup.procs" interface file; however, all operations which affect
resource control - writes to "cgroup.subtree_control" or any
controller-specific knobs - will require an explicit CAP privilege.

単一階層構造には、まだ決定していないが、全てのリソースコントロールに関
係するノブに、ケーパビリティがひとつ必要になるだろう。サブグループの作
成やサブ階層へのマイグレーションと言ったようなプロセスの集合に対する操
作は cgroup ディレクトリや "cgroup.procs" の所有権やパーミッションを変
えることによって伝播する可能性がある。一方、リソースコントロールに影響
する全ての操作、つまり "cgroup.subtree_control" や任意のコントローラ特
有のノブに対する書き込みのような操作は、明確 CAP 特権が必要となるだろう。

This, in part, is to prevent cgroup interface from being inadvertently
promoted to programmable API used by non-privileged binaries.  cgroup
exposes various aspects of the system in ways which aren't properly
abstracted for direct consumption by regular programs.  This is an
administration interface much closer to sysctl knobs than system
calls.  Even the basic access model, being filesystem path based,
isn't suitable for direct consumption.  There's no way to access "my
cgroup" in race-free way or make multiple operations atomic against
migration to another cgroup.

これはある程度、cgroup インターフェースの、非特権バイナリが使うプログ
ラマブル API に対する意図しない昇格を防ぐためのものである。cgroup は通
常のプログラムの消費を直接、適切に抽象化されない方法でシステムの色々な側
面を露出している。これはシステムコールよりも sysctl ノブに近い管理イン
ターフェースである。ファイルシステムのパスベースの通常のアクセスモデル
は、直接の消費には向いていない。競合のない方法で「私のcgroup」にア
クセスする方法がなく、他のcgroupへのマイグレーションに対する複数の操作
をアトミックにする方法もない。

Another aspect is that, for better or for worse, cgroup interface goes
through far less scrutiny than regular interfaces for unprivileged
userland.  The upside is that cgroup is able to expose useful features
which may not be suitable for general consumption in reasonable time
frame.  It provides a relatively short path between internal details
and userland-visible interface.  Of course, this shortcut comes with
high risk.  We go through what we go through for general kernel APIs
for good reasons.  It may end up leaking internal details in a way
which can exert significant pain by locking the kernel into a contract
that can't be maintained in a reasonable manner.

別の側面は、良きにせよ悪しきにせよ、cgroup インターフェースは非特権ユー
ザランドに対する通常のインターフェースに比べてはるかに精密でなく使うこ
とができる。この良い面は、妥当な時間枠内での一般的な消費に対して適切で
ない可能性のある有用な機能を見せることができることである。これは比較的
最短経路で内部の詳細とユーザランドで見ることのできるインターフェースを
提供する。もちろん、このショートカットは高いリスクを伴う。我々は正当な
理由で一般的なカーネル API を通したものを通します。これは、妥当な方法
で扱うことができない決まりでカーネルを閉じ込める事により、重大な痛みを
行使する可能性のある方法で最終的には内部の詳細なリークとなるかもしれな
い。

Also, due to the specific nature, cgroup and its controllers don't
tend to attract attention from wide-scope of developers.  cgroup's
short history is already fraught with severely mis-designed
interfaces, unnecessary commitment to and exposing of internal
details, broken and dangerous implementations of various features.

また、この特有の性質により、cgroup とコントローラは開発者の広いスコー
プから注意を引きつけない傾向がある。cgroup の小史は厳しくミスデザイン
されたインターフェース、不必要なコミットと内部の詳細の公開、様々な機能
の壊れた危険な実装で既に困難なものである。

Keeping cgroup as an administration interface is both advantageous for
its role and an imperative given its nature.  Some of the cgroup
features may make sense for unprivileged access.  If deemed justified,
those must be further abstracted and implemented as a different
interface, be it a system call or process-private filesystem, and
survive through the scrutiny that any interface for general
consumption is required to go through.

cgroup を管理インターフェースとして維持し続けることは、その役割が得に
なる事と、与えられたその性質が不可欠であることの両方である。cgroup の
機能には、非特権アクセスの意味がある可能性があるものがある。もし理にか
なっていると考えるのなら、より抽象化され、システムコールやプロセス独自
のファイルシステムのような異なるインターフェースで実装され、一般的な消
費が通ることが必要な任意のインターフェースの精査を通して存続し続けなけ
ればならない。

Requiring CAP is not a complete solution but should serve as a
significant deterrent against spraying cgroup usages in non-privileged
programs.

CAPの必要性は完全な解決策ではない。しかし非特権プログラムのスプレーす
るような cgroup の使用に対する重要な抑止力としての役割を果たすだろう。
  • linux/kernel/cgroup/単一階層構造.1450083311.txt.gz
  • 最終更新: 2015/12/14 08:55
  • (外部編集)