wutiejun / workspace

My workspace.
7 stars 3 forks source link

内核CGroup翻译 #8

Open wutiejun opened 8 years ago

wutiejun commented 8 years ago

~\linux-3.10.53\Documentation\cgroups\cgroups.txt

CGROUPS


Written by Paul Menage menage@google.com based on Documentation/cgroups/cpusets.txt

Original copyright statements from cpusets.txt: Portions Copyright (C) 2004 BULL SA. Portions Copyright (c) 2004-2006 Silicon Graphics, Inc. Modified by Paul Jackson pj@sgi.com Modified by Christoph Lameter clameter@sgi.com

CONTENTS:

  1. Control Groups 1.1 What are cgroups ? 1.2 Why are cgroups needed ? 1.3 How are cgroups implemented ? 1.4 What does notify_on_release do ? 1.5 What does clone_children do ? 1.6 How do I use cgroups ?
  2. Usage Examples and Syntax 2.1 Basic Usage 2.2 Attaching processes 2.3 Mounting hierarchies by name 2.4 Notification API
  3. Kernel API 3.1 Overview 3.2 Synchronization 3.3 Subsystem API
  4. Extended attributes usage
  5. Questions
wutiejun commented 8 years ago

1. Control Groups 控制组

1.1 What are cgroups ? 什么是控制组

Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour.

控制组提供了一个机制, 让聚合/部份的任务的集合, 以及他们未来的子进程, 放到一个继承的组中, 拥有特殊的的行为.

Definitions: 定义

A cgroup associates a set of tasks with a set of parameters for one or more subsystems. 一个cgroup关联到一个任务的集合, 拥有一个或者多个子系统的参数.

A subsystem is a module that makes use of the task grouping facilities provided by cgroups to treat groups of tasks in particular ways. A subsystem is typically a "resource controller" that schedules a resource or applies per-cgroup limits, but it may be anything that wants to act on a group of processes, e.g. a virtualization subsystem.

一个子系统是一个模块, 通过cgroup提供的分组机制, 用于 具体的方法. 一个子系统, 通常就是一个资源控制器, 用于调度资源, 或者应用每个cgroup的限制, 但它也可能是任何想要上演的事情, 在一个进程的组, 例如: 一个虚拟的子系统.

A hierarchy is a set of cgroups arranged in a tree, such that every task in the system is in exactly one of the cgroups in the hierarchy, and a set of subsystems; each subsystem has system-specific state attached to each cgroup in the hierarchy. Each hierarchy has an instance of the cgroup virtual filesystem associated with it.

继承是一个cgroup在一个树中的排列, 例如在它系统里的每一个任务, 也明确的是cgroup中继承的一员. 而且, 一个子系统的集合, 每个子系统有一个系统指定的状态 , 附加在每个cgroup的继承中. 每个继承有一个cgroup的实例.

At any one time there may be multiple active hierarchies of task cgroups. Each hierarchy is a partition of all tasks in the system.

User-level code may create and destroy cgroups by name in an instance of the cgroup virtual file system, specify and query to which cgroup a task is assigned, and list the task PIDs assigned to a cgroup. Those creations and assignments only affect the hierarchy associated with that instance of the cgroup file system.

On their own, the only use for cgroups is for simple job tracking. The intention is that other subsystems hook into the generic cgroup support to provide new attributes for cgroups, such as accounting/limiting the resources which processes in a cgroup can access. For example, cpusets (see Documentation/cgroups/cpusets.txt) allow you to associate a set of CPUs and a set of memory nodes with the tasks in each cgroup.