← Documents Documentation/infiniband/user_verbs.rst GitHub 원문 ↗

Linux 6.18.37 · InfiniBand

Userspace verbs access

ib_uverbs와 libibverbs의 계층, 느린·빠른 경로, IDR 핸들, 메모리 고정과 udev 권한을 설명합니다.

Source pathDocumentation/infiniband/user_verbs.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

user_verbs.rst:1-75

Userspace verbs는 `libibverbs`의 장치 독립 API와 `ib_uverbs` 커널 인터페이스를 연결합니다. 자원 관리는 `uverbsN` 문자 장치의 느린 경로로 수행하고 데이터 경로는 `mmap()`된 레지스터를 직접 사용합니다. 커널은 파일 컨텍스트와 IDR 핸들로 자원을 격리하고, 직접 I/O 메모리는 `pinned_vm`과 `RLIMIT_MEMLOCK`으로 회계합니다.

문서 개요
항목내용
SourceDocumentation/infiniband/user_verbs.rst
분량75 source lines
공통 API`libibverbs`
커널 인터페이스`ib_uverbs`, `/dev/infiniband/uverbsN`
자원 보호File context, IDR opaque handle
메모리 회계`pinned_vm`, `RLIMIT_MEMLOCK`

원문 분량과 핵심 사용자·커널 경계를 요약합니다.

Userspace verbs 핵심 흐름
애플리케이션이 `libibverbs` API 호출느린 경로는 `uverbsN`의 `write()`로 자원 관리IDR이 사용자 핸들을 커널 객체로 안전하게 변환빠른 경로는 `mmap()` 레지스터로 직접 접근I/O 메모리는 페이지 고정과 한도 회계프로세스 종료 시 컨텍스트 소유 자원 정리

라이브러리 호출부터 자원·데이터 경로와 정리까지의 순서입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ======================
2 Userspace verbs access
3 ======================
4
5 The ib_uverbs module, built by enabling CONFIG_INFINIBAND_USER_VERBS,
6 enables direct userspace access to IB hardware via "verbs," as
7 described in chapter 11 of the InfiniBand Architecture Specification.
8
9 To use the verbs, the libibverbs library, available from
10 https://github.com/linux-rdma/rdma-core, is required. libibverbs contains a
11 device-independent API for using the ib_uverbs interface.
12 libibverbs also requires appropriate device-dependent kernel and
13 userspace driver for your InfiniBand hardware. For example, to use
14 a Mellanox HCA, you will need the ib_mthca kernel module and the
15 libmthca userspace driver be installed.
16
17 User-kernel communication
18 =========================
19
20 Userspace communicates with the kernel for slow path, resource
21 management operations via the /dev/infiniband/uverbsN character
22 devices. Fast path operations are typically performed by writing
23 directly to hardware registers mmap()ed into userspace, with no
24 system call or context switch into the kernel.
25
26 Commands are sent to the kernel via write()s on these device files.
27 The ABI is defined in drivers/infiniband/include/ib_user_verbs.h.
28 The structs for commands that require a response from the kernel
29 contain a 64-bit field used to pass a pointer to an output buffer.
30 Status is returned to userspace as the return value of the write()
31 system call.
32
33 Resource management
34 ===================
35
36 Since creation and destruction of all IB resources is done by
37 commands passed through a file descriptor, the kernel can keep track
38 of which resources are attached to a given userspace context. The
39 ib_uverbs module maintains idr tables that are used to translate
40 between kernel pointers and opaque userspace handles, so that kernel
41 pointers are never exposed to userspace and userspace cannot trick
42 the kernel into following a bogus pointer.
43
44 This also allows the kernel to clean up when a process exits and
45 prevent one process from touching another process's resources.
46
47 Memory pinning
48 ==============
49
50 Direct userspace I/O requires that memory regions that are potential
51 I/O targets be kept resident at the same physical address. The
52 ib_uverbs module manages pinning and unpinning memory regions via
53 get_user_pages() and put_page() calls. It also accounts for the
54 amount of memory pinned in the process's pinned_vm, and checks that
55 unprivileged processes do not exceed their RLIMIT_MEMLOCK limit.
56
57 Pages that are pinned multiple times are counted each time they are
58 pinned, so the value of pinned_vm may be an overestimate of the
59 number of pages pinned by a process.
60
61 /dev files
62 ==========
63
64 To create the appropriate character device files automatically with
65 udev, a rule like::
66
67 KERNEL=="uverbs*", NAME="infiniband/%k"
68
69 can be used. This will create device nodes named::
70
71 /dev/infiniband/uverbs0
72
73 and so on. Since the InfiniBand userspace verbs should be safe for
74 use by non-privileged processes, it may be useful to add an
75 appropriate MODE or GROUP to the udev rule.
76

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` 사용자 공간 드라이버를 설치해야 합니다.

Userspace verbs 소프트웨어 계층
계층구성 요소역할
커널 공통`ib_uverbs`사용자 공간 verbs 접근 제공
사용자 공통`libibverbs`장치 독립 API 제공
커널 장치 의존예: `ib_mthca`특정 HCA 제어
사용자 장치 의존예: `libmthca`특정 HCA 사용자 공간 지원
빌드 옵션`CONFIG_INFINIBAND_USER_VERBS``ib_uverbs` 활성화

장치 독립 API부터 하드웨어 의존 드라이버까지 필요한 구성 요소입니다.

Verbs 사용 준비
`CONFIG_INFINIBAND_USER_VERBS`로 커널 구성`ib_uverbs` 모듈과 HCA 커널 드라이버 준비`rdma-core`의 `libibverbs` 설치필요한 장치 의존 사용자 공간 드라이버 설치애플리케이션이 `libibverbs` 장치 독립 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()` 시스템 호출의 반환값으로 사용자 공간에 돌아옵니다.

Verbs 느린 경로와 빠른 경로
항목느린 경로빠른 경로
주요 목적자원 생성·삭제·관리데이터 경로 하드웨어 연산
접근`/dev/infiniband/uverbsN`에 `write()``mmap()`된 하드웨어 레지스터에 직접 기록
시스템 호출필요일반적으로 불필요
커널 컨텍스트 전환필요일반적으로 없음
상태 전달`write()` 반환값하드웨어별 완료 경로

커널 개입, 접근 방식, 대표 목적을 비교합니다.

느린 경로 명령·응답
애플리케이션이 명령 구조체 구성응답이 필요하면 64비트 필드에 출력 버퍼 포인터 설정`uverbsN` 장치에 `write()` 호출커널이 자원 관리 명령 처리출력 버퍼에 응답 기록`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 테이블로 커널 포인터와 불투명한 사용자 공간 핸들을 변환합니다. 커널 포인터는 사용자 공간에 노출되지 않으며, 사용자 공간이 가짜 포인터를 제공해 커널이 잘못된 주소를 따라가게 만들 수도 없습니다.

이 소유권 모델 덕분에 프로세스가 종료될 때 커널이 해당 자원을 정리할 수 있고, 한 프로세스가 다른 프로세스의 자원에 접근하는 것도 방지할 수 있습니다.

IB 자원 핸들 격리
구성효과
파일 디스크립터 컨텍스트사용자 공간 컨텍스트별 자원 소유권 추적
IDR table커널 포인터와 불투명 핸들 사이 변환
Opaque userspace handle실제 커널 주소 비공개
프로세스 종료연결된 IB 자원 자동 정리
프로세스 격리다른 컨텍스트의 자원 접근 방지

파일 컨텍스트와 IDR이 제공하는 보호 속성입니다.

IDR 기반 자원 접근
파일 컨텍스트에서 IB 자원 생성커널 객체 포인터를 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` 값은 프로세스가 실제로 고정한 서로 다른 페이지 수보다 클 수 있습니다.

Verbs 메모리 고정 회계
항목동작
페이지 고정`get_user_pages()`
페이지 해제`put_page()`
프로세스 회계`pinned_vm`
비특권 한도`RLIMIT_MEMLOCK`
중복 고정고정 횟수마다 별도 계산
회계 특성`pinned_vm`이 고유 페이지 수를 과대평가할 수 있음

고정·해제 API와 사용자별 한도 및 중복 계산 규칙입니다.

직접 I/O 메모리 등록
I/O 대상 사용자 메모리 영역 선택`get_user_pages()`로 물리 페이지 고정고정량을 `pinned_vm`에 더함비특권 프로세스의 `RLIMIT_MEMLOCK` 확인직접 하드웨어 I/O 수행등록 해제 시 `put_page()`와 회계 감소

메모리 영역을 고정하고 한도를 검사한 뒤 해제하는 흐름입니다.

==============

  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`을 추가해 접근을 허용하는 것이 유용할 수 있습니다.

uverbs udev 설정
항목
Kernel match`KERNEL=="uverbs*"`
Node template`NAME="infiniband/%k"`
첫 장치 노드`/dev/infiniband/uverbs0`
권한 제어적절한 `MODE` 또는 `GROUP`
대상 사용자비특권 verbs 프로세스

장치 매칭, 생성 경로, 비특권 접근 제어 항목입니다.

uverbs 장치 노드 생성
커널이 `uverbsN` 장치 등록udev가 `KERNEL=="uverbs*"` 규칙과 매칭`/dev/infiniband/uverbsN` 노드 생성`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.