Introduction to Linux kernel engineering-UIO
To enable the hugepages file system, the file system uses mmap to map pages, which can significantly reduce page disconnection.
UIO Introduction
UIO is a kernel-driven mechanism on the user side. It has a module in the kernel that supports the uio module. Currently, this module only supports character devices. You can add multiple uio devices (device drivers at the user end). Each device is in/dev/uioX, X is a number, the first is 0, and so on. We know that all devices respond by means of interruptions. The method to respond to uio device interruptions is to read the/dev/uioX file, and reading will be blocked when there is no interruption, when it is interrupted, the integer is read, which indicates the number of interruptions that have occurred.
However, this is only the general situation. Some devices have multiple interruptions, while others have not. In these cases, uio also implements the corresponding mechanism, but the implementation is not perfect. For multiple interruptions, the/dev/uioX write () system call can enable or disable the Interrupt Processing of the kernel, so that the driver can manually handle the interruption. Without interruption, uio provides a timer interface, which can manually interrupt the device at regular intervals.
For UIO User-Defined drivers, similar to kernel drivers, there are usually some global variables that need to be accessed through the sys File System. Uio does not support calling sysctl to change these values, but you can find these corresponding files in the sys File System to modify them:/sys/class/uio/uioX
Each uio device has three defined attributes: name, version, and event, and a maps folder (which exists only when memory ing exists). Others are the uevent model that comes with the sys File System. Name indicates the name of The UIO device. version indicates the version of the current uio kernel module. The value of event is the same as that obtained by the read () device, which is the number of times that the device has been interrupted. The maps folder serves hardware data processing. Most hardware requires memory operations. If the UIO user driver needs to map the device memory to the user end, it needs to be called by the mmap system, each time a system call is used, a map [digital] Directory is generated under the maps Directory, which contains four fixed files to describe the information of the mapped memory:
Here, addr is the base address of the ing, offset is the offset, name is the name mapped to the ing, and size is the size of the mapped memory. If the memory cannot be mapped, you can also use the x86 port operating system to call ioperm (), iopl (), inb (), and outb () to read and write a hardware port. In this case, the uio module also adds the/sys/class/uio/uioX/portio/directory. below is the file ing of each module, this allows you to directly change the configuration by operating on the port.
UIO is easy to write driver in user space, so it provides good support for FPGA. Even the mechanism of exporting kernel data packets to user space such as dpdk also uses UIO. Open Source Automation Development Lab and other organizations that use robot programming also like UIO.
IOMMU
IOMMU is designed for virtualization. If the driver is in the user State (such as a virtual machine), there is no efficient method to use the device I/O memory, the kernel needs to perform extra conversion from the user memory space to the device memory space. IOMMU can directly map the device memory space to the user process space. You can directly arrange its hardware operations.
VFIO
This is the software's support for brute-force Memory leakage from hardware devices in the user space. The DMA memory is directly mapped to the user's process space. To use this driver, you need to unbind the device from the original driver of the operating system. Currently, only the vfio-pci module is supported to support PCI ing of pci devices. This is of great significance for virtual machines and user space device drivers.