Documentation
¶
Overview ¶
Package nvproxy implements proxying for the Nvidia GPU Linux kernel driver: https://github.com/NVIDIA/open-gpu-kernel-modules.
Supported Nvidia GPUs: T4, L4, A100, A10G and H100.
Lock ordering:
- nvproxy.fdsMu - rootClient.objsMu
- nvproxy.clientsMu
Index ¶
- Constants
- func AnyFrontendDevicesOpen(vfsObj *vfs.VirtualFilesystem) bool
- func CheckDevicesRemappable(ids []DeviceRemapID) error
- func FillDeviceRemapIDsFromMinor(ctx context.Context, ctlDevClient *devutil.GoferClient, ids []DeviceRemapID) error
- func Filters(enabledCaps nvconf.DriverCaps) seccomp.SyscallRules
- func ForEachSupportDriver(f func(version nvconf.DriverVersion, checksums Checksums))
- func HostDriverVersion() (string, error)
- func Init()
- func LatestDriver() nvconf.DriverVersion
- func SupportedDrivers() []nvconf.DriverVersion
- func SupportedIoctlsNumbers(version nvconf.DriverVersion) (frontendIoctls map[uint32]struct{}, uvmIoctls map[uint32]struct{}, ...)
- type Checksums
- type DeviceInfo
- type DeviceRemapID
- type DeviceRemapping
- type DriverABIInfo
- type DriverStruct
- type DriverStructName
- type IoctlInfo
- type IoctlName
- type NvidiaDeviceFD
- type Options
- type ProcfsInfo
Constants ¶
const ( // ChecksumNoDriver is a special value that indicates that the driver runfile // does not exist. This is mostly for ARM drivers that NVIDIA does not // provide a driver installer. ChecksumNoDriver = "NO_DRIVER" )
const ( // CtxDeviceRemapping is a Context.Value key for a DeviceRemapping. CtxDeviceRemapping saveRestoreGoogleContextID = iota )
Variables ¶
This section is empty.
Functions ¶
func AnyFrontendDevicesOpen ¶
func AnyFrontendDevicesOpen(vfsObj *vfs.VirtualFilesystem) bool
AnyFrontendDevicesOpen returns true if at least one "frontend device" (/dev/nvidia# or /dev/nvidiactl) has at least one open file descriptor.
func CheckDevicesRemappable ¶
func CheckDevicesRemappable(ids []DeviceRemapID) error
CheckDevicesRemappable checks that the set of devices in ids can be saved.
func FillDeviceRemapIDsFromMinor ¶
func FillDeviceRemapIDsFromMinor(ctx context.Context, ctlDevClient *devutil.GoferClient, ids []DeviceRemapID) error
FillDeviceRemapIDsFromMinor fills all DeviceRemapID fields in ids based on DeviceRemapID.Minor and DeviceRemapID.DevGoferClient.
func Filters ¶
func Filters(enabledCaps nvconf.DriverCaps) seccomp.SyscallRules
Filters returns seccomp-bpf filters for this package when using the given set of capabilities.
func ForEachSupportDriver ¶
func ForEachSupportDriver(f func(version nvconf.DriverVersion, checksums Checksums))
ForEachSupportDriver calls f on all supported drivers. Precondition: Init() must have been called.
func HostDriverVersion ¶
HostDriverVersion returns the version of the host Nvidia driver.
func LatestDriver ¶
func LatestDriver() nvconf.DriverVersion
LatestDriver returns the latest supported driver. Precondition: Init() must have been called.
func SupportedDrivers ¶
func SupportedDrivers() []nvconf.DriverVersion
SupportedDrivers returns a list of all supported drivers. Precondition: Init() must have been called.
func SupportedIoctlsNumbers ¶
func SupportedIoctlsNumbers(version nvconf.DriverVersion) (frontendIoctls map[uint32]struct{}, uvmIoctls map[uint32]struct{}, controlCmds map[uint32]struct{}, allocClasses map[uint32]struct{}, ok bool)
SupportedIoctlsNumbers returns the ioctl numbers that are supported by nvproxy at a given version.
Types ¶
type Checksums ¶
Checksums is a struct containing the SHA256 checksum of the linux .run driver installer file from NVIDIA.
func ExpectedDriverChecksum ¶
func ExpectedDriverChecksum(version nvconf.DriverVersion) (Checksums, bool)
ExpectedDriverChecksum returns the expected checksum for a given version. Precondition: Init() must have been called.
func NewChecksums ¶
NewChecksums creates a new Checksums struct.
type DeviceInfo ¶
type DeviceInfo struct {
// CapsDevMajor is nvidia-caps' device major number. If CapsDevMajor is 0,
// nvidia-caps is not enabled.
CapsDevMajor uint32
// If HaveFabricIMEXManagement is true, FabricIMEXManagementDevMinor is the
// fabric-imex-mgmt capability's device minor number, which matches the
// value on the host. (Its device major number is CapsDevMajor, which must
// be non-zero and might not match the host's value.)
HaveFabricIMEXManagement bool
FabricIMEXManagementDevMinor uint32
// CapsIMEXChannelsDevMajor is nvidia-caps-imex-channels's device major
// number. If CapsIMEXChannelsDevMajor is 0, nvidia-caps-imex-channels is
// not enabled.
CapsIMEXChannelsDevMajor uint32
// UVMDevMajor is nvidia-uvm's device major number. If UVMDevMajor is 0,
// nvidia-uvm is enabled.
UVMDevMajor uint32
}
DeviceInfo contains information on registered nvproxy devices.
+stateify savable
func DeviceInfoFromVFS ¶
func DeviceInfoFromVFS(vfsObj *vfs.VirtualFilesystem) *DeviceInfo
DeviceInfoFromVFS returns device information for nvproxy devices registered in vfsObj. The returned DeviceInfo must not be mutated. If DeviceInfoFromVFS returns nil, nvproxy.Register(vfsObj) has not been called.
func Register ¶
func Register(vfsObj *vfs.VirtualFilesystem, opts *Options) (*DeviceInfo, error)
Register registers all devices implemented by this package, and specified by opts, in vfsObj. If it succeeds, it returns information about registered devices; the returned DeviceInfo must not be mutated.
type DeviceRemapID ¶
type DeviceRemapID struct {
// Minor is the minor device number. This is assigned by
// kernel-open/nvidia/nv-pci.c:nv_pci_probe() =>
// kernel-open/nvidia/nv.c:nv_linux_add_device_locked().
Minor uint32 `json:"minor"`
// PCIVendorID and PCIDeviceID are PCI vendor and device IDs respectively.
// These are properties of the underlying hardware.
PCIVendorID uint16 `json:"pci_vendor_id"`
PCIDeviceID uint16 `json:"pci_device_id"`
// GPUID is nv_state_t::gpu_id. This is generated by
// src/nvidia/arch/nvalloc/unix/src/osinit.c:RmInitPrivateState() =>
// nv_generate_id_from_pci_info().
GPUID uint32 `json:"gpu_id"`
// DeviceInstance is the "broadcast device instance number", or
// equivalently the value of NV0080_ALLOC_PARAMETERS::deviceId, or
// equivalently the index of this device in OBJGPUMGR::pGpuGrpTable. This
// is assigned by
// src/nvidia/src/kernel/gpu_mgr/gpu_mgr.c:gpumgrCreateDevice() =>
// gpumgrAllocDeviceInstance().
DeviceInstance uint32 `json:"device_instance"`
// SubDeviceInstance is the "unicast subdevice instance number", or
// equivalently the value of NV2080_ALLOC_PARAMETERS::subDeviceId, or
// equivalently the value of OBJGPU::subdeviceInstance. This is set by an
// invocation of NV2080_CTRL_CMD_GPU_SET_SDM.
SubDeviceInstance uint32 `json:"subdevice_instance"`
// UUID is the "UUID", including the "GPU-" prefix, as printed by
// `nvidia-smi -L`. This is provided by the GSP, and retrieved and
// stringified by src/nvidia/src/kernel/gpu/gpu.c:gpuGetGidInfo_IMPL().
UUID string `json:"uuid"`
// If DevGoferClient is not nil, it provides access to the represented
// device.
DevGoferClient *devutil.GoferClient `json:"-"`
}
DeviceRemapID identifies a device for remapping across save/restore.
func (*DeviceRemapID) String ¶
func (id *DeviceRemapID) String() string
String implements fmt.Stringer.String.
type DeviceRemapping ¶
type DeviceRemapping struct {
// XByY maps Y to X.
NewDeviceByOld map[*DeviceRemapID]*DeviceRemapID
OldDeviceByMinor map[uint32]*DeviceRemapID
OldDeviceByDeviceInstance map[uint32]*DeviceRemapID
}
DeviceRemapping specifies the remapping from a set of saved devices to a set of devices available during restore.
func DeviceRemappingFromContext ¶
func DeviceRemappingFromContext(ctx goContext.Context) *DeviceRemapping
DeviceRemappingFromContext returns the DeviceRemapping associated with ctx, or nil if no such DeviceRemapping exists.
func MakeDeviceRemapping ¶
func MakeDeviceRemapping(oldIDs, newIDs []DeviceRemapID) (*DeviceRemapping, error)
MakeDeviceRemapping produces a DeviceRemapping. It takes ownership of oldIDs and newIDs.
Preconditions: CheckDevicesRemappable(oldIDs) == nil.
type DriverABIInfo ¶
type DriverABIInfo struct {
FrontendInfos map[uint32]IoctlInfo
UvmInfos map[uint32]IoctlInfo
ControlInfos map[uint32]IoctlInfo
AllocationInfos map[nvgpu.ClassID]IoctlInfo
}
DriverABIInfo defines all the structs and ioctls used by a driverABI. This is used to help with verifying and supporting new driver versions. This helps keep track of all the driver structs and ioctls that we currently support. We do so by mapping ioctl numbers to its name in the driver and a list of DriverStructs used by that ioctl.
func SupportedIoctls ¶
func SupportedIoctls(version nvconf.DriverVersion) (*DriverABIInfo, bool)
SupportedIoctls returns the DriverABIInfo struct for the given version, which describes the ioctls supported in nvproxy for the given version.
type DriverStruct ¶
type DriverStruct struct {
Name DriverStructName
Type reflect.Type
}
DriverStruct ties an nvproxy struct type to its corresponding driver struct name.
type DriverStructName ¶
type DriverStructName = string
DriverStructName is the name of a struct used by the Nvidia driver.
type IoctlInfo ¶
type IoctlInfo struct {
Name IoctlName
Structs []DriverStruct
}
IoctlInfo contains information about an ioctl defined by the Nvidia driver.
type IoctlName ¶
type IoctlName = string
IoctlName is the name of the constant used by the Nvidia driver to define the ioctl number/control command/allocation class.
type NvidiaDeviceFD ¶
type NvidiaDeviceFD interface {
IsNvidiaDeviceFD()
}
NvidiaDeviceFD is an interface that should be implemented by all vfs.FileDescriptionImpl of Nvidia devices.
type Options ¶
type Options struct {
// DriverVersion is the Nvidia GPU driver version.
DriverVersion nvconf.DriverVersion
// AllowUnsupportedDriver allows nvproxy to be initialized with an
// unsupported driver version.
AllowUnsupportedDriver bool
// DriverCaps is the set of driver capabilities exposed to applications.
DriverCaps nvconf.DriverCaps
HostSettings *nvconf.HostSettings
// If UseDevGofer is true, open device files via gofer.
UseDevGofer bool
}
Options holds arguments to Register.
type ProcfsInfo ¶
type ProcfsInfo struct {
// StaticFiles maps paths relative to /proc/driver/nvidia/ to the contents of
// files at those paths.
StaticFiles map[string]string
}
ProcfsInfo contains information about procfs files maintained by nvproxy.
func ProcfsInfoFromVFS ¶
func ProcfsInfoFromVFS(vfsObj *vfs.VirtualFilesystem) *ProcfsInfo
ProcfsInfoFromVFS returns procfs information for nvproxy devices registered in vfsObj. If ProcfsInfoFromVFS returns nil, nvproxy.Register(vfsObj) has not been called.