IO-Polling code analysis

Source: Internet
Author: User

IO-Polling code analysis

In the previous article "IO-Polling implementation analysis and performance evaluation", I/O-Polling differs from interrupt principles, the performance test of NVMe SSD in two modes is used to compare the two modes. This article will go deep into the I/O-Polling code and interpret this IO processing mode.

I/O-Polling mode has been added to the linux 4.4 kernel, and multiple member groups have been added to test the performance impact of I/O-Polling on fast devices. Currently, IO-Polling only supports direct-IO sync Mode read/write operations. Later, I/O-Polling for libaio will be added. For details, see git log information.


IO-Polling code analysis

Based on Linux kernel version 4.4, this article provides a brief analysis of the changes to the kernel block device layer, file system, and underlying NVMe driver in IO-Polling mode. I/O-Polling of Linux kernel 4.4 is used to modify 33 files. For detailed modification list, see: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20160331/20160331090346290.png" alt = "\">

Blk-poll functions are mainly added to block/blk-core.c to support the polling mode. In the blk-poll function, if the underlying driver does not support mq or mq does not support the polling mode, the upper layer is returned and the interruption mode is used. If the underlying driver supports the mq polling mode, the underlying driver's poll function is called for IO processing. For more information about the function, see.

Added support for io-poll parameters in sys file systems in block/blk-mq-sysfs.c and block/blk-sysfs.c files


In the block/blk-mq.c file, modifying each function adds processing for the poll logic.



In addition to the above changes to the general block device layer, each IO Device must support the polling mode and must partially modify its own devices. Take the NVMe device as an example. The nvme_poll function is added to the NVMe driver source code. when the registration is mounted to the block layer and the upper layer accesses the NVMe device in polling mode, the driver calls the nvme_poll function, instead of using the interrupt mode. The NVMe driver code is modified as follows:


In the file system layer fs/direct-io.c, the direct-io function has been modified to support polling. In actual testing, polling only works in direct_io. In buffer_io mode, i/O mode still adopts the interrupt mode. In the previous article, only the raw device's polling mode performance data is provided. The file system's polling mode will be analyzed in detail later.

Conclusion

Although most of the Upper-layer application services are asynchronous, IO-Polling brings a great benefit to latency when it is based on synchronous I/O and sensitive to a small part of key services. At the same time, the Linux kernel is constantly evolving, and the asynchronous mode Polling will also be added. With the development of high-speed storage devices, IO-Polling will play a greater role in latency-sensitive businesses.

The author Luna is a memblze product engineer. His main research interests include KVM, Virtio and other Virtualization Technologies. He is best at optimizing PCIe SSD in KVM virtualization scenarios. A previous article titled Virtio-blk-data-plane for QEMU-KVM I/O performance optimization in Luna analyzes in detail the technical principles of Virtio-blk-data-plane, the test demonstrates its performance advantages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.