summaryrefslogtreecommitdiffstats
path: root/docs/tools/rmtool.md
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-14 06:43:11 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-14 06:43:11 -0400
commit5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60 (patch)
tree7523e29d8044d4d5b6dcd7c1c888a3491137fcd1 /docs/tools/rmtool.md
parent9a7263fce4e3156349a526631805fce66b87fb1b (diff)
downloadopen-iov-5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60.tar.gz
open-iov-5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60.zip
VFIO device registration fix + IOMMUFD callbacks + VFIO ioctl handlers
- Removed IOMMU group addition before vfio_register_emulated_iommu_dev() in nv_vgpu_mdev_create() - Added IOMMUFD callbacks (bind_iommufd, unbind_iommufd, attach_ioas, detach_ioas) using kernel's vfio_iommufd_emulated_* functions - Implemented VFIO ioctl handlers: GET_INFO, GET_REGION_INFO, GET_IRQ_INFO, SET_IRQS, MMAP - Added config space read/write handlers at offset 0x70000000000 - Mmap handler for config space, BAR0 (emulation shadow), BAR1-5 (physical VRAM/registers) - Interrupt handler for VFIO_DEVICE_SET_IRQS (DATA_EVENTFD, DATA_NONE, DATA_BOOL) - Added udev rules for vfio group permissions - Created stack_manager.sh unified tool - Fixed mdev remove crash with deferred cleanup in vfio_device_release callback - Kernel 6.8+ IOMMUFD compatibility - QEMU launches successfully with vGPU passthrough
Diffstat (limited to 'docs/tools/rmtool.md')
-rw-r--r--docs/tools/rmtool.md149
1 files changed, 149 insertions, 0 deletions
diff --git a/docs/tools/rmtool.md b/docs/tools/rmtool.md
new file mode 100644
index 0000000..e15306b
--- /dev/null
+++ b/docs/tools/rmtool.md
@@ -0,0 +1,149 @@
+# rmtool - RM API Swiss Army Knife
+
+## Overview
+`rmtool` is a comprehensive userspace utility for interacting with the NVIDIA Resource Manager (RM) API. It provides direct access to RM internal state, engine control, memory management, and performance telemetry. Built by recycling existing code from the NVIDIA driver stack (`integ/gpu_drv/ext-tree/`).
+
+## Source Code Reuse
+| Component | Source Location | Purpose |
+|-----------|-----------------|---------|
+| nvidia-smi core | `ext-tree/drivers/gpgpu/nvidia-smi/` | CLI framework, NV2080 ioctls, GPU enumeration |
+| gpumon/perfmon | `ext-tree/drivers/gpgpu/gpumon_perfmon/` | Performance monitoring, sampling infrastructure |
+| NV2080 controls | `ext-tree/drivers/gpgpu/nv2080/` | RM control interfaces (classes, methods, events) |
+| Resource Server | `ext-tree/drivers/gpgpu/resserve/` | Resource Server (resserve) API |
+| CUDA Internal | `ext-tree/drivers/gpgpu/cudasw/` | CUDASW / CUDA Internal Layer |
+| Resource Manager | `ext-tree/drivers/gpgpu/resman/` | Resman API |
+
+## Core Commands
+
+### GPU Enumeration & Topology
+```bash
+rmtool gpu list # List all GPUs with PCI info
+rmtool gpu topology # Show GPU topology (NVLink, PCIe, PCI IDs)
+rmtool gpu info -d 0000:65:00.0 # Detailed GPU info (like nvidia-smi -q)
+```
+
+### Engine Management
+```bash
+rmtool engine list # List all engines (GR, CE, NVDEC, NVENC, NVJPG, OFA)
+rmtool engine info -d 0 -e gr # Engine details (registers, capabilities)
+rmtool engine allocate -d 0 -e gr -c 4 # Allocate 4 GR channels
+rmtool engine start -d 0 -e gr -c 0 # Start engine channel
+rmtool engine stop -d 0 -e gr -c 0 # Stop engine channel
+rmtool engine config -d 0 -e nvenc --preset=h264 --bitrate=10M
+```
+
+### Channel & Context Control
+```bash
+rmtool channel list -d 0 # List all channels on GPU
+rmtool channel create -d 0 -e gr -t compute # Create compute channel
+rmtool channel submit -d 0 -c 0 --pushbuf=work.bin # Submit work
+rmtool channel status -d 0 -c 0 # Channel status (busy, pending, error)
+rmtool context list -d 0 # List all contexts
+rmtool context info -d 0 -c 0 # Context details (page tables, memory)
+```
+
+### Memory Operations
+```bash
+rmtool mem alloc -d 0 --size=1G --type=video # Allocate VRAM
+rmtool mem alloc -d 0 --size=512M --type=system # Allocate sysmem
+rmtool mem map -d 0 -h 0x1234 --gpu-va=0x100000 # Map to GPU VA
+rmtool mem unmap -d 0 -h 0x1234 # Unmap
+rmtool mem pin -d 0 -h 0x1234 # Pin for DMA
+rmtool mem info -d 0 -h 0x1234 # Allocation details
+rmtool mem stats -d 0 # VRAM/sysmem usage breakdown
+```
+
+### Performance Sampling
+```bash
+rmtool sample engine -d 0 -e gr --interval=100ms --count=100
+rmtool sample clocks -d 0 --interval=1s
+rmtool sample power -d 0 --interval=1s
+rmtool sample thermal -d 0 --interval=1s
+rmtool sample pcie -d 0 --interval=1s
+```
+
+### NV2080 Direct Control
+```bash
+rmtool nv2080 class list -d 0 # List all NV2080 classes
+rmtool nv2080 method call -d 0 -c 0x906D -m 0x100 --params=...
+rmtool nv2080 event subscribe -d 0 -c 0x906D -e 0x100
+rmtool nv2080 event wait -d 0 -c 0x906D -e 0x100 --timeout=5000
+```
+
+### Resource Server (resserve) Integration
+```bash
+rmtool resserve status # Resource Server status
+rmtool resserve reservation list # List all reservations
+rmtool resserve reservation create --gpu=0 --engine=gr --size=4
+rmtool resserve reservation release --id=123
+```
+
+### CUDA Internal Layer (CUDASW)
+```bash
+rmtool cudasw context list # CUDA contexts
+rmtool cudasw module list # Loaded CUDA modules
+rmtool cudasw stream list -c 0 # Streams in context
+rmtool cudasw event list -c 0 # Events in context
+```
+
+### Resource Manager (Resman)
+```bash
+rmtool resman client list # Resman clients
+rmtool resman resource list -c 0 # Resources owned by client
+rmtool resman heap info -d 0 # Heap state
+```
+
+### GSP-RM Telemetry
+```bash
+rmtool gsp rpc-stats -d 0 # RPC queue depths, latency
+rmtool gsp doorbell -d 0 # Doorbell rates
+rmtool gsp firmware -d 0 # Firmware version, threads
+rmtool gsp wpr -d 0 # WPR state
+```
+
+## Output Formats
+```bash
+rmtool gpu list --format=json
+rmtool engine list --format=csv
+rmtool sample engine --format=prometheus
+rmtool mem stats --format=influx
+```
+
+## Build
+```bash
+cd open-iov/tools/rmtool
+make
+# Links against: libnvidia-rmapi.so (from ext-tree), libpciaccess, libnuma
+```
+
+## Architecture
+```
+rmtool/
+├── src/
+│ ├── main.c # CLI parsing, command dispatch
+│ ├── gpu.c # GPU enumeration, topology
+│ ├── engine.c # Engine allocation/control
+│ ├── channel.c # Channel/context management
+│ ├── memory.c # Memory alloc/map/pin
+│ ├── sample.c # Performance sampling
+│ ├── nv2080.c # NV2080 direct control
+│ ├── resserve.c # Resource Server client
+│ ├── cudasw.c # CUDA Internal Layer
+│ ├── resman.c # Resource Manager
+│ ├── gsp.c # GSP-RM telemetry
+│ └── output.c # JSON/CSV/Prometheus formatters
+├── include/
+│ └── rmtool.h # Internal headers
+├── lib/
+│ ├── librmapi.a # Recycled RM API code
+│ └── libgpumon.a # Recycled perfmon code
+└── Makefile
+```
+
+## Future Extensions
+- **Remote gRPC/REST API** for fleet management
+- **Policy Engine** for automated engine allocation
+- **Migration Coordination** via resserve
+- **Telemetry Export** (Prometheus, OpenTelemetry, InfluxDB)
+- **Guest Introspection** via vGPU VFIO interface
+- **Workload Profiling** with CUDA/GR engine correlation \ No newline at end of file