A system call method based on exchangeable attributes
By judging the request type and allocating appropriate kernel threads in system call preprocessing, combined with asynchronous programming and merged request processing, the problem of poor hardware utilization in traditional system call methods is solved, and efficient system call processing and performance improvement are achieved.
Patent Information
- Application Number
- CN202410975124.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-19
AI Technical Summary
Traditional system call methods lead to poor hardware utilization under system call-intensive workloads and affect application performance. Existing solutions have problems such as large kernel changes, security implications, and high development complexity.
Using a system call method based on exchangeable attributes, the system call preprocessing module receives the request and determines whether it is an IPC class or asynchronous processing, and allocates synchronous or asynchronous kernel threads for scheduling processing. Asynchronous processing uses asynchronous programming syntax and waiting mechanisms. Consolidate system call requests to improve efficiency.
It improves multi-core processor utilization and system execution efficiency, supports synchronous and asynchronous system calls, balances distribution and merge processing according to system call characteristics, and reduces communication overhead.
Smart Images

Figure CN118519707B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of operating systems, and in particular to a system calling method based on exchangeable attributes. Background Art
[0002] The traditional system call method mainly provides an entry through the kernel. When calling from user mode, the kernel is entered through machine instructions and corresponding registers to execute related function calls. It relies on a synchronous call model. Before the system call is completed, the application cannot execute in user mode, causing blocking. The main problem with the traditional system call method is that under some system call-intensive workloads, switching from user mode to kernel mode execution will destroy the locality of the application state. The destruction of locality will lead to poor hardware utilization and affect the performance of the application.
[0003] There are currently the following solutions to the above problems:
[0004] 1) In-kernel sandbox: allows application code to be executed in privileged state, reducing state switching during system calls. For example, eBPF (extended Berkeley Packet Filter, eBPF) allows developers to attach code to kernel trace points, and when the kernel executes to the trace point, the attached code is executed at the same time, for example, supporting direct processing of some data in kernel state, reducing data copying between user state and kernel state.
[0005] 2) Cross-kernel state solution: Move work unrelated to kernel work to user state to reduce the occurrence of system calls and improve execution efficiency. For example, the Data Platform Development Kit (DPDK) moves I / O device management to user state, and I / O requests are sent to the device through a shared ring buffer (managed by user state), eliminating the need for kernel involvement.
[0006] 3) User-mode penetration solution: Utilize software error isolation technology (SFI) to transparently translate user-mode code into kernel-safe instructions in an online (JIT) manner and execute them directly in the kernel, reducing the switching of system calls between the kernel and user mode, thereby achieving binary-level acceleration of high-frequency I / O applications.
[0007] The above methods have the following main problems: The in-kernel sandbox solution makes significant changes to the kernel and may affect the security of the kernel code. The eBPF method has high restrictions on the code. The kernel will verify whether the additional code meets the execution requirements before executing the additional code. When a false positive occurs, it will affect the execution of the application. The cross-kernel state solution requires asynchronous interaction with the buffer queue, which is not conducive to synchronous programming by developers. The user state penetration solution is only applicable to intensive IO scenarios, and the user state code needs to be put into the kernel for execution, which affects the security and reliability of the kernel code to a certain extent. Summary of the invention
[0008] The technical problem to be solved by the present invention is to provide a system calling method based on exchangeable attributes to improve the execution efficiency of the system.
[0009] The technical solution adopted by the present invention to solve the above technical problems is: a system call method based on exchangeable attributes, the system includes a user space and a kernel space, the user space includes a system call module, the kernel space includes a multi-core scheduling module, and the system call module includes a system call preprocessing module;
[0010] The method for the system call preprocessing module to perform system call preprocessing includes:
[0011] A system call request is received;
[0012] Determine whether it is an IPC system call, if so, perform message parsing; if not, determine whether it can be processed asynchronously;
[0013] After the message is parsed, it is determined whether it is an asynchronous system call; if so, it is submitted to the asynchronous submission queue; otherwise, it is submitted to the synchronous submission queue;
[0014] If asynchronous processing is possible, it is performed and then submitted to the asynchronous submission queue;
[0015] If asynchronous processing is not possible, submit it directly to the synchronous submission queue;
[0016] The synchronous submission queue and the asynchronous submission queue enter the kernel space and are scheduled by the multi-core scheduling module. The scheduling method includes:
[0017] Determine whether it comes from the synchronous submission queue; if so, assign a synchronous kernel thread;
[0018] If it is not from the synchronous submission queue, an asynchronous kernel thread is assigned; determine whether it is a system call with interchangeable execution order, and if so, perform balanced allocation based on the load of the corresponding asynchronous kernel thread;
[0019] If it is not a system call whose execution order can be exchanged, it is submitted in the same kernel;
[0020] System calls whose execution order can be interchanged are system calls that have no data sharing relationship with other system calls.
[0021] Preferably, in the scheduling processing method, if a kernel in the kernel space is already unloaded, the kernel steals the unexecuted system scheduling and has no data sharing relationship from the same type of kernel for execution.
[0022] Preferably, the asynchronous processing method includes:
[0023] Use asynchronous programming syntax to wrap the implementation part of the system call, annotate the return value with the future class, and immediately return the response identifier of the system call processing to the application module in the user space;
[0024] The submission part of the system call uses an asynchronous execution waiting method to enter the processor in the executor. The processor in the executor executes the task that pops up in the task queue. When the task cannot make progress, the scheduler suspends the task, puts it back into the task queue and sets the wake-up condition. When the socket module in the reactor receives the wake-up information that meets the wake-up condition, it wakes up the suspended task and notifies the processor in the executor to continue executing the awakened task. When the task is completed, the execution result is returned to the application module.
[0025] Preferably, synchronous system call merging is performed before the synchronous submission queue is submitted, and the method of merging synchronous system calls includes: merging IPC-type system calls therein, merging multiple IO requests generated within a process or between processes and continuous at a physical address into a single IO request for processing together.
[0026] Preferably, asynchronous system call merging is performed before the asynchronous submission queue is submitted, and the method for merging asynchronous system calls includes: merging multiple IO requests that are continuous at physical addresses generated within a process or between processes into a single IO request for processing together.
[0027] Preferably, after the kernel thread has processed the system call, the completed task is added to the shared memory corresponding to the completion queue, and the user-mode process in the user space obtains the system call return data in the completion queue.
[0028] The beneficial effects of the present invention are as follows: by adopting the method of the present invention, different kernel threads are used for processing synchronous system calls and asynchronous system calls, and support for synchronous system calls is retained without being limited by the type of system calls. By using the system call method based on the exchangeable attribute of the present invention, the system calls whose execution order is exchangeable and irrelevant to task data are evenly distributed according to the load of the corresponding asynchronous kernel threads; the system calls related to task data are submitted in the same kernel to achieve lower communication overhead, and the utilization rate of multi-core processors and the system execution efficiency are fully improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is the overall architecture diagram of the system of the present invention;
[0030] Figure 2 is a flow chart of a system call preprocessing method in the method of the present invention;
[0031] Figure 3 is a flow chart of the asynchronous processing method in the method of the present invention;
[0032] Figure 4 is a flow chart of allocation of system calls with interchangeable execution order in the method of the present invention;
[0033] Figure 5 It is a flow chart of the scheduling processing method in the method of the present invention. DETAILED DESCRIPTION
[0034] The present invention will now be described in further detail in conjunction with the accompanying drawings and preferred embodiments. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.
[0035] like Figure 1 As shown, a system call method based on exchangeable attributes, the system includes a user space and a kernel space, the user space includes a system call module, the kernel space includes a multi-core scheduling module, and the system call module includes a system call preprocessing module.
[0036] like Figure 2 As shown, the method for the system call preprocessing module to perform system call preprocessing includes:
[0037] A system call request is received;
[0038] Determine whether it is an IPC system call. If so, perform message parsing. If not, determine whether it can be processed asynchronously. IPC system calls are InterProcess Communication (IPC) system calls.
[0039] After the message is parsed, it is determined whether it is an asynchronous system call; if so, it is submitted to the asynchronous submission queue; otherwise, it is submitted to the synchronous submission queue;
[0040] If asynchronous processing is possible, it is performed and then submitted to the asynchronous submission queue;
[0041] If asynchronous processing is not possible, submit it directly to the synchronous submission queue.
[0042] For IPC system calls, after message parsing, synchronous system calls are submitted to the synchronous submission queue, and asynchronous system calls are submitted to the asynchronous submission queue. For non-IPC system calls, some system calls that can be processed asynchronously are processed asynchronously and then submitted to the asynchronous submission queue; system calls for process exit, such as sys_yield and sys_sleep, cannot be processed asynchronously.
[0043] like Figure 1 As shown, the synchronous submission queue and the asynchronous submission queue enter the kernel space and are scheduled by the multi-core scheduling module, such as Figure 5 As shown, the scheduling processing method includes:
[0044] Determine whether it comes from the synchronous submission queue; if so, assign a synchronous kernel thread;
[0045] If it is not from the synchronous submission queue, an asynchronous kernel thread is assigned; determine whether it is a system call with interchangeable execution order, and if so, perform balanced allocation based on the load of the corresponding asynchronous kernel thread;
[0046] If it is not a system call whose execution order can be exchanged, it is submitted in the same kernel;
[0047] System calls whose execution order can be interchanged are those that have no data sharing relationship with other system calls.
[0048] For asynchronous system calls whose execution order can be swapped, these system calls can be submitted to different asynchronous kernel threads. If the execution order is not swappable, they are submitted in the same kernel. For system calls whose execution order can be swapped, the execution order between system calls does not affect the final state of the system. For example, two read system calls can be swapped; two system calls that write to different memory addresses can be swapped; two system calls that open different files can be swapped, etc. Figure 4 In the example, for system call 1 and system call 2, if system call 1 and system call 2 are system calls with interchangeable execution order, they are evenly distributed according to the load of the corresponding asynchronous kernel thread; if system call 1 and system call 2 are not system calls with interchangeable execution order, they are submitted to the same kernel thread to achieve lower communication overhead.
[0049] Specifically, in an optional implementation manner, Figure 5 As shown, in the scheduling processing method, if a kernel in the kernel space is already unloaded, the kernel steals the system scheduling that has not been executed and has no data sharing relationship from the same type of kernel for execution.
[0050] Specifically, in an optional implementation manner, Figure 3 As shown, the asynchronous processing method includes:
[0051] Use asynchronous programming syntax (async syntax) to wrap the implementation part of the system call, annotate the return value with the Future category, and immediately return the response mark of the system call processing to the application module in the user space; in async syntax, asynchronous (async) functions are usually used in conjunction with awaitable (await) expressions. Use the async keyword to declare an asynchronous function, which will not be executed immediately, but will return an object that is waited for using the await keyword, and the category is Future; after the object that the await expression waits for is completed, the execution of the corresponding asynchronous function is paused and the processing result is returned; the Future category is an asynchronous calculation that can generate values;
[0052] The submission part of the system call uses the asynchronous execution waiting method (await mechanism) to enter the processor in the executor. The processor in the executor executes the task popped out of the task queue. When the task cannot make progress, the scheduler suspends the task, puts it back into the task queue and sets the wake-up condition. When the socket module in the reactor receives the wake-up information that meets the wake-up condition, it wakes up the suspended task and notifies the processor in the executor to continue executing the awakened task. When the task is completed, the execution result is returned to the application module. Await mechanism: A mechanism used in asynchronous computing to obtain the Future value of the waiting object. When an asynchronous function is declared using the async keyword, an object waited for by the await keyword is returned.
[0053] Specifically, in an optional implementation, synchronous system calls are merged before the synchronous submission queue is submitted, and the method for merging synchronous system calls includes: merging IPC-type system calls therein, merging multiple IO requests generated within or between processes and continuous at physical addresses into a single IO request for processing together. The synchronous submission queue allows the submission of multiple synchronous system calls, and merges the IPC-type system calls therein, thereby improving the processing efficiency of IO requests.
[0054] Specifically, in an optional implementation, asynchronous system call merging is performed before the asynchronous submission queue is submitted. The method of asynchronous system call merging includes: merging multiple IO requests that are continuous at the physical address generated within a process or between processes into a single IO request and processing them together, thereby improving the processing efficiency of the IO requests.
[0055] Specifically, in an optional implementation, after the kernel thread completes processing the system call, the completed task is added to the shared memory corresponding to the completion queue, and the user-mode process in the user space obtains the system call return data in the completion queue.
[0056] By adopting the method of the present invention, different kernel threads are used to process synchronous system calls and asynchronous system calls, and support for synchronous system calls is retained without being limited by the type of system calls. By adding asynchronous processing to the system call preprocessing, support for asynchronization is provided without changing the synchronous programming logic of programmers. Through the system call method based on the exchangeable attribute of the present invention, the execution order of the system calls that are not related to task data and can be exchanged are evenly distributed according to the load of the corresponding asynchronous kernel thread; for the system calls related to task data, they are submitted in the same kernel to achieve lower communication overhead, fully improving the utilization rate of multi-core processors and the system execution efficiency.
[0057] The above description only describes the specific implementation mode of the present invention. Various examples do not limit the essential content of the present invention. After reading the description, ordinary technicians in the relevant technical field can modify or deform the specific implementation modes described above without departing from the essence and scope of the invention.
Claims
1. A system call method based on exchangeable properties, Features: The system includes a user space and a kernel space, the user space includes a system call module, the kernel space includes a multi-core scheduling module, and the system call module includes a system call preprocessing module; The method for the system call preprocessing module to perform system call preprocessing includes: A system call request is received; Determine whether it is an IPC system call, if so, perform message parsing; if not, determine whether it can be processed asynchronously; After the message is parsed, it is determined whether it is an asynchronous system call; if so, it is submitted to the asynchronous submission queue; otherwise, it is submitted to the synchronous submission queue; If asynchronous processing is possible, it is performed and then submitted to the asynchronous submission queue; If asynchronous processing is not possible, submit it directly to the synchronous submission queue; The synchronous submission queue and the asynchronous submission queue enter the kernel space and are scheduled by the multi-core scheduling module. The scheduling method includes: Determine whether it comes from the synchronous submission queue; if so, assign a synchronous kernel thread; If it is not from the synchronous submission queue, an asynchronous kernel thread is assigned; determine whether it is a system call with interchangeable execution order, and if so, perform balanced allocation based on the load of the corresponding asynchronous kernel thread; If it is not a system call whose execution order can be exchanged, it is submitted in the same kernel; System calls whose execution order can be interchanged are: system calls that have no data sharing relationship with other system calls; The asynchronous processing method includes: Use asynchronous programming syntax to wrap the implementation part of the system call, annotate the return value with the future class, and immediately return the response identifier of the system call processing to the application module in the user space; The submission part of the system call uses an asynchronous execution waiting method to enter the processor in the executor. The processor in the executor executes the task that pops up in the task queue. When the task cannot make progress, the scheduler suspends the task, puts it back into the task queue and sets the wake-up condition. When the socket module in the reactor receives the wake-up information that meets the wake-up condition, it wakes up the suspended task and notifies the processor in the executor to continue executing the awakened task. When the task is completed, the execution result is returned to the application module.
2. A system call method based on exchangeable attributes according to claim 1, Features: In the scheduling processing method, if a kernel in the kernel space is already unloaded, the kernel steals the unexecuted system scheduling from the kernel of the same type and has no data sharing relationship for execution.
3. A system call method based on exchangeable attributes according to claim 1, Features: Synchronous system calls are merged before the synchronous submission queue is submitted. The method of merging synchronous system calls includes: merging IPC-type system calls therein, merging multiple IO requests generated within a process or between processes and continuous on a physical address into a single IO request for processing together.
4. A system call method based on exchangeable attributes according to claim 1, Features: Asynchronous system call merging is performed before the asynchronous submission queue is submitted. The method for merging the asynchronous system call includes: merging multiple IO requests that are continuous at physical addresses generated within a process or between processes into a single IO request for processing together.
5. A system call method based on exchangeable attributes according to claim 1, Features: When the kernel thread completes processing the system call, it adds the completed task to the shared memory corresponding to the completion queue, and the user-mode process in the user space obtains the system call return data in the completion queue.
Citation Information
Patent Citations
Design scheme of message service module supporting kernel module isolation
CN108875381A
Coroutine-based asynchronous system calling system
CN111767159A
Asynchronous communication method and system supporting load balancing strategy, medium and equipment
CN115412500A
System, method and medium for providing asynchronous input and output with less system calls to and from an operating system
US20060184948A1
Method and apparatus for using a 32-bit operating system kernel to support 64-bit applications
US20080034194A1
