Request processing method, related device and storage medium

By using a ring buffer in kernel mode to process multiple read and write requests from user-mode programs, the concurrent performance bottleneck of storage devices is resolved and a higher number of input/output operations per second is achieved.

CN119248192BActive Publication Date: 2025-09-19MAXIO TECHNOLOGY (HANGZHOU) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411336571.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-09-19
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

When a user-mode program sends a large number of data read and write requests to a storage device driver through multiple threads, the number of input/output operations per second of the storage device decreases, and a large number of data read and write requests are queued in the storage device driver waiting to be executed.

Method used

Multiple read and write requests from the user-mode program are stored in the first ring buffer, and the requests are sent to the controller for data read and write operations through the kernel-mode ring buffer pointer operation. The target read and write responses are stored in the second ring buffer, and the third ring buffer saves the context information. Finally, the responses are sent to the user-mode program and the buffer context information is cleared.

Benefits of technology

It reduces the contention and waiting time between multiple threads, improves the kernel-mode concurrency performance of storage devices, and thus increases the number of input/output operations per second.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248192B_ABST
    Figure CN119248192B_ABST
Patent Text Reader

Abstract

The present disclosure provides a request processing method, related device, and storage medium. The method includes: storing multiple read and write requests of a user-mode program to a storage device in a first ring buffer, the storage device including a controller and a memory, and executing a loop step: sending a target read and write request pointed to by a head pointer in the first ring buffer to the controller to implement data read and write operations on the memory, obtaining a target read and write response to the target read and write request, storing the target read and write response in a second ring buffer, storing context information of the target read and write request and the target read and write response in a third ring buffer, sending the target read and write response to a corresponding user-mode program based on the context information of the target read and write request and the target read and write response, shifting the head pointer down one position, and clearing the context information of the target read and write request and the target read and write response stored in the third ring buffer, thereby improving the number of input / output operations per second of the storage device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of storage technology, and particularly relates to a request processing method, related devices, and storage media. Background Art

[0002] A storage system typically includes a computer device and a storage device, which can expand the computer device's storage space. The computer device's operating system includes user mode and kernel mode, which are two different execution levels. User-mode programs can use multiple threads to issue data read and write requests to the storage device driver in kernel mode to perform data read and write operations on the storage device. However, if a user-mode program issues a large number of data read and write requests to the storage device driver through multiple threads, a large number of data read and write requests may be queued by the storage device driver, waiting to be executed. This obviously limits the number of input / output operations per second (IOPS) of the storage device. Summary of the Invention

[0003] In view of the above problems, the present disclosure provides a request processing method, related devices and storage media, aiming to reduce the competition and waiting time between multiple threads, improve the concurrency performance of the kernel state in the host of the storage device, and thereby increase the input / output operations per second of the storage device.

[0004] According to a first aspect of the present disclosure, a request processing method is provided, which is applied in kernel mode and includes:

[0005] storing multiple read and write requests of a user-mode program to a storage device in a first ring buffer, wherein the storage device includes a controller and a memory;

[0006] Executing a loop step: sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement a data read / write operation on the memory, and obtaining a target read / write response to the target read / write request;

[0007] storing the target read / write response in a second ring buffer, wherein context information of the target read / write request and the target read / write response is stored in a third ring buffer;

[0008] Based on the context information of the target read / write request and the target read / write response, sending the target read / write response to the corresponding user mode program;

[0009] The head pointer is moved down one position, and the context information of the target read / write request and the target read / write response stored in the third ring buffer is cleared.

[0010] Optionally, before storing the multiple read and write requests of the user mode program to the storage device in the first ring buffer, the request processing method further includes:

[0011] Instantiate the first ring buffer, the second ring buffer, and the third ring buffer respectively;

[0012] Pre-allocate storage space for the third ring buffer.

[0013] Optionally, storing the multiple read and write requests of the user-mode program to the storage device in the first ring buffer includes:

[0014] Receiving the multiple read and write requests through a system call interface channel between user mode and kernel mode;

[0015] storing the plurality of read and write requests in the first ring buffer;

[0016] Storing context information of the multiple read and write requests in the third ring buffer.

[0017] Optionally, the context information of the read / write request includes: a mapping of the logical address of the read / write request to a physical address,

[0018] The step of sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement the data read / write operation on the memory, and obtaining the target read / write response to the target read / write request includes:

[0019] Constructing a storage interface channel request based on the target read / write request and a mapping of the logical address of the target read / write request to the physical address, and sending the storage interface channel request to the controller;

[0020] The controller performs data read and write operations on the memory according to the storage interface channel request, and obtains a target read and write response to the target read and write request.

[0021] Optionally, storing the target read / write response in a second ring buffer includes:

[0022] Receiving, via a system call interface channel between a user state and a kernel state, a tracking command for tracking the execution status of the target read / write request;

[0023] storing the target read and write responses in the second ring buffer based on the tracking command;

[0024] The context information of the target read / write response is stored in the third ring buffer.

[0025] Optionally, the sending the target read / write response to the corresponding user mode program based on the context information of the target read / write request and the target read / write response includes:

[0026] Receiving a retrieval command for retrieving the target read / write response via a system call interface channel between a user state and a kernel state;

[0027] Based on the context information of the target read / write request, restore the original context in the user state and store the target read / write response in the user state;

[0028] Based on the context information of the target read / write response, the original context of the kernel state is restored, and the loop step is executed again.

[0029] Optionally, before storing the multiple read and write requests of the user mode program to the storage device in the first ring buffer, the request processing method further includes:

[0030] Initialize the storage device as a miscellaneous device structure dev device and register the storage device.

[0031] According to a second aspect of the present disclosure, a request processing device is provided, which is applied in kernel mode and includes:

[0032] a read / write request storage unit, configured to store a plurality of read / write requests of a user-mode program to a storage device in a first ring buffer, wherein the storage device includes a controller and a memory;

[0033] a target read / write request execution unit, configured to execute a loop step of sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement a data read / write operation on the memory and obtain a target read / write response to the target read / write request;

[0034] storing the target read / write response in a second ring buffer, wherein context information of the target read / write request and the target read / write response is stored in a third ring buffer;

[0035] Based on the context information of the target read / write request and the target read / write response, sending the target read / write response to the corresponding user mode program;

[0036] The head pointer is moved down by one position, and the context information of the target read / write request and the target read / write response stored in the third ring buffer is cleared.

[0037] According to a third aspect of the present disclosure, there is provided a storage system, including:

[0038] Storage devices, including controllers and memory;

[0039] A computer device includes the request processing device running in kernel mode as described above, which is used to store multiple read and write requests of the user mode program to the storage device in a first ring buffer, and send the target read and write request pointed to by the head pointer in the first ring buffer to the controller to implement data read and write operations on the memory, and obtain a target read and write response to the target read and write request.

[0040] According to a fourth aspect of the present disclosure, a storage medium is provided, on which a computer program or instructions are stored. When the computer program or instructions are executed by a processor, the steps of the method described above are implemented.

[0041] The present disclosure brings the following beneficial effects:

[0042] The request processing method provided by the present invention is applied to kernel mode, and the storage device includes a controller and a memory. Multiple read and write requests of the user mode program to the storage device are stored in a first ring buffer. Then, a loop step is executed: the target read and write request pointed to by the head pointer in the first ring buffer is sent to the controller to realize the data read and write operation of the memory, and the target read and write response of the target read and write request is obtained, and the target read and write response is stored in the second ring buffer, wherein the context information of the target read and write request and the target read and write response is stored in the third ring buffer, based on the context information of the target read and write request and the target read and write response, the target read and write response is sent to the corresponding user mode program, the head pointer is moved down by one position, and the context information of the target read and write request and the target read and write response stored in the third ring buffer is cleared. In this way, the pointer operation of the kernel mode ring buffer is used to realize the transmission and processing of multiple read and write requests of the user mode program to the storage device, thereby reducing the competition and waiting time between multiple threads, improving the concurrency performance of the kernel mode in the host of the storage device, and thereby improving the input / output operations per second of the storage device.

[0043] Other features and advantages of the present disclosure will be described in the following description, and in part will become apparent from the description, or understood by practicing the present disclosure. The objectives and other advantages of the present disclosure are realized and obtained by the structures particularly pointed out in the description and the drawings.

[0044] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0046] Figure 1A schematic diagram of the structure of a storage system provided according to an embodiment of the present disclosure;

[0047] Figure 2 A schematic diagram of the structure of software for a computer device provided according to one embodiment of the present disclosure;

[0048] Figure 3 A flowchart of a request processing method provided according to an embodiment of the present disclosure;

[0049] Figure 4 A flowchart of a request processing method provided according to an embodiment of the present disclosure;

[0050] Figure 5 A schematic diagram of the structure of a request processing device provided according to an embodiment of the present disclosure;

[0051] Figure 6 The figure is a schematic structural diagram of an electronic device provided according to one embodiment of the present disclosure. DETAILED DESCRIPTION

[0052] Various embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. In each of the drawings, identical elements are represented by identical or similar reference numerals. For clarity, the various parts in the drawings are not drawn to scale.

[0053] The following terms are used in this article:

[0054] Input / output (I / O) operations per second (IOPS) is a common performance metric for storage devices such as solid-state drives (SSDs). IOPS refers to the total number of I / O operations a storage device can perform per second. A higher IOPS number indicates better performance and lower latency for storage device operations (such as read and write operations).

[0055] A ring buffer, also known as a pointer ring, is a data structure that is typically used to store data in a fixed-size buffer in a circular manner. A ring buffer consists of a fixed-size array and two pointers: a head pointer pointing to the beginning of the buffer and a tail pointer pointing to the current position. As data is written to the ring buffer, the tail pointer advances. If the tail pointer reaches the end of the buffer, it wraps around to the beginning, implementing circular data storage. As data is read, the head pointer also advances to ensure the most up-to-date data is read.

[0056] User mode and kernel mode are two distinct operating modes within an operating system, distinguishing between code running at different privilege levels. In user mode, programs run at a lower privilege level, with limited access to resources and restricted operations. User mode code is typically an application or user process, such as a text editor or browser. In user mode, programs cannot directly access underlying hardware or execute privileged instructions. If a user mode program requires privileged operations or access to restricted resources, it must request kernel mode support through system calls.

[0057] Kernel state is a highly privileged level of the operating system. Only the operating system kernel can run in kernel state. In kernel state, the operating system has complete control over all system resources and privileged instructions. Kernel state can execute privileged instructions, directly access hardware devices, and manage system resources. When a user program requests a privileged operation, the processor switches to kernel state and transfers the request to the operating system kernel. Kernel state code is typically part of the operating system kernel and is responsible for core functions such as managing system resources, scheduling tasks, and handling interrupts.

[0058] Context is a static description of a specific moment in the dynamic process of a process or thread. If a process or thread is suspended, the context represents the CPU state associated with that moment. This state typically includes the values ​​of general-purpose registers and status registers. When the context is restored, the CPU can resume execution from the point where it was suspended, and the process or thread can continue running.

[0059] Context switch: During the execution of a user-mode program, if a system call, exception, or interrupt occurs, the kernel mode needs to handle it. At this time, the system will sink to the kernel mode, which will save the current context of the user mode and restore the original context of the kernel mode. This process is a case of context switch.

[0060] It is understandable that user-mode programs can perform data read and write operations on storage devices. User-mode programs can establish a data read and write process (worker), which includes multiple threads, each of which executes different data read and write tasks in parallel. The user-mode program can use multiple threads to issue data read and write requests to the storage device driver in kernel mode. The storage device driver forwards the data read and write requests to the storage device in sequence to implement the data read and write operations on the storage device. The storage device driver then returns the results of the data read and write operations to the user-mode program. Table 1 shows the verification results of the number of input / output operations per second of the storage device when the user-mode program uses a multi-threaded approach to process data read and write requests to the storage device. As shown in Table 1, a user-mode program creates 2-32 processes, each process creates one thread, and each thread executes a maximum of 2000-8000 data read / write requests. Verification results show that when the number of processes reaches 16 and each thread issues 4000 data read / write requests, the storage device's I / O operations per second peaks at 45,000. Further increasing the number of processes and the number of data read / write requests issued by each thread causes the storage device's I / O operations per second to decrease. Clearly, when a user-mode program issues a large number of data read / write requests to the storage device driver through multiple threads, a large number of these requests will be queued for execution by the storage device driver, limiting the storage device's I / O operations per second.

[0061] Based on this, an embodiment of the present disclosure provides a request processing method to reduce competition and waiting time between multiple threads, improve the concurrency performance of the kernel state in the host of the storage device, and thereby increase the number of input / output operations per second of the storage device.

[0062] Table 1

[0063] Number of workers Number of threads per worker Number of requests per thread Read IOPS 2 1 2000 30880 2 1 4000 30651 2 1 8000 30323 4 1 2000 34213 4 1 4000 34277 4 1 8000 35580 8 1 2000 44567 8 1 4000 45079 8 1 8000 45118 16 1 2000 45496 16 1 4000 45796 16 1 8000 45575 32 1 2000 37559 32 1 4000 35457 32 1 8000 33000

[0064] Figure 1 FIG. 1 shows a schematic diagram of the structure of a storage system provided according to an embodiment of the present disclosure. Figure 1As shown, the storage system 100 provided in an embodiment of the present disclosure includes: a computer device 110 and a storage device 120, wherein the storage device 120 can be understood as an external storage device of the computer device 110. In some embodiments, the storage device 120 can be a solid state drive (SSD), a hard disk drive (HDD), a universal flash storage (UFS), an embedded multimedia card (EMMC), or other types of memory. In some embodiments, the computer device 110 can be a mobile phone, a tablet computer, a PC, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), or other device having the storage device 120. The embodiments of the present disclosure do not impose any restrictions on the specific type of the computer device 110.

[0065] In some embodiments, storage device 120 may include a controller 121 and memory (e.g., Flash) 122. Controller 121 includes a data buffer 123 and firmware (Firmware, FW) 124. In some embodiments, memory 122 in storage device 120 includes multiple memory chips (e.g., UFS memory cards). The operating speed of a single memory chip is often insufficient to meet performance requirements, so storage device 120 often packages multiple memory chips together (e.g., 32 UFS memory cards) to enable parallel control of multiple memory chips and improve performance. In some embodiments, computer device 110 may run an operating system, which can be considered the host 111 of storage device 120. Host 111 may send instructions (including read / write commands, trim commands, and commands for FW-related tasks) to firmware 124 via a storage interface (e.g., Small Computer System Interface (SCSI)) channel between computer device 110 and storage device 120. When the host 111 sends a write command to the firmware 124, the firmware 124 can write data to the memory 122 according to the write command. When the host 111 sends a read command to the firmware 124, the firmware 124 can read data from the memory 122 according to the read command and return the read data to the host 111. It should be noted that, for the convenience of description, Figure 1 In the example above, the computer device 110 does not include the storage device 120 . Alternatively, the storage device 120 may be included as a part of the computer device 110 .

[0066] Figure 2 FIG. 1 is a schematic diagram of the structure of software for a computer device according to an embodiment of the present disclosure. Figure 2 As shown, the software architecture of the operating system running on the computer device 110 (which can also be understood as the host 111 of the storage device 120) can adopt a layered architecture. The embodiment of the present disclosure takes the Android system with a layered architecture as an example to illustrate the software structure of the host 111.

[0067] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer 210, application framework layer 220, Android runtime and system library 230, and kernel layer 240. The application layer 210 may include a series of application packages. Figure 2 As shown, the application package may include user-mode programs such as camera, call, music, video, and navigation. The application framework layer 220 provides an application programming interface (API) and programming framework for the user-mode programs of the application layer 210. Figure 2As shown, the application framework layer 220 may include a window manager, content provider, resource manager, etc. The application layer 210 and the application framework layer 220 run in a virtual machine. The system library may include multiple functional modules, such as media libraries and image processing libraries. The kernel layer 240 is a layer between hardware and software. The kernel layer 240 includes at least a driver module 241 and a file system management module 242. The driver module 241 may include a display driver 244, a camera driver 245, a sensor driver 246, a storage device driver 243, etc. In some embodiments, the application layer 210 runs in user mode, and the kernel layer 240 runs in kernel mode. A system call interface exists between user mode and kernel mode. For example, the input / output control (IOCTL) interface is used for communication between the driver module 241 and the application layer 210. In some embodiments, the kernel layer 240 also includes a first ring buffer 251, a second ring buffer 252, and a third ring buffer 253. In some embodiments, the storage device driver 243 receives multiple read and write requests from the user state program to the storage device 120 through the system call interface channel between the user state and the kernel state, and stores them in the first ring buffer 251, sends the target read and write request pointed to by the head pointer in the first ring buffer 251 to the controller 121 (for example, the firmware 124) and stores the target read and write request in the data buffer 123 to implement data read and write operations on the memory 122, and obtain a target read and write response to the target read and write request.

[0068] Since the process of using the request processing method in the embodiment of the present disclosure to process multiple read and write requests from the user mode program to the storage device 120 will be described in detail below, it will not be repeated here.

[0069] Figure 3 The flowchart of the request processing method provided according to one embodiment of the present disclosure is shown. The request processing method of the embodiment of the present disclosure is applied to the kernel state. The request processing method of the embodiment of the present disclosure can be executed by the request processing device (not shown in the figure) in the software of the computer device 110. Figure 3 , the request processing method includes steps S310 to S320.

[0070] In step S310 , multiple read and write requests from a user-mode program to a storage device are stored in a first ring buffer, where the storage device includes a controller and a memory.

[0071] In some embodiments, before storing multiple read and write requests from a user-mode program to the storage device 120 in the first ring buffer 251, the storage device driver 243 instantiates the first ring buffer 251, the second ring buffer 252, and the third ring buffer 253, respectively, and pre-allocates storage space for the third ring buffer 253. In one example, the memory 122 in the storage device 120 includes 32 UFS slots. The storage device driver 243 instantiates three lock-free pointer ring structure arrays for each of the 32 UFS slots: the first ring buffer 251, the second ring buffer 252, and the third ring buffer 253. The size of each array is, for example, 8192. The first ring buffer 251 is used to store multiple read and write requests from the user-mode program to the storage device 122. The second ring buffer 252 is used to store read and write responses to the multiple read and write requests. The third ring buffer 253 is used to store context information for the multiple read and write requests and context information for the read and write responses to the multiple read and write requests. In one example, memory is allocated for the third ring buffer 253 using a function in the Linux kernel for dynamically allocating memory (e.g., the kmalloc function). In some embodiments, before storing multiple read and write requests from a user-mode program to the storage device 120 in the first ring buffer 251, the storage device driver 243 initializes the storage device 120 as a miscdevice structure (dev device) in kernel mode and registers the storage device 120 for access and operation during read and write operations in the operating system.

[0072] In some embodiments, a user-mode program sends multiple read and write requests for storage device 120 to storage device driver 243 via a system call interface channel (e.g., an ioctl interface channel) between user mode and kernel mode. In some embodiments, in user mode, the user-mode program configures attributes for the read and write requests to storage device 120, including information such as startoffset, data length, dpo, fua, block size, and data buffer. Using configuration information such as lun, request information, read / write type, data transfer direction, and initialization of some fields of the UPIU structure, the program constructs corresponding system call interface channel read and write request commands (e.g., ioctl read and write request commands). The corresponding system call interface channel read and write request commands are sent to storage device driver 243. If the request is successful, the number of successful read and write requests is recorded. If the request fails, the relevant information is recorded. In one example, the user-mode program can send (e.g., 32*8192) read and write requests for storage device 120 to storage device driver 243 via a system call interface channel (e.g., an ioctl interface channel) between user mode and kernel mode. In some embodiments, the storage device driver 243 stores multiple read and write requests from the user-mode program to the storage device 120 in the first ring buffer 251 .

[0073] In some embodiments, the storage device driver 243 receives multiple read and write requests via a system call interface channel (e.g., an ioctl interface channel) between user mode and kernel mode, stores the multiple read and write requests in the first ring buffer 251, and stores context information for the multiple read and write requests in the third ring buffer 253. In one example, ptr_ring_peek() can be called to read the pointer data of the consumer head position in the third ring buffer 253 to ensure data accuracy. In one example, ptr_ring_discard_one() can be called to update the status of the third ring buffer 253.

[0074] In step S320, a loop step is executed: the target read / write request pointed to by the head pointer in the first ring buffer is sent to the controller to implement data read / write operations on the memory, and a target read / write response of the target read / write request is obtained; the target read / write response is stored in the second ring buffer, wherein the context information of the target read / write request and the target read / write response is stored in the third ring buffer; based on the context information of the target read / write request and the target read / write response, the target read / write response is sent to the corresponding user-mode program; the head pointer is moved down one position to clear the context information of the target read / write request and the target read / write response stored in the third ring buffer.

[0075] In some embodiments, the context information for a user-mode program's read / write request to the storage device 120 includes a mapping of the logical address of the read / write request to a physical address. In some embodiments, the storage device driver 243 constructs a storage interface (e.g., a SCSI interface) channel request based on the target read / write request pointed to by the head pointer in the first ring buffer 251 and the mapping of the logical address of the target read / write request to a physical address, and sends the storage interface channel request to the controller 121. In one example, ptr_ring_produce() can be called to process production data for the first ring buffer 251. After obtaining the memory 122 of the storage device 120, the driver uses a spinlock to fill in the storage interface channel request information and construct the storage interface channel request. The storage interface channel request is then sent to the controller 121, and the firmware 124 stores the storage interface channel request in the data buffer 123. This allows the firmware 124 to perform data read / write operations on the memory 122 according to the storage interface channel request, thereby obtaining a target read / write response to the target read / write request.

[0076] In some embodiments, the user-mode program sends a tracking command for tracking the execution status of the target read / write request to the storage device driver 243 via a system call interface channel (e.g., an ioctl interface channel) between the user mode and the kernel mode. In some embodiments, the storage device driver 243 receives the tracking command for tracking the execution status of the target read / write request via the system call interface channel between the user mode and the kernel mode, stores the target read / write response in the second ring buffer 252 based on the tracking command, and stores the context information of the target read / write response in the third ring buffer 253.

[0077] In some embodiments, the user-mode program sends a retrieval command for retrieving the target read / write response to the storage device driver 243 via a system call interface channel (e.g., an ioctl interface channel) between user mode and kernel mode. In some embodiments, the storage device driver 243 receives the retrieval command for retrieving the target read / write response via the system call interface channel between user mode and kernel mode, restores the original context in user mode based on the context information of the target read / write request, stores the target read / write response in user mode, restores the original context in kernel mode based on the context information of the target read / write response, and returns to the execution loop step, i.e., returns to the execution step of shifting the head pointer in the first ring buffer 251 by one position and clearing the context information of the target read / write request and target read / write response stored in the third ring buffer 253. In one example, ptr_ring_consume_batched() is called to send the target read / write response stored in the second ring buffer 252 to the corresponding user-mode program.

[0078] It is easy to understand that by directly passing pointers from the first ring buffer to the third ring buffer, there is no need to copy the data itself, thus avoiding frequent copying of data between different threads, reducing memory copies during data transmission, reducing the number of times data is moved in memory, and reducing system overhead. By sharing the first ring buffer to the third ring buffer in kernel mode, user-mode programs are prevented from frequently creating and destroying threads. In a multi-threaded model, each thread requires a certain amount of resources, thus saving system resources. By utilizing pointer operations in kernel mode's ring buffers, multiple read and write requests from user-mode programs to the storage device are passed and processed, reducing contention and waiting time between multiple threads, improving the kernel mode concurrency performance in the storage device's host, and thereby increasing the number of input / output operations per second of the storage device.

[0079] It is easy to understand that the user-mode program sends multiple read and write requests to the storage device to the storage device driver through the system call interface channel between the user mode and the kernel mode. By sending requests with the same attributes, the cache hit rate of the storage device can be improved, and more adjacent data blocks in the storage device can be accessed.

[0080] It is easy to understand that cyclically storing multiple read and write requests of the user-mode program to the storage device in the first ring buffer 251 at one time can reduce the communication overhead of cyclic writing-executing 1 command, and can improve the concurrency performance of the kernel mode in the host of the storage device.

[0081] Figure 4 The following is a flowchart of a request processing method according to an embodiment of the present disclosure. The request processing method of the embodiment of the present disclosure is applied to the kernel state. Figure 4 , the request processing method includes steps S401 to S411.

[0082] In step S401 , the storage device driver 243 instantiates the first ring buffer 251 , the second ring buffer 252 , and the third ring buffer 253 , respectively, and pre-allocates storage space for the third ring buffer 253 .

[0083] In step S402 , the storage device driver 243 initializes the storage device 120 as a miscdevice structure dev device in kernel mode, and registers the storage device 120 so as to access and operate it during read and write operations in the operating system.

[0084] In step S403 , the user-mode program sends multiple read and write requests to the storage device 120 to the storage device driver 243 via a system call interface channel (eg, an ioctl interface channel) between the user mode and the kernel mode.

[0085] In step S404 , the storage device driver 243 receives multiple read and write requests through the system call interface channel between the user state and the kernel state, stores the multiple read and write requests in the first ring buffer 251 , and stores the context information of the multiple read and write requests in the third ring buffer 253 .

[0086] In step S405, the storage device driver 243 constructs a storage interface (e.g., SCSI interface) channel request based on the target read / write request pointed to by the head pointer in the first ring buffer 251 and the mapping of the logical address of the target read / write request to the physical address, and sends the storage interface channel request to the controller 121.

[0087] In step S406 , the firmware 124 performs data read and write operations on the memory 122 according to the storage interface channel request, and obtains a target read and write response to the target read and write request.

[0088] In step S407 , the user state program sends a tracking command for tracking the execution status of the target read / write request to the storage device driver 243 through the system call interface channel between the user state and the kernel state.

[0089] In step S408, the storage device driver 243 receives a tracking command for tracking the execution status of the target read and write request through the system call interface channel between the user state and the kernel state, stores the target read and write response in the second ring buffer 252 based on the tracking command, and stores the context information of the target read and write response in the third ring buffer 253.

[0090] In step S409 , the user state program sends a retrieval command for retrieving the target read / write response to the storage device driver 243 via the system call interface channel between the user state and the kernel state.

[0091] In step S410, the storage device driver 243 receives a retrieval command for retrieving the target read / write response through the system call interface channel between the user state and the kernel state, restores the original context of the user state based on the context information of the target read / write request, and stores the target read / write response in the user state.

[0092] In step S411, the original kernel state context is restored based on the context information of the target read / write response.

[0093] In step S412, the head pointer in the first ring buffer 251 is shifted down by one position, and the context information of the target read / write request and the target read / write response stored in the third ring buffer 253 is cleared. The process returns to step S405.

[0094] Figure 5 FIG. 1 is a schematic diagram of a request processing device according to an embodiment of the present disclosure. Figure 5As shown, the request processing device 500 includes a read / write request storage unit 510 and a target read / write request execution unit 520 .

[0095] The read / write request storage unit 510 is configured to store multiple read / write requests from a user-mode program to a storage device in a first ring buffer, where the storage device includes a controller and a memory.

[0096] The target read / write request execution unit 520 is used to execute the following loop steps: sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement data read / write operations on the memory and obtain a target read / write response to the target read / write request; storing the target read / write response in the second ring buffer, wherein the context information of the target read / write request and the target read / write response is stored in the third ring buffer; based on the context information of the target read / write request and the target read / write response, sending the target read / write response to the corresponding user mode program; moving the head pointer down one position to clear the context information of the target read / write request and the target read / write response stored in the third ring buffer.

[0097] Since the process of processing multiple read and write requests from a user-mode program to the storage device 120 using the request processing method in the embodiment of the present disclosure has been described in detail above, it will not be repeated here.

[0098] The present disclosure also provides an electronic device, such as Figure 6 As shown, it includes a memory 620, a processor 610, and a program stored in the memory 620 and executable on the processor 610. When the program is executed by the processor 610, the various processes of the various embodiments of the above-mentioned request processing method can be implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0099] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be accomplished through instructions, or by controlling related hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. To this end, the embodiments of the present disclosure further provide a storage medium having a computer program or instructions stored thereon. When the computer program or instructions are executed by the processor, the various processes of the various embodiments of the request processing method described above can be implemented.

[0100] Since the instructions stored in the storage medium can execute the steps of the request processing method provided in the embodiment of the present disclosure, the beneficial effects that can be achieved by the request processing method provided in the embodiment of the present disclosure can be achieved. Please refer to the previous embodiment for details and will not be repeated here. The specific implementation of each of the above operations can be referred to the previous embodiment and will not be repeated here.

[0101] In summary, according to an embodiment of the present disclosure, applied to kernel mode, the storage device includes a controller and a memory, and multiple read and write requests of the user mode program to the storage device are stored in a first ring buffer. Then, a loop step is executed: the target read and write request pointed to by the head pointer in the first ring buffer is sent to the controller to implement data read and write operations on the memory, and a target read and write response of the target read and write request is obtained, and the target read and write response is stored in a second ring buffer, wherein the context information of the target read and write request and the target read and write response is stored in a third ring buffer, and based on the context information of the target read and write request and the target read and write response, the target read and write response is sent to the corresponding user mode program, the head pointer is moved down one position, and the context information of the target read and write request and the target read and write response stored in the third ring buffer is cleared. In this way, the pointer operation of the kernel mode ring buffer is used to realize the transmission and processing of multiple read and write requests of the user mode program to the storage device, thereby reducing the competition and waiting time between multiple threads, improving the concurrency performance of the kernel mode in the host of the storage device, and thereby improving the input / output operations per second of the storage device.

[0102] Finally, it should be noted that the above embodiments are merely examples for the purpose of illustrating the present disclosure and are not intended to limit the embodiments. Those skilled in the art will readily appreciate that other variations or modifications based on the above descriptions are possible. It is not necessary and impossible to provide an exhaustive list of all embodiments. Obvious variations or modifications arising therefrom remain within the scope of protection of the present disclosure.

Claims

1. A request processing method, applied in kernel mode, comprising: storing multiple read and write requests of a user-mode program to a storage device in a first ring buffer, wherein the storage device includes a controller and a memory; Executing a loop step: sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement a data read / write operation on the memory, and obtaining a target read / write response to the target read / write request; storing the target read / write response in a second ring buffer, wherein context information of the target read / write request and the target read / write response is stored in a third ring buffer; Based on the context information of the target read / write request and the target read / write response, sending the target read / write response to the corresponding user mode program; The head pointer is moved down by one position, and the context information of the target read / write request and the target read / write response stored in the third ring buffer is cleared.

2. The request processing method according to claim 1, wherein: Before storing the multiple read and write requests of the user mode program to the storage device in the first ring buffer, the request processing method further includes: Instantiate the first ring buffer, the second ring buffer, and the third ring buffer respectively; Pre-allocate storage space for the third ring buffer.

3. The request processing method according to claim 1, wherein: The storing of the plurality of read and write requests of the user mode program to the storage device in the first ring buffer comprises: Receiving the multiple read and write requests through a system call interface channel between user mode and kernel mode; storing the plurality of read and write requests in the first ring buffer; Storing context information of the multiple read and write requests in the third ring buffer.

4. The request processing method according to claim 3, wherein: The context information of the read / write request includes: a mapping of the logical address of the read / write request to a physical address, The step of sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement the data read / write operation on the memory, and obtaining the target read / write response to the target read / write request includes: Constructing a storage interface channel request based on the target read / write request and a mapping of the logical address of the target read / write request to the physical address, and sending the storage interface channel request to the controller; The controller performs data read and write operations on the memory according to the storage interface channel request, and obtains a target read and write response to the target read and write request.

5. The request processing method according to claim 3, wherein: The storing the target read / write response in the second ring buffer comprises: Receiving, via a system call interface channel between a user state and a kernel state, a tracking command for tracking the execution status of the target read / write request; storing the target read and write responses in the second ring buffer based on the tracking command; The context information of the target read / write response is stored in the third ring buffer.

6. The request processing method according to claim 5, wherein: The sending of the target read / write response to the corresponding user mode program based on the context information of the target read / write request and the target read / write response includes: Receiving a retrieval command for retrieving the target read / write response via a system call interface channel between a user state and a kernel state; Based on the context information of the target read / write request, restore the original context in the user state and store the target read / write response in the user state; Based on the context information of the target read / write response, the original context of the kernel state is restored, and the loop step is executed again.

7. The request processing method according to claim 1, wherein: Before storing the multiple read and write requests of the user mode program to the storage device in the first ring buffer, the request processing method further includes: Initialize the storage device as a miscellaneous device structure device and register the storage device.

8. A request processing device, applied in kernel mode, comprising: a read / write request storage unit, configured to store a plurality of read / write requests of a user-mode program to a storage device in a first ring buffer, wherein the storage device includes a controller and a memory; a target read / write request execution unit, configured to execute a loop step of sending the target read / write request pointed to by the head pointer in the first ring buffer to the controller to implement a data read / write operation on the memory and obtain a target read / write response to the target read / write request; storing the target read / write response in a second ring buffer, wherein context information of the target read / write request and the target read / write response is stored in a third ring buffer; Based on the context information of the target read / write request and the target read / write response, sending the target read / write response to the corresponding user mode program; The head pointer is moved down by one position, and the context information of the target read / write request and the target read / write response stored in the third ring buffer is cleared.

9. A storage system comprising: Storage devices, including controllers and memory; A computer device, comprising a request processing device running in kernel mode as described in claim 8, which is used to store multiple read and write requests of a user-mode program to the storage device in a first ring buffer, and send the target read and write request pointed to by the head pointer in the first ring buffer to the controller to implement data read and write operations on the memory, and obtain a target read and write response to the target read and write request.

10. A storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Local storage IO protocol stack data interaction method and device

    CN111209123A

  • DMA data transmission system and method

    CN114416613A