요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
Resource accounting
rdma.rst:37-91Cgroup·device별 pool, css ownership, migration과 resource type을 정리합니다.
Usage examples
rdma.rst:92-117`rdma.max`와 `rdma.current`의 설정·조회·삭제 예제를 보존합니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===============
RDMA Controller
===============
.. Contents
1. Overview
1-1. What is RDMA controller?
1-2. Why RDMA controller needed?
1-3. How is RDMA controller implemented?
2. Usage Examples
1. Overview
===========
1-1. What is RDMA controller?
-----------------------------
RDMA controller allows user to limit RDMA/IB specific resources that a given
set of processes can use. These processes are grouped using RDMA controller.
RDMA controller defines two resources which can be limited for processes of a
cgroup.
1-2. Why RDMA controller needed?
--------------------------------
Currently user space applications can easily take away all the rdma verb
specific resources such as AH, CQ, QP, MR etc. Due to which other applications
in other cgroup or kernel space ULPs may not even get chance to allocate any
rdma resources. This can lead to service unavailability.
Therefore RDMA controller is needed through which resource consumption
of processes can be limited. Through this controller different rdma
resources can be accounted.
1-3. How is RDMA controller implemented?
----------------------------------------
RDMA cgroup allows limit configuration of resources. Rdma cgroup maintains
resource accounting per cgroup, per device using resource pool structure.
Each such resource pool is limited up to 64 resources in given resource pool
by rdma cgroup, which can be extended later if required.
This resource pool object is linked to the cgroup css. Typically there
are 0 to 4 resource pool instances per cgroup, per device in most use cases.
But nothing limits to have it more. At present hundreds of RDMA devices per
single cgroup may not be handled optimally, however there is no
known use case or requirement for such configuration either.
Since RDMA resources can be allocated from any process and can be freed by any
of the child processes which shares the address space, rdma resources are
always owned by the creator cgroup css. This allows process migration from one
to other cgroup without major complexity of transferring resource ownership;
because such ownership is not really present due to shared nature of
rdma resources. Linking resources around css also ensures that cgroups can be
deleted after processes migrated. This allow progress migration as well with
active resources, even though that is not a primary use case.
Whenever RDMA resource charging occurs, owner rdma cgroup is returned to
the caller. Same rdma cgroup should be passed while uncharging the resource.
This also allows process migrated with active RDMA resource to charge
to new owner cgroup for new resource. It also allows to uncharge resource of
a process from previously charged cgroup which is migrated to new cgroup,
even though that is not a primary use case.
Resource pool object is created in following situations.
(a) User sets the limit and no previous resource pool exist for the device
of interest for the cgroup.
(b) No resource limits were configured, but IB/RDMA stack tries to
charge the resource. So that it correctly uncharge them when applications are
running without limits and later on when limits are enforced during uncharging,
otherwise usage count will drop to negative.
Resource pool is destroyed if all the resource limits are set to max and
it is the last resource getting deallocated.
User should set all the limit to max value if it intents to remove/unconfigure
the resource pool for a particular device.
IB stack honors limits enforced by the rdma controller. When application
query about maximum resource limits of IB device, it returns minimum of
what is configured by user for a given cgroup and what is supported by
IB device.
Following resources can be accounted by rdma controller.
========== =============================
hca_handle Maximum number of HCA Handles
hca_object Maximum number of HCA Objects
========== =============================
2. Usage Examples
=================
(a) Configure resource limit::
echo mlx4_0 hca_handle=2 hca_object=2000 > /sys/fs/cgroup/rdma/1/rdma.max
echo ocrdma1 hca_handle=3 > /sys/fs/cgroup/rdma/2/rdma.max
(b) Query resource limit::
cat /sys/fs/cgroup/rdma/2/rdma.max
#Output:
mlx4_0 hca_handle=2 hca_object=2000
ocrdma1 hca_handle=3 hca_object=max
(c) Query current usage::
cat /sys/fs/cgroup/rdma/2/rdma.current
#Output:
mlx4_0 hca_handle=1 hca_object=20
ocrdma1 hca_handle=1 hca_object=23
(d) Delete resource limit::
echo mlx4_0 hca_handle=max hca_object=max > /sys/fs/cgroup/rdma/1/rdma.max
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
RDMA controller의 범위
1-24이 문서는 overview에서 RDMA controller의 정의, 필요성, 구현을 설명한 뒤 usage example을 제공합니다.
RDMA controller는 주어진 process 집합이 사용할 수 있는 RDMA/IB 전용 resource를 제한합니다. 이 process들은 RDMA controller를 이용해 group으로 묶입니다.
RDMA controller는 cgroup의 process에 대해 제한할 수 있는 resource 두 종류를 정의합니다.
RDMA resource 제한이 필요한 이유
25-36현재 user-space application은 `AH`, `CQ`, `QP`, `MR` 같은 RDMA verb 전용 resource를 모두 쉽게 차지할 수 있습니다. 그러면 다른 cgroup의 application이나 kernel-space `ULP`가 RDMA resource를 할당받을 기회조차 잃어 service unavailable 상태가 될 수 있습니다.
따라서 process의 resource consumption을 제한하고 서로 다른 RDMA resource를 account하기 위해 RDMA controller가 필요합니다.
Controller가 없을 때 한 workload가 resource를 소진하는 문제를 cgroup limit으로 막습니다.
Resource pool과 css ownership
37-84RDMA cgroup은 resource limit을 설정할 수 있게 하며, resource pool structure를 이용해 cgroup별·device별 accounting을 유지합니다. 각 resource pool은 현재 최대 64종의 resource를 담을 수 있고 필요하면 나중에 확장할 수 있습니다.
Resource pool object는 cgroup `css`에 연결됩니다. 일반적인 use case에서는 cgroup·device마다 pool instance가 0~4개이지만 더 많이 두는 것을 막는 제한은 없습니다. 다만 한 cgroup에 수백 개 RDMA device를 두는 구성은 현재 최적으로 처리되지 않을 수 있으며, 알려진 use case나 요구도 없습니다.
RDMA resource는 어느 process에서든 allocate될 수 있고 address space를 공유하는 child process 어느 쪽에서든 free될 수 있으므로 항상 creator cgroup `css`가 소유합니다. Shared resource 특성상 개별 process ownership을 실질적으로 이전하지 않아도 되어, process를 다른 cgroup으로 옮길 때 resource ownership transfer의 큰 복잡성을 피할 수 있습니다.
Resource를 `css`에 연결하면 process migration 뒤 cgroup을 삭제할 수 있고, 주된 use case는 아니지만 active resource를 가진 상태의 process migration도 진행할 수 있습니다.
RDMA resource를 charge할 때 caller에는 owner RDMA cgroup이 반환됩니다. Resource를 uncharge할 때 반드시 같은 RDMA cgroup을 전달해야 합니다. 따라서 active RDMA resource를 가진 process가 migrate한 뒤 새 resource는 새 owner cgroup에 charge하면서, 이전에 charge된 resource는 원래 cgroup에서 올바르게 uncharge할 수 있습니다.
Pool을 만들고 유지하고 제거하는 조건입니다.
Limit이 아직 없더라도 IB/RDMA stack이 resource를 charge하면 pool을 만듭니다. 제한 없이 실행한 application의 resource를 나중에 limit 적용 중 uncharge할 때 usage count가 음수가 되지 않게 하기 위해서입니다.
모든 resource limit이 `max`이고 마지막 resource가 deallocate되면 pool을 파괴합니다. 특정 device의 resource pool 설정을 제거하려면 모든 limit을 `max`로 설정해야 합니다.
IB stack은 RDMA controller가 강제한 limit을 따릅니다. Application이 IB device의 maximum resource limit을 질의하면, 해당 cgroup에 사용자가 설정한 값과 IB device가 지원하는 값 가운데 더 작은 값을 반환합니다.
Active resource와 새 resource가 서로 다른 owner cgroup에 정확히 account되는 방식입니다.
Account 가능한 resource
85-91RDMA controller는 다음 resource를 account할 수 있습니다.
원문의 resource 표를 구조화했습니다.
rdma.max와 rdma.current 사용 예제
92-117Resource limit은 device 이름 뒤에 `resource=value` 쌍을 적어 `rdma.max`에 씁니다. 첫 명령은 `mlx4_0`의 `hca_handle`을 `2`, `hca_object`를 `2000`으로 제한하고, 둘째 명령은 `ocrdma1`의 `hca_handle`을 `3`으로 제한합니다.
echo mlx4_0 hca_handle=2 hca_object=2000 > /sys/fs/cgroup/rdma/1/rdma.max
echo ocrdma1 hca_handle=3 > /sys/fs/cgroup/rdma/2/rdma.max
`rdma.max`를 읽으면 device별 limit이 출력됩니다. 명시하지 않은 `ocrdma1 hca_object`는 `max`입니다.
cat /sys/fs/cgroup/rdma/2/rdma.max
#Output:
mlx4_0 hca_handle=2 hca_object=2000
ocrdma1 hca_handle=3 hca_object=max
`rdma.current`는 device별 현재 usage를 보여 줍니다. 예제에서는 `mlx4_0`이 handle `1`과 object `20`, `ocrdma1`이 handle `1`과 object `23`을 사용합니다.
cat /sys/fs/cgroup/rdma/2/rdma.current
#Output:
mlx4_0 hca_handle=1 hca_object=20
ocrdma1 hca_handle=1 hca_object=23
Resource limit을 삭제하려면 해당 device의 모든 값을 `max`로 설정합니다.
echo mlx4_0 hca_handle=max hca_object=max > /sys/fs/cgroup/rdma/1/rdma.max
Overview and need
rdma.rst:1-36RDMA resource exhaustion 문제와 controller의 제한 범위를 설명합니다.