Asynchronous communication-based file system client kernel mode and user mode communication method

By employing an asynchronous communication method between kernel mode and user mode, and utilizing a circular buffer, DMA, and shared memory pool, the problems of communication latency and throughput limitations in high-concurrency scenarios are solved, achieving efficient data transmission and response.

CN120950251APending Publication Date: 2025-11-14JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511071174.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing kernel-mode and user-mode communication methods suffer from frequent context switching and redundant data copying in high-concurrency, low-latency I/O access scenarios, leading to throughput limitations and consistency issues, especially in AI training and real-time data analysis.

Method used

An asynchronous communication method based on an event-driven architecture is adopted, lock-free queue management is achieved through a circular buffer, zero-copy data transmission is performed by combining DMA and a shared memory pool, and adaptive priority queue scheduling is used to reduce context switching and data copy overhead and improve response efficiency.

Benefits of technology

It significantly reduces the context switching overhead and data copying consumption of kernel-mode and user-mode communication, improves system throughput and response efficiency, and is suitable for high-concurrency mixed load scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120950251A_ABST
    Figure CN120950251A_ABST
Patent Text Reader

Abstract

The invention provides a file system client kernel mode and user mode communication method based on asynchronous communication. According to the asynchronous communication-based file system client kernel mode and user mode communication method provided by the embodiment of the invention, the context switching overhead of communication between the user mode and the kernel mode can be reduced, the data transmission throughput is improved, the resource utilization rate is optimized through dynamic queue management, and the problem of performance bottleneck in a high-concurrency scene is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of kernel-mode and user-mode communication technology in distributed storage systems, and particularly to a kernel-mode and user-mode communication method for file system clients based on asynchronous communication. Background Technology

[0002] In modern high-performance computing (HPC) and artificial intelligence (AI) training scenarios, the file system client serves as a crucial bridge between the distributed storage system and computing nodes, and its performance directly impacts the overall system's throughput and response efficiency. With the continuous expansion of AI model scale and the urgent need for petabyte-scale data processing capabilities in HPC tasks, traditional communication mechanisms based on synchronous system calls are insufficient to meet the requirements of high-concurrency, low-latency I / O access. Related technologies typically utilize kernel interfaces such as Netlink and IOCTL to achieve interaction between user space and kernel space, and combine them with user-space file system frameworks such as FUSE to complete file operation proxying. Specifically, this communication system covers the entire process from request generation, context switching, data transmission to cache management, involving multi-dimensional technical collaboration including hardware resource scheduling, memory management, and queue control.

[0003] However, existing communication methods, which directly employ synchronous system calls and fixed queue mechanisms, fail to effectively integrate event-driven architectures and dynamic resource scheduling strategies. This can lead to frequent context switching and redundant data copying, significantly increasing I / O latency and limiting throughput. Traditional solutions rely on copy_from_user / copy_to_user mechanisms for data transmission, consuming significant CPU resources. Furthermore, in mixed load scenarios, fixed-priority queues struggle to adaptively adjust processing weights, easily resulting in resource waste or request backlog. In addition, the lack of coordination mechanisms between metadata caches and data caches can easily lead to consistency issues during multi-threaded concurrent access. These technical shortcomings are particularly pronounced in high-concurrency scenarios such as AI training and real-time data analysis, severely restricting the performance and scalability of distributed storage systems. Summary of the Invention

[0004] The present invention aims to at least partially solve one of the technical problems in the related art.

[0005] Therefore, the first objective of this invention is to propose a file system client kernel-user space communication method based on asynchronous communication.

[0006] The second objective of this invention is to propose a file system client kernel-user space communication device based on asynchronous communication.

[0007] The third objective of this invention is to provide an electronic device.

[0008] The fourth objective of this invention is to provide a computer-readable storage medium.

[0009] The fifth objective of this invention is to provide a computer program product.

[0010] To achieve the above objectives, the first aspect of this invention proposes a kernel-user space communication method for a file system client based on asynchronous communication, comprising: S1, publishing asynchronous events in kernel space through a circular buffer based on an event-driven architecture, and implementing lock-free queue management using CAS operations; S2, a user-space daemon process listens for asynchronous events through epoll or kqueue, merging multiple I / O requests into batches for processing, reducing the number of context switches; S3, implementing zero-copy data transfer between user space and kernel space through DMA and a shared memory pool, with user-space processes using mmap to map shared memory regions, and kernel space submitting data pointers through virtqueue; S4, dynamically adjusting the processing weight of the adaptive priority queue according to system load, and optimizing queue resource allocation in real time through a PID controller to improve the response efficiency of high-priority requests.

[0011] In one embodiment of the present invention, the method of publishing asynchronous events in kernel space through a circular buffer based on the event-driven architecture and implementing lock-free queue management using CAS operations further includes: S11, the circular buffer adopts a dual-pointer structure to record the positions of producers and consumers respectively, and implements lock-free event enqueueing and dequeueing through CAS operations; S12, the asynchronous events are generated through Netlink or IOCTL interfaces, and event listeners are registered in user space through epoll / kqueue to realize asynchronous event notification and processing.

[0012] In one embodiment of the present invention, the user-space daemon process listens for asynchronous events through epoll or kqueue, and merges multiple I / O requests into batches for processing, reducing the number of context switches. The method further includes: S21, after receiving an event notification, the daemon process categorizes read events and write events into different thread pool queues according to the event type; S22, when processing requests, the threads in the thread pool adopt a batch submission mechanism to merge multiple events into a single processing unit, reducing thread wake-up and scheduling overhead.

[0013] In one embodiment of the present invention, the zero-copy data transfer between user mode and kernel mode is achieved through DMA and a shared memory pool, where user mode processes use mmap to map shared memory regions and kernel mode submits data pointers through virtqueue. The method further includes: S31, the shared memory pool pre-allocates contiguous physical memory pages and divides the memory into fixed-size blocks (e.g., 4KB or 1MB) to reduce memory fragmentation; S32, the memory lifecycle is managed through reference counting and CAS atomic operations to ensure thread safety and resource reclamation efficiency during multi-process access.

[0014] In one embodiment of the present invention, the method further includes: implementing an intelligent prefetching mechanism based on the LRU-K algorithm, which analyzes the access patterns of user-mode processes, predicts subsequent requests, and loads data into the cache in advance by an independent prefetching thread, so as to improve the hit rate of hot data and reduce cache pollution caused by occasional access.

[0015] To achieve the above objectives, a second aspect of the present invention proposes a file system client kernel-user space communication device based on asynchronous communication, comprising: an event-driven publishing module, used to publish asynchronous events in kernel space through a circular buffer based on an event-driven architecture, and to implement lock-free queue management using CAS operations; an asynchronous listening and batch processing module, used by a user-space daemon process to listen for asynchronous events through epoll or kqueue, and to merge multiple I / O requests into batches for processing to reduce the number of context switches; a zero-copy transfer module, used to implement zero-copy data transfer between user space and kernel space through DMA and a shared memory pool, whereby user-space processes use mmap to map shared memory regions, and kernel space submits data pointers through virtqueue; and an adaptive priority scheduling module, used to dynamically adjust the processing weight of the adaptive priority queue according to the system load, and to optimize queue resource allocation in real time through a PID controller to improve the response efficiency of high-priority requests.

[0016] In one embodiment of the present invention, the event-driven publishing module is further configured to: use a dual-pointer structure for the circular buffer to record the positions of the producer and consumer respectively, and implement lock-free event enqueueing and dequeueing through CAS operation; the asynchronous event is generated through Netlink or IOCTL interface, and event listeners are registered in user space through epoll / kqueue to realize asynchronous event notification and processing.

[0017] To achieve the above objectives, a third aspect of the present invention provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0018] The memory stores computer-executed instructions;

[0019] The processor executes computer execution instructions stored in the memory to implement the method as described in any one of the first aspects.

[0020] To achieve the above objectives, a fourth aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of the first aspects.

[0021] To achieve the above objectives, a fifth aspect of the present invention provides a computer program product that, when executed by a processor, implements the method described in any one of the first aspects.

[0022] The technical solutions provided by the embodiments of the present invention bring at least the following beneficial effects: they can significantly reduce the context switching overhead and data copy consumption of kernel-mode and user-mode communication, improve system throughput and response efficiency, and adapt to high-concurrency mixed load scenarios.

[0023] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0024] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0025] Figure 1 This is a flowchart of a file system client kernel-user space communication method based on asynchronous communication according to an embodiment of the present invention;

[0026] Figure 2 This is a schematic diagram of the structure of a file system client kernel-user space communication device based on asynchronous communication according to an embodiment of the present invention. Detailed Implementation

[0027] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0028] Figure 1 This is a flowchart of a file system client kernel-user space communication method based on asynchronous communication according to an embodiment of the present invention.

[0029] like Figure 1 As shown, the file system client kernel-user space communication method based on asynchronous communication includes the following steps:

[0030] S1, based on an event-driven architecture, publishes asynchronous events in kernel space through a circular buffer and uses CAS operations to implement lock-free queue management.

[0031] Specifically, in some implementations, this invention uses an event-driven architecture in kernel mode to publish asynchronous events through a ring buffer and utilizes CAS (Compare-And-Swap) operations to achieve lock-free queue management, thereby improving the concurrency performance and response efficiency of communication between user mode and kernel mode. The core technical principle of this step lies in reducing the context switching and scheduling overhead caused by traditional locking mechanisms through lock-free data structures and event-driven mechanisms, while ensuring data consistency and atomicity in a multi-threaded environment.

[0032] Furthermore, S1 includes:

[0033] S11, the circular buffer adopts a dual-pointer structure to record the positions of producers and consumers respectively, and implements lock-free event enqueueing and dequeueing through CAS operation.

[0034] Specifically, the ring buffer employs a dual-pointer structure, used to record the current positions of the producer and consumer within the buffer. This structure achieves concurrent enqueueing and dequeueing of events through lock-free CAS (Compare-And-Swap) atomic operations, thereby improving communication efficiency in high-concurrency environments and avoiding the context switching overhead and deadlock risk associated with traditional locking mechanisms.

[0035] At the technical implementation level, a circular buffer typically consists of a fixed-size array, with its ends linked together to form a circular structure. The producer pointer (write_ptr) indicates the next writable position, and the consumer pointer (read_ptr) indicates the next readable position. During each enqueue operation, the producer attempts to update write_ptr using a CAS operation, ensuring atomic updates to the write position in a multi-threaded environment. For dequeue operations, the consumer updates read_ptr using CAS, enabling lock-free access to the read position. To prevent buffer overflow, the system typically employs a "circular boundary check" mechanism, which reserves a certain safety distance (such as 1 / 4 of the buffer capacity) between write_ptr and read_ptr. When this distance is less than a preset threshold, it triggers buffer resizing or a discard request strategy.

[0036] In terms of parameters, the capacity of the circular buffer is typically configured based on the system's expected event throughput; for example, in AI training scenarios, it can be set to 1024 to 8192 event slots. The number of retries, timeout mechanisms, and memory alignment (e.g., 64-byte alignment) for CAS operations also need to be optimized according to the hardware platform (e.g., x86 or ARM architecture) to ensure the performance and reliability of atomic operations. Furthermore, the event structure typically includes the event type (READ / WRITE), data pointer, length field, and status bits to support asynchronous processing and state synchronization.

[0037] In application scenarios, this circular buffer is embedded between the kernel-mode event-driven module and the user-mode daemon process as the core data structure for asynchronous communication. For example, in a file system client, after the kernel receives an I / O request from the user mode, it writes the event to the circular buffer. The user-mode daemon process listens for events through epoll / kqueue, reads them in batches from the buffer, and distributes them to the thread pool for processing, thereby achieving high-throughput, low-latency asynchronous communication.

[0038] The technical advantage of this step lies in significantly reducing the overhead of thread blocking and context switching through lock-free design, thereby improving the system's responsiveness and stability in high-concurrency scenarios. Combining CAS operations and a two-pointer mechanism not only ensures data consistency in a multi-threaded environment but also avoids the performance bottlenecks caused by traditional locking mechanisms, providing an efficient and reliable foundation for subsequent zero-copy data transmission and dynamic queue management.

[0039] S12, the asynchronous event is generated through the Netlink or IOCTL interface, and event listeners are registered in user space through epoll / kqueue to realize asynchronous event notification and processing.

[0040] Specifically, in this invention, asynchronous events are generated through Netlink or IOCTL interfaces and registered in user space via epoll or kqueue for event listening, thereby achieving asynchronous event notification and processing. This step is a key link in achieving low latency and high throughput in the entire communication framework, and its technical implementation is based on the asynchronous communication mechanism and user-space event-driven model provided by the Linux kernel.

[0041] At the technical implementation level, Netlink is a socket-based asynchronous communication mechanism that supports bidirectional message passing between the kernel and user-space processes, has multicast capabilities, and is suitable for system-level event notifications. IOCTL, on the other hand, is a traditional system call interface used to send control commands to the kernel. Although it is a synchronous interface, it can be asynchronously processed through asynchronous notifications (such as triggering epoll events via file descriptors). In this scheme, after receiving a file system operation request (such as read / write or metadata update), the kernel-space module generates an event through the Netlink or IOCTL interface and writes the event to a kernel-space ring buffer. This buffer adopts a lock-free design and uses CAS (Compare-And-Swap) atomic operations to achieve thread-safe event enqueueing.

[0042] In user space, the daemon registers a listener for Netlink or IOCTL file descriptors via epoll (Linux) or kqueue (BSD / macOS), setting EPOLLIN or EVFILT_READ events to achieve asynchronous event notification. When an event is written to kernel space, epoll / kqueue immediately wakes up the user-space thread, triggering the event callback function. The callback function dequeues the event from the circular buffer and dispatches it to the appropriate processing function in the thread pool based on the event type (e.g., READ, WRITE), thus achieving asynchronous event processing.

[0043] At the parameter level, Netlink communication can be configured for multicast group mode, supporting multiple user-space processes to simultaneously listen for the same type of event. Its message buffer size is typically set to 4KB–64KB to adapt to different load scenarios. The IOCTL interface requires an asynchronous notification mechanism (e.g., set via F_SETOWN and F_NOTIFY), and its event triggering threshold can be configured for single or batch mode to reduce system call frequency. The event types listened to by epoll / kqueue should include edge-triggered mode to avoid duplicate event triggering and improve processing efficiency.

[0044] At the application level, this step is widely applicable to scenarios requiring frequent kernel-user space interaction, such as distributed file systems, high-performance storage clients, and AI training frameworks. For example, in a distributed storage system, when the kernel detects a data update event on a remote node, it can notify the user-space process via Netlink. The user-space process then listens for updates via epoll / kqueue and promptly triggers cache refresh or prefetch operations, thereby improving overall I / O performance.

[0045] The technical advantage of this step lies in significantly reducing the context switching overhead between user mode and kernel mode through an asynchronous event mechanism, thereby improving the real-time performance and concurrency capabilities of event processing. Combined with thread pools and event callbacks, high-throughput event distribution and processing can be achieved, providing an efficient and stable event-driven foundation for subsequent modules such as zero-copy data transfer and dynamic queue management.

[0046] S2, the user-space daemon listens for asynchronous events through epoll or kqueue, and merges multiple I / O requests into batches for processing, reducing the number of context switches.

[0047] Specifically, in some implementations, the user-space daemon listens for asynchronous events through `epoll` (Linux) or `kqueue` (BSD) mechanisms, merging multiple I / O requests into batches for processing. This significantly reduces the number of context switches between user space and kernel space, improving overall system throughput. This step is based on an event-driven architecture, combining lock-free queues and thread pool technology to achieve an efficient asynchronous I / O processing flow.

[0048] Furthermore, S2 includes:

[0049] S21, after receiving the event notification, the daemon process classifies the read event and the write event into different thread pool queues according to the event type.

[0050] Specifically, in some implementations, after receiving an event notification, the daemon process categorizes read events and write events into different thread pool queues based on the event type. This implementation is based on an event-driven architecture and a lock-free queue mechanism. Specifically, the kernel space publishes events through a ring buffer, with each event containing metadata such as a type field (e.g., READ, WRITE), a data pointer, a request ID, and a timestamp. The user-space daemon process listens for kernel-space events using epoll or kqueue mechanisms. Once an event is detected, it performs a non-blocking dequeue operation using a lock-free queue. During the event dispatch phase, the daemon process categorizes events based on their type field, submitting read events to the read thread pool and write events to the write thread pool, thereby achieving parallelization and load isolation of I / O operations.

[0051] Furthermore, the size of the thread pool in this step can be dynamically adjusted according to the system load. For example, in high-concurrency read operation scenarios, the read thread pool can be expanded to 16-32 threads, while the write thread pool is maintained at 8-16 threads based on write latency sensitivity, in order to balance resource utilization and response time. The event classification logic adopts CAS (Compare-And-Swap) atomic operations to ensure thread safety of event enqueuing in a multi-threaded environment and avoid data corruption caused by race conditions.

[0052] This technique is widely applicable in practical scenarios involving mixed I / O loads, such as AI training and HPC data processing. Especially when the read / write operation ratio is unbalanced, it effectively prevents thread resource contention and improves system throughput and response efficiency. Through an event-type-driven thread pool separation mechanism, this invention achieves differentiated processing for different I / O operations, thereby significantly optimizing communication performance between kernel and user modes. It is a key technical step in achieving low-latency, high-concurrency file system communication.

[0053] S22, when the threads in the thread pool process requests, they adopt a batch submission mechanism to merge multiple events into one processing unit, thereby reducing the overhead of thread waking up and scheduling.

[0054] Specifically, in some implementations, the threads in the thread pool employ a batch submission mechanism when processing requests, merging multiple events into a single processing unit, thereby reducing thread wake-up and scheduling overhead. This mechanism is based on an event-driven architecture, combining lock-free queues with a thread pool's collaborative scheduling strategy to achieve efficient processing of communication events between user space and kernel space. Specifically, the kernel space publishes events through a ring buffer, with each event containing metadata such as operation type (e.g., READ, WRITE), data pointer, and length. The user-space daemon listens to the event queue using epoll or kqueue, and when an event is detected as ready, it retrieves multiple events from the buffer in batches, forming a processing batch, which is then handled uniformly by worker threads in the thread pool.

[0055] Furthermore, this batch submission mechanism balances latency and throughput by setting reasonable batch processing thresholds (such as a maximum number of events of 64 or a maximum wait time of 5ms). In high-concurrency scenarios, threads in the thread pool can handle multiple I / O requests at once, thereby significantly reducing the frequency of context switching. For example, in AI training, multiple threads may submit requests to read model parameters simultaneously. By batch merging, interactions that originally required multiple system calls can be compressed into a single interaction, reducing the overhead of CPU switching between user mode and kernel mode. In practice, this can reduce the number of context switches by approximately 60%.

[0056] In terms of parameter settings, the size of the thread pool is usually configured based on the number of CPU cores in the system, for example, set to 1.5 to 2 times the number of CPU cores, to balance concurrent processing capabilities and resource utilization. The capacity of the event queue is dynamically adjusted according to the expected I / O load, supporting on-demand expansion and avoiding event dropping or blocking due to a full queue.

[0057] This step plays a crucial role in the entire technical solution and is one of the core means to achieve high-throughput, low-latency communication. By reducing the overhead of thread scheduling and context switching, it improves the overall performance of the system under mixed loads (such as sequential reads and random writes), and is particularly suitable for large-scale distributed storage systems and high-performance computing (HPC) scenarios.

[0058] S3 achieves zero-copy data transfer between user mode and kernel mode through DMA and shared memory pool. User mode processes use mmap to map shared memory regions, and kernel mode submits data pointers through virtqueue.

[0059] Specifically, this step achieves zero-copy data transfer between user mode and kernel mode through DMA (Direct Memory Access) and a shared memory pool, which is a key technical achievement of this invention in improving communication efficiency and reducing system overhead. Its core lies in using the mmap mechanism to map the virtual address space of user-mode processes to the physical memory region of kernel mode, thereby achieving memory sharing; simultaneously, kernel mode submits data pointers through virtqueue, avoiding the data copying overhead of traditional copy_from_user / copy_to_user operations.

[0060] Furthermore, S3 includes:

[0061] S31, the shared memory pool pre-allocates contiguous physical memory pages and divides the memory into fixed-size blocks (such as 4KB or 1MB) to reduce memory fragmentation.

[0062] Specifically, in some implementations, the shared memory pool divides memory into fixed-size blocks (such as 4KB or 1MB) by pre-allocating contiguous physical memory pages to reduce memory fragmentation and improve memory management efficiency. The core technical principle of this step is based on the physical memory pre-allocation mechanism and the fixed-size block memory pool management strategy, aiming to optimize data transfer performance between user mode and kernel mode and reduce the overhead of memory allocation and deallocation.

[0063] In terms of specific implementation, during the initialization phase, the system uses the `mmap()` or `shmat()` system calls to map a contiguous physical memory region into the shared address space between user mode and kernel mode. This memory region is typically pre-allocated in the kernel using mechanisms such as `kmalloc()` or `CXL` (Compute Express Link) to ensure its physical contiguity, thereby supporting DMA (Direct Memory Access) transfers. The memory pool divides this contiguous region into multiple fixed-size memory blocks, such as 4KB or 1MB. The block size can be configured according to the application scenario; for example, in AI training scenarios, 1MB blocks can reduce the number of blocks and improve the efficiency of large-granularity data transfer.

[0064] In terms of memory management, the system employs a combination of reference counting and atomic operations (such as CAS and Compare-And-Swap) to ensure safe memory access in multi-process or multi-threaded environments. The reference count of each memory block is incremented upon allocation and decremented upon release. When the reference count reaches zero, the memory block is reclaimed and added back to the memory pool. Furthermore, the system may optionally introduce garbage collection (GC) mechanisms, such as a delayed collection strategy based on `Kmalloc`, to further optimize memory utilization.

[0065] This step is widely applicable in practical scenarios such as distributed storage systems, high-performance file systems (e.g., FUSE), and AI training frameworks. Especially in environments with high concurrency and low latency requirements, it significantly improves memory access efficiency and system throughput by reducing memory fragmentation and avoiding frequent dynamic memory allocation. Technically, this shared memory pool design can reduce memory allocation latency to the microsecond level, increase memory utilization by over 40%, and effectively reduce performance fluctuations caused by memory fragmentation, thereby enhancing the stability and scalability of the entire communication framework.

[0066] S32, the memory lifecycle is managed through reference counting and CAS atomic operations to ensure thread safety and resource reclamation efficiency during multi-process access.

[0067] Specifically, the memory lifecycle is managed through reference counting and CAS atomic operations to ensure thread safety and efficient resource reclamation during multi-process access. The core of this technical solution lies in achieving efficient memory sharing and management between user mode and kernel mode through a shared memory pool, thereby reducing fragmentation issues and context switching overhead in traditional memory allocation mechanisms.

[0068] At the technical implementation level, shared memory pools employ a strategy of pre-allocating contiguous physical memory pages, typically dividing memory into fixed-size blocks (such as 4KB or 1MB) to accommodate data transfer needs of varying granularities. Each memory block is assigned a reference count during allocation to track how many processes or threads are currently using it. When a process maps shared memory pages to its own address space using the `mmap` or `shmat` system calls, the reference count is updated lock-free each time the memory block is accessed or released via a CAS (Compare-And-Swap) atomic operation. The CAS operation is atomically implemented at the hardware level (e.g., the CMPXCHG instruction in x86 architecture), ensuring that incrementing or decrementing the reference count during concurrent access by multiple processes does not result in race conditions, thus guaranteeing thread safety for memory access.

[0069] Regarding parameters, the size of memory blocks needs to be optimized based on the actual I / O load. For example, in AI training scenarios, if data access exhibits high concurrency and fine-grained characteristics, 4KB blocks can be used to improve allocation efficiency; while in large-scale batch read / write scenarios, 1MB blocks are more beneficial for reducing memory management overhead. The initial value of the reference count is usually set to 1, indicating that the memory block has been allocated. When the reference count decreases to 0, the memory block will be marked as reclaimable and released uniformly by the garbage collection mechanism (GC). The GC algorithm can adopt a delayed reclamation strategy similar to `Kmalloc`, combined with the free list of the memory pool for efficient memory reclamation.

[0070] In application scenarios, this memory management mechanism is widely applicable to data transfer between user space and kernel space in distributed storage systems, such as file system caching, metadata operations, and asynchronous I / O event handling. By combining a shared memory pool with reference counting, user-space processes and kernel modules can directly share physical memory regions, avoiding the data copying overhead of traditional `copy_from_user` / `copy_to_user` mechanisms, thereby significantly improving system throughput and response speed.

[0071] The technical benefits of this step lie in its ability to achieve efficient allocation and reclamation of memory resources through the combination of reference counting and CAS atomic operations. This reduces memory fragmentation and improves the security and performance of concurrent access by multiple processes. Real-world testing data shows that this mechanism can increase memory utilization by over 40% and effectively reduce system latency caused by memory contention, providing crucial support for high-concurrency, low-latency distributed storage systems.

[0072] S4 dynamically adjusts the processing weight of the adaptive priority queue based on the system load, and optimizes the allocation of queue resources in real time through the PID controller to improve the response efficiency of high-priority requests.

[0073] Specifically, in some implementations, dynamically adjusting the processing weights of the Adaptive Priority Queue (APQ) based on system load is one of the core technical steps of the dynamic resource scheduling module in this invention. This step, by introducing a PID (Proportional-Integral-Derivative) controller, enables real-time optimization of queue processing resources, thereby improving the response efficiency of high-priority requests, which is particularly suitable for mixed load scenarios such as AI training and HPC.

[0074] At the technical implementation level, this step first deploys a load monitoring module in kernel space to collect key system performance indicators in real time, such as CPU utilization (expressed as a percentage, ranging from 0-100%), queue depth (i.e., the number of requests currently waiting to be processed), and I / O throughput (in MB / s or IOPS). These indicators are periodically updated through a sampling period (e.g., 100ms) and used as input signals for the PID controller. The PID controller calculates the weight adjustment amount for queue i based on the deviation between the current load and the preset target load (Ttarget).

[0075] At the parameter level, it is recommended to set the system load Tsys(t) sampling frequency to 100ms to balance real-time performance and computational overhead. The target load Ttarget can be set according to the application scenario. For example, in AI training scenarios, Ttarget can be set to 70%-80% CPU utilization to ensure efficient use of computing resources. The output range of queue weight i(t) is usually limited to [0,1] and is distributed to each priority queue after normalization to control its processing priority in the scheduler.

[0076] In terms of application scenarios, this step is mainly applied in distributed storage systems. When the user-space daemon submits I / O requests to the kernel space through the Netlink or IOCTL interface, the kernel space dynamically adjusts the processing weight of each queue according to the current load to ensure that high-priority requests (such as model parameter updates) can still obtain sufficient scheduling resources when resources are scarce, thereby reducing response latency and improving the overall throughput of the system.

[0077] In terms of technical effectiveness, this step, by introducing a PID control mechanism, achieves dynamic, closed-loop adjustment of queue weights, effectively alleviating the rigidity of resource allocation in traditional fixed-priority queues under load fluctuations. Experimental data shows that in mixed load scenarios, this mechanism can reduce the average response time of high-priority requests by approximately 70%, while maintaining stable growth in system throughput, significantly improving the elasticity and adaptability of the storage system.

[0078] The asynchronous communication-based file system client kernel-user space communication method of this invention effectively reduces the context switching overhead and data copying frequency between user space and kernel space, improves data transmission throughput and response efficiency, and adapts to high-concurrency mixed load scenarios.

[0079] In addition, this invention also implements an intelligent prefetching mechanism based on the LRU-K algorithm. By analyzing the access patterns of user-mode processes, it predicts subsequent requests and loads data into the cache in advance by an independent prefetching thread, thereby improving the hit rate of hot data and reducing cache pollution caused by occasional access.

[0080] Specifically, this step implements an intelligent prefetching mechanism based on the LRU-K algorithm. This mechanism aims to predict subsequent data requests by analyzing the access patterns of user-space processes, and then load the data into the cache in advance by an independent prefetching thread. This improves the hit rate of frequently accessed data and reduces cache pollution caused by occasional accesses. This mechanism is one of the key innovations of this invention in cache management and I / O performance optimization.

[0081] At the technical implementation level, the LRU-K algorithm maintains the timestamps of the K most recent accesses to each cache item (K is usually 2, i.e., LRU-2) to more accurately assess the access frequency of data. Unlike the traditional LRU algorithm, which only records the time of the most recent access, LRU-K considers the time distribution of multiple accesses, thus more effectively identifying truly hot data. A cache item is only added to the cache queue after being accessed K times, avoiding frequent loading and cache replacement of data with infrequent accesses. In the prefetch strategy, the access sequence of user-space processes is collected and analyzed in real time to identify data blocks with a high probability of consecutive access. The prefetch thread runs independently of the main business thread, using CAS atomic operations and a shared memory pool for thread-safe data loading, avoiding resource contention.

[0082] Regarding parameter metrics, the K value is typically set to 2 or 3 to strike a balance between prediction accuracy and computational overhead. The scheduling priority of the prefetch thread should be lower than that of the main business thread to ensure it does not affect the real-time performance of critical I / O operations. The trigger threshold for cache prefetching can be set when the access frequency exceeds a certain baseline (e.g., ≥10 accesses per second), and combined with the access interval (e.g., ≤500ms) for a comprehensive judgment.

[0083] This mechanism is suitable for high-concurrency I / O scenarios such as AI training, HPC computing, and real-time data analysis. Especially under mixed loads, such as when sequential reads and random writes coexist, it can significantly improve cache hit rate. By reducing the interference of occasional accesses on the cache, the overall system I / O latency can be reduced by more than 20%, and the cache pollution rate can be reduced by about 35%, thereby improving the throughput performance and response efficiency of the storage system.

[0084] The asynchronous communication method for file system client kernel-user space communication in this invention combines the intelligent prefetching mechanism of the LRU-K algorithm with the asynchronous loading of predicted data by independent threads, which further improves the hit rate of hot data in the cache and reduces the impact of occasional access on cache efficiency. Thus, it significantly optimizes the overall response speed and resource utilization of the system in high-concurrency mixed load scenarios.

[0085] To implement the above embodiments, the present invention also proposes a file system client kernel-user space communication device based on asynchronous communication. Figure 2 This is a schematic diagram illustrating the structure of a file system client kernel-user space communication device based on asynchronous communication, provided as an embodiment of the present invention. (See diagram below.) Figure 2 As shown, the device includes:

[0086] The event-driven publishing module 100 is used to publish asynchronous events in kernel space through a circular buffer based on the event-driven architecture, and to implement lock-free queue management using CAS operations;

[0087] The asynchronous listening and batch processing module 200 is used by the user-space daemon to listen for asynchronous events through epoll or kqueue, and to merge multiple I / O requests into batches for processing, so as to reduce the number of context switches;

[0088] The zero-copy transfer module 300 is used to realize zero-copy data transfer between user mode and kernel mode through DMA and shared memory pool. User mode processes use mmap to map shared memory regions, and kernel mode submits data pointers through virtqueue.

[0089] The adaptive priority scheduling module 400 is used to dynamically adjust the processing weight of the adaptive priority queue according to the system load, and optimize the allocation of queue resources in real time through the PID controller to improve the response efficiency of high priority requests.

[0090] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0091] To implement the above embodiments, the present invention also proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method provided in the foregoing embodiments.

[0092] To implement the above embodiments, the present invention also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.

[0093] To implement the above embodiments, the present invention also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.

[0094] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in this invention all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0095] It should be noted that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. Furthermore, such collection / sharing should only be conducted after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes authorization of relevant user information before the user uses the function. In addition, any necessary steps must be taken to protect and safeguard access to such personal information data and ensure that others with access to personal information data comply with their privacy policies and procedures.

[0096] This invention is intended to provide implementation schemes for users to selectively prevent the use or access to personal information data. That is, this disclosure is intended to provide hardware and / or software to prevent or block access to such personal information data. Once personal information data is no longer needed, risks can be minimized by restricting data collection and deleting data. Furthermore, where applicable, such personal information can be de-identified to protect user privacy.

[0097] In the foregoing descriptions of the embodiments, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0098] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0099] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of the invention pertain.

[0100] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0101] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0102] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0103] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0104] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

[0105] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0106] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A file system client kernel-user space communication method based on asynchronous communication, characterized in that, include: S1, based on an event-driven architecture, publishes asynchronous events in kernel space through a circular buffer and uses CAS operations to implement lock-free queue management; S2, the user-space daemon listens for asynchronous events through epoll or kqueue, and merges multiple I / O requests into batches for processing, reducing the number of context switches; S3 achieves zero-copy data transfer between user mode and kernel mode through DMA and shared memory pool. User mode processes use mmap to map shared memory regions, and kernel mode submits data pointers through virtqueue. S4 dynamically adjusts the processing weight of the adaptive priority queue based on the system load, and optimizes the allocation of queue resources in real time through the PID controller to improve the response efficiency of high-priority requests.

2. The method as described in claim 1, characterized in that, The event-driven architecture, which publishes asynchronous events in kernel space via a circular buffer and utilizes CAS operations to implement lock-free queue management, also includes: S11, the circular buffer adopts a dual-pointer structure to record the positions of producers and consumers respectively, and implements lock-free event enqueueing and dequeueing through CAS operation; S12, the asynchronous event is generated through the Netlink or IOCTL interface, and event listeners are registered in user space through epoll / kqueue to realize asynchronous event notification and processing.

3. The method as described in claim 1, characterized in that, The user-space daemon listens for asynchronous events via epoll or kqueue, merging multiple I / O requests into batches for processing to reduce context switching. It also includes: S21, after receiving the event notification, the daemon process classifies the read event and the write event into different thread pool queues according to the event type; S22, when the threads in the thread pool process requests, they adopt a batch submission mechanism to merge multiple events into one processing unit, thereby reducing the overhead of thread waking up and scheduling.

4. The method as described in claim 1, characterized in that, The method of achieving zero-copy data transfer between user mode and kernel mode through DMA and shared memory pool, where user mode processes use mmap to map shared memory regions and kernel mode submits data pointers through virtqueue, also includes: S31, the shared memory pool pre-allocates contiguous physical memory pages and divides the memory into fixed-size blocks to reduce memory fragmentation; S32, the memory lifecycle is managed through reference counting and CAS atomic operations to ensure thread safety and resource reclamation efficiency during multi-process access.

5. The method as described in claim 1, characterized in that, Also includes: S5 implements an intelligent prefetching mechanism based on the LRU-K algorithm. By analyzing the access patterns of user-mode processes, it predicts subsequent requests and loads data into the cache in advance by an independent prefetching thread, thereby improving the hit rate of hot data and reducing cache pollution caused by occasional access.

6. A file system client kernel-user space communication device based on asynchronous communication, characterized in that, include: The event-driven publishing module is used to publish asynchronous events in kernel space through a circular buffer based on the event-driven architecture, and to implement lock-free queue management using CAS operations; The asynchronous listening and batch processing module is used by the user-space daemon to listen for asynchronous events through epoll or kqueue, and to merge multiple I / O requests into batches for processing, thereby reducing the number of context switches; The zero-copy transfer module is used to achieve zero-copy data transfer between user mode and kernel mode through DMA and shared memory pool. User mode processes use mmap to map shared memory regions, and kernel mode submits data pointers through virtqueue. The adaptive priority scheduling module is used to dynamically adjust the processing weight of the adaptive priority queue according to the system load. It optimizes the allocation of queue resources in real time through the PID controller to improve the response efficiency of high-priority requests.

7. The apparatus as claimed in claim 6, characterized in that, The event-driven publishing module is also used for: The circular buffer adopts a dual-pointer structure to record the positions of producers and consumers respectively, and uses CAS operation to realize lock-free event enqueueing and dequeueing; The asynchronous events are generated through the Netlink or IOCTL interface and event listeners are registered in user space via epoll / kqueue to achieve asynchronous event notification and processing.

8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-5.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-5.

10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1-5.

Citation Information

Cited By

  • AI accelerator optimization method and system based on multipath kernel software stack

    CN121681165A

  • An ai accelerator optimization method and system based on a multi-path kernel software stack

    CN121681165B