요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
======================
Userspace verbs access
======================
The ib_uverbs module, built by enabling CONFIG_INFINIBAND_USER_VERBS,
enables direct userspace access to IB hardware via "verbs," as
described in chapter 11 of the InfiniBand Architecture Specification.
To use the verbs, the libibverbs library, available from
https://github.com/linux-rdma/rdma-core, is required. libibverbs contains a
device-independent API for using the ib_uverbs interface.
libibverbs also requires appropriate device-dependent kernel and
userspace driver for your InfiniBand hardware. For example, to use
a Mellanox HCA, you will need the ib_mthca kernel module and the
libmthca userspace driver be installed.
User-kernel communication
=========================
Userspace communicates with the kernel for slow path, resource
management operations via the /dev/infiniband/uverbsN character
devices. Fast path operations are typically performed by writing
directly to hardware registers mmap()ed into userspace, with no
system call or context switch into the kernel.
Commands are sent to the kernel via write()s on these device files.
The ABI is defined in drivers/infiniband/include/ib_user_verbs.h.
The structs for commands that require a response from the kernel
contain a 64-bit field used to pass a pointer to an output buffer.
Status is returned to userspace as the return value of the write()
system call.
Resource management
===================
Since creation and destruction of all IB resources is done by
commands passed through a file descriptor, the kernel can keep track
of which resources are attached to a given userspace context. The
ib_uverbs module maintains idr tables that are used to translate
between kernel pointers and opaque userspace handles, so that kernel
pointers are never exposed to userspace and userspace cannot trick
the kernel into following a bogus pointer.
This also allows the kernel to clean up when a process exits and
prevent one process from touching another process's resources.
Memory pinning
==============
Direct userspace I/O requires that memory regions that are potential
I/O targets be kept resident at the same physical address. The
ib_uverbs module manages pinning and unpinning memory regions via
get_user_pages() and put_page() calls. It also accounts for the
amount of memory pinned in the process's pinned_vm, and checks that
unprivileged processes do not exceed their RLIMIT_MEMLOCK limit.
Pages that are pinned multiple times are counted each time they are
pinned, so the value of pinned_vm may be an overestimate of the
number of pages pinned by a process.
/dev files
==========
To create the appropriate character device files automatically with
udev, a rule like::
KERNEL=="uverbs*", NAME="infiniband/%k"
can be used. This will create device nodes named::
/dev/infiniband/uverbs0
and so on. Since the InfiniBand userspace verbs should be safe for
use by non-privileged processes, it may be useful to add an
appropriate MODE or GROUP to the udev rule.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Userspace verbs 구성 요소
1-17`CONFIG_INFINIBAND_USER_VERBS`를 활성화해 빌드하는 `ib_uverbs` 모듈은 InfiniBand Architecture Specification 11장에 설명된 verbs를 통해 사용자 공간이 IB 하드웨어에 직접 접근할 수 있게 합니다.
Verbs를 사용하려면 `https://github.com/linux-rdma/rdma-core`에서 제공하는 `libibverbs` 라이브러리가 필요합니다. `libibverbs`는 `ib_uverbs` 인터페이스를 사용하는 장치 독립 API를 제공합니다.
또한 실제 InfiniBand 하드웨어에 맞는 장치 의존 커널 드라이버와 사용자 공간 드라이버가 모두 필요합니다. 예를 들어 Mellanox HCA를 사용하려면 `ib_mthca` 커널 모듈과 `libmthca` 사용자 공간 드라이버를 설치해야 합니다.
장치 독립 API부터 하드웨어 의존 드라이버까지 필요한 구성 요소입니다.
커널 구성부터 애플리케이션 API 사용까지의 의존 관계입니다.
======================
Userspace verbs access
======================
The ib_uverbs module, built by enabling CONFIG_INFINIBAND_USER_VERBS,
enables direct userspace access to IB hardware via "verbs," as
described in chapter 11 of the InfiniBand Architecture Specification.
To use the verbs, the libibverbs library, available from
https://github.com/linux-rdma/rdma-core, is required. libibverbs contains a
device-independent API for using the ib_uverbs interface.
libibverbs also requires appropriate device-dependent kernel and
userspace driver for your InfiniBand hardware. For example, to use
a Mellanox HCA, you will need the ib_mthca kernel module and the
libmthca userspace driver be installed.
User-kernel communication
느린 경로 ABI와 빠른 경로 mmap
18-34사용자 공간은 느린 경로의 자원 관리 연산을 `/dev/infiniband/uverbsN` 문자 장치를 통해 커널과 교환합니다. 반면 빠른 경로 연산은 보통 사용자 공간에 `mmap()`된 하드웨어 레지스터에 직접 기록하므로 시스템 호출이나 커널로의 컨텍스트 전환이 필요하지 않습니다.
커널 명령은 이 장치 파일에 대한 `write()`로 전달합니다. ABI는 `drivers/infiniband/include/ib_user_verbs.h`에 정의됩니다.
커널 응답이 필요한 명령 구조체에는 출력 버퍼 포인터를 전달하는 64비트 필드가 있습니다. 명령 상태는 `write()` 시스템 호출의 반환값으로 사용자 공간에 돌아옵니다.
커널 개입, 접근 방식, 대표 목적을 비교합니다.
사용자 버퍼와 `write()` 반환값을 이용하는 ABI 흐름입니다.
=========================
Userspace communicates with the kernel for slow path, resource
management operations via the /dev/infiniband/uverbsN character
devices. Fast path operations are typically performed by writing
directly to hardware registers mmap()ed into userspace, with no
system call or context switch into the kernel.
Commands are sent to the kernel via write()s on these device files.
The ABI is defined in drivers/infiniband/include/ib_user_verbs.h.
The structs for commands that require a response from the kernel
contain a 64-bit field used to pass a pointer to an output buffer.
Status is returned to userspace as the return value of the write()
system call.
Resource management
===================
파일 컨텍스트와 IDR 자원 격리
35-47모든 IB 자원의 생성과 파괴가 파일 디스크립터를 통해 전달되는 명령으로 수행되므로, 커널은 각 사용자 공간 컨텍스트에 어떤 자원이 연결되어 있는지 추적할 수 있습니다.
`ib_uverbs` 모듈은 IDR 테이블로 커널 포인터와 불투명한 사용자 공간 핸들을 변환합니다. 커널 포인터는 사용자 공간에 노출되지 않으며, 사용자 공간이 가짜 포인터를 제공해 커널이 잘못된 주소를 따라가게 만들 수도 없습니다.
이 소유권 모델 덕분에 프로세스가 종료될 때 커널이 해당 자원을 정리할 수 있고, 한 프로세스가 다른 프로세스의 자원에 접근하는 것도 방지할 수 있습니다.
파일 컨텍스트와 IDR이 제공하는 보호 속성입니다.
사용자 핸들이 검증된 커널 객체로 변환되는 경로입니다.
Since creation and destruction of all IB resources is done by
commands passed through a file descriptor, the kernel can keep track
of which resources are attached to a given userspace context. The
ib_uverbs module maintains idr tables that are used to translate
between kernel pointers and opaque userspace handles, so that kernel
pointers are never exposed to userspace and userspace cannot trick
the kernel into following a bogus pointer.
This also allows the kernel to clean up when a process exits and
prevent one process from touching another process's resources.
Memory pinning
직접 I/O 메모리 고정과 한도 회계
48-61사용자 공간 직접 I/O에서는 잠재적인 I/O 대상 메모리 영역이 같은 물리 주소에 상주해야 합니다. `ib_uverbs`는 `get_user_pages()`와 `put_page()` 호출로 메모리 영역을 고정하고 해제합니다.
모듈은 프로세스의 `pinned_vm`에 고정한 메모리 양을 회계하고, 권한 없는 프로세스가 `RLIMIT_MEMLOCK` 한도를 넘지 않는지 검사합니다.
한 페이지를 여러 번 고정하면 고정할 때마다 각각 계산됩니다. 따라서 `pinned_vm` 값은 프로세스가 실제로 고정한 서로 다른 페이지 수보다 클 수 있습니다.
고정·해제 API와 사용자별 한도 및 중복 계산 규칙입니다.
메모리 영역을 고정하고 한도를 검사한 뒤 해제하는 흐름입니다.
==============
Direct userspace I/O requires that memory regions that are potential
I/O targets be kept resident at the same physical address. The
ib_uverbs module manages pinning and unpinning memory regions via
get_user_pages() and put_page() calls. It also accounts for the
amount of memory pinned in the process's pinned_vm, and checks that
unprivileged processes do not exceed their RLIMIT_MEMLOCK limit.
Pages that are pinned multiple times are counted each time they are
pinned, so the value of pinned_vm may be an overestimate of the
number of pages pinned by a process.
/dev files
uverbs 장치 노드와 udev 권한
62-75적절한 문자 장치 파일을 udev로 자동 생성하려면 `uverbs*` 커널 장치 이름을 `infiniband/%k`에 배치하는 규칙을 사용할 수 있습니다.
KERNEL=="uverbs*", NAME="infiniband/%k"
이 규칙은 첫 장치에 `/dev/infiniband/uverbs0` 노드를 만들고 이후 장치도 같은 방식으로 번호를 붙입니다.
InfiniBand 사용자 공간 verbs는 비특권 프로세스가 사용해도 안전하도록 설계되었으므로, udev 규칙에 적절한 `MODE` 또는 `GROUP`을 추가해 접근을 허용하는 것이 유용할 수 있습니다.
장치 매칭, 생성 경로, 비특권 접근 제어 항목입니다.
커널 장치 이벤트가 접근 가능한 문자 장치로 연결되는 과정입니다.
==========
To create the appropriate character device files automatically with
udev, a rule like::
KERNEL=="uverbs*", NAME="infiniband/%k"
can be used. This will create device nodes named::
/dev/infiniband/uverbs0
and so on. Since the InfiniBand userspace verbs should be safe for
use by non-privileged processes, it may be useful to add an
appropriate MODE or GROUP to the udev rule.
요약·해설
user_verbs.rst:1-75Userspace verbs는 `libibverbs`의 장치 독립 API와 `ib_uverbs` 커널 인터페이스를 연결합니다. 자원 관리는 `uverbsN` 문자 장치의 느린 경로로 수행하고 데이터 경로는 `mmap()`된 레지스터를 직접 사용합니다. 커널은 파일 컨텍스트와 IDR 핸들로 자원을 격리하고, 직접 I/O 메모리는 `pinned_vm`과 `RLIMIT_MEMLOCK`으로 회계합니다.
원문 분량과 핵심 사용자·커널 경계를 요약합니다.
라이브러리 호출부터 자원·데이터 경로와 정리까지의 순서입니다.