Data access method and apparatus, device, storage medium, and program product

By setting up a shared memory metadata buffer on the processor core and directly switching threads to handle data access requests, the problem of low data access efficiency in computer devices is solved, achieving more efficient data transfer and reduced latency.

WO2026157225A1PCT designated stage Publication Date: 2026-07-30HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2025-08-27
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

In existing technologies, computer devices have low data access efficiency, especially under high load or multi-threaded conditions, with issues of scheduling delay and memory overhead.

Method used

By setting a target metadata buffer on the target processor core, making it a shared memory area for the first and second threads, the system can directly store and read requested metadata, and directly switch to the second thread for processing after the first thread triggers a data access request, thus avoiding the waiting time and data copying in traditional scheduling mechanisms.

Benefits of technology

It significantly improves data access efficiency, reduces thread scheduling and data transmission latency, lowers memory overhead, and simplifies thread management complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025117229_30072026_PF_FP_ABST
    Figure CN2025117229_30072026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computers, and discloses a data access method and apparatus, a device, a storage medium, and a program product. The method comprises: in response to a data access request triggered by a first thread, storing request metadata in a target metadata buffer; switching the thread running on a target processor core from the first thread to a second thread; and acquiring the request metadata from the target metadata buffer, and processing the data access request by means of the second thread on the basis of the request metadata. In the present application, upon triggering the data access request, the first thread can directly store the request metadata in the buffer, and the second thread can directly read data from the buffer without performing data copying, thereby effectively reducing memory overhead and improving data transfer efficiency. In addition, the thread running on the target processor core can be directly switched from the first thread to the second thread, thereby avoiding the waiting time in traditional scheduling mechanisms, and significantly improving data access efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Data access methods, devices, equipment, storage media and software products

[0001] This application claims priority to Chinese Patent Application No. 202510123641.4, filed on January 24, 2025, entitled “Data Access Method, Apparatus, Device, Storage Medium and Program Product”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of computer technology, and in particular to a data access method, apparatus, device, storage medium, and program product. Background Technology

[0003] In computer devices, software used to organize, store, and access data is called a file management system (or simply a file system). In other words, a file system is a system that organizes, allocates, stores files, protects, and retrieves stored files within the storage space of a computer device. For example, a file system can create files, store data in files, read data from files, modify data in files, transfer files, and control file access, etc. Currently, threads in computer devices can access data in storage devices through the file system, but this data access method is inefficient. Therefore, there is an urgent need for a data access method to improve data access efficiency. Summary of the Invention

[0004] This application provides a data access method, apparatus, device, storage medium, and program product, which can solve the problem of low data access efficiency in related technologies. The technical solution is as follows:

[0005] Firstly, a data access method is provided, applied to a computer device, the computer device including a target processor core, on which a first thread runs, and the target processor core also corresponding to a second thread, wherein the first thread is a thread of an application program on the computer device, and the second thread is a thread of a file system service program on the computer device; the method includes:

[0006] In response to a data access request triggered by the first thread, request metadata is stored in a target metadata buffer. The data access request indicates that a target operation be performed on a target file in the computer device. The request metadata includes descriptive information of the data access request. The target metadata buffer is a memory area shared by the first thread and the second thread. The thread running on the target processor core is switched from the first thread to the second thread. The request metadata is retrieved from the target metadata buffer, and the data access request is processed by the second thread based on the request metadata.

[0007] Since the target metadata buffer is a shared memory area for both the first and second threads, the first thread can directly store the requested metadata into this buffer after triggering a data access request. The second thread can then directly read the data from it without copying it, effectively reducing memory overhead and improving data transfer efficiency. Furthermore, this application can also switch the thread running on the target processor core directly from the first thread to the second thread after the first thread triggers a data access request, avoiding the waiting time in traditional scheduling mechanisms. This allows for rapid response to data access requests, significantly improving data access efficiency. In addition, the second thread (i.e., the file system service program thread) in this application is the thread corresponding to the target processor core. Each processor core in the computer device is bound to a corresponding second thread, ensuring that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transfer latency can be significantly reduced. Moreover, since each processor core has a corresponding file system service program thread, the operating system kernel does not need to handle thread scheduling between different cores, reducing the complexity of thread management.

[0008] In one possible implementation, a data access request can be triggered when the first thread in user mode needs to access data through a file system service program.

[0009] In one possible implementation, the data access request function is a kernel-mode function. Therefore, after the first thread in user mode calls the data access request function, the first thread will switch from user mode to kernel mode. During the switching process, the context of the first thread in user mode will be saved so that when the first thread is switched back to user mode, the first thread can execute subsequent tasks accurately.

[0010] In one possible implementation, before storing the requested metadata in the target metadata buffer in response to a data access request triggered by the first thread, the computer device can also store the context of the second thread, which indicates the thread's runtime environment. In this case, the process of switching the thread running on the target processor core from the first thread to the second thread includes: storing the context of the first thread, and running the second thread on the target processor core based on the context of the second thread.

[0011] It's important to note that thread context is a core concept in multithreaded programming. It refers to the execution state of a thread at a given moment. This state contains all the crucial information necessary for the thread to run, allowing it to resume its execution state when needed. This crucial information includes register values, the program counter, the stack pointer, and stack contents. CPU registers store intermediate data, addresses, and instruction counts related to thread execution. These register values ​​reflect the thread's computational state and instruction execution progress at a given moment. The program counter indicates the location of the next instruction the current thread will execute. The thread's call stack stores the state of function calls, including local variables and return addresses. The stack pointer points to the current top of the stack, while the stack contents record the sequence of function calls generated during thread execution.

[0012] The operating system kernel can store the context of the first thread in kernel mode and run the second thread directly on the target processor core based on the context of the second thread. In other words, this application can directly switch the first thread to the second thread when performing thread switching, thereby avoiding the waiting time in traditional scheduling mechanisms. In this way, data access requests can be responded to quickly, thus significantly improving the efficiency of data access.

[0013] In one possible implementation, before storing the context of the second thread, the computer device can also initialize the file system service program, that is, load the file system service program and create a second thread for the target processor core, thereby allocating a target metadata buffer for the target processor core.

[0014] In one possible implementation, the computer device includes at least one processor core, and the at least one processor core includes a target processor core. In this case, during the loading of the file system service program, at least one thread of the file system service program is created based on the number of at least one processor, and a correspondence is established between the at least one file system service program thread and the at least one processor. Furthermore, for any thread of the at least one file system service program, a metadata buffer can be allocated in the memory of the computing device when the thread begins execution. Thus, each thread of the at least one file system service program is processed in the same way to obtain at least one metadata buffer. Therefore, each at least one processor core in the computer device corresponds to one thread of the file system service program, and the computer's memory also contains a metadata buffer allocated for each processor core.

[0015] In the computer device of this application, each processor core is bound to a corresponding second thread. This ensures that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transfer latency can be significantly reduced. Furthermore, because each processor core has a corresponding file system service thread, the operating system kernel does not need to handle thread scheduling between different cores, thus reducing the complexity of thread management.

[0016] In one possible implementation, after the file system service program is initialized, the second thread is in user mode. In this case, the computer device can store the context of the second thread in user mode and switch the second thread to kernel mode. Furthermore, the computer device can also store the context of the second thread in kernel mode and suspend the execution of the second thread.

[0017] It is understandable that, since the stored context of the second thread is the context of the second thread in kernel mode, the above implementation process of storing the context of the first thread and running the second thread directly on the target processor core based on the context of the second thread is as follows: storing the context of the first thread in kernel mode, and running the kernel-mode second thread directly on the target processor core based on the context of the second thread in kernel mode.

[0018] In one possible implementation, the process of retrieving the requested metadata from the target metadata buffer includes: a second thread in kernel mode retrieves the requested metadata from the target metadata buffer.

[0019] In one possible implementation, the target operation can be a read operation or a write operation. In different cases, the implementation method of processing the data access request through a second thread based on the request metadata will be different, which will be introduced separately below.

[0020] In the first scenario, the target operation is a read operation. The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target data is the data that the first thread needs to read from the target file, and the target virtual address is the virtual base address corresponding to the memory region used to store the read target data. In this case, based on the file descriptor, the second thread in user mode determines the file virtual address, which is the virtual base address for performing the target operation on the target file. Based on the file virtual address, the target virtual address, and the size of the target data, a first physical address range and a first virtual address range are determined. The first physical address range is the physical address range corresponding to the storage location of the target data, and the first virtual address range is the virtual address range corresponding to the memory region used to store the read target data. A mapping relationship between the first physical address range and the first virtual address range is added to the page table of the first thread, and it is determined that the second thread's processing operation for the data access request has been completed.

[0021] Currently, when a file system service program handles a read operation, it reads the target data from the target file and copies it to the physical address range corresponding to the first virtual address range allocated by the application for storing the target data. The application can then retrieve the target data based on the first virtual address range. However, this method requires multiple copies of the target data, resulting in significant memory overhead. This application, however, can directly add the mapping relationship between the first physical address range and the first virtual address range to the page table corresponding to the application's thread. The application's thread can directly access the target data through the first virtual address range; that is, data reading is achieved by modifying the page table without data copying. This greatly reduces memory pressure and improves data access efficiency.

[0022] The process of determining the first physical address range and the first virtual address range based on the file virtual address, the target virtual address, and the size of the target data includes: taking the target virtual address as the minimum value of the first virtual address range, and taking the sum of the target virtual address and the size of the target data as the maximum value of the first virtual address range; determining the file physical address corresponding to the file virtual address based on the file virtual address, wherein the file physical address is the physical base address for performing the target operation on the target file, taking the file physical address as the minimum value of the first physical address range, and taking the sum of the file physical address and the size of the target data as the maximum value of the first physical address range.

[0023] In one possible implementation, after the second thread processes the data access request based on the request metadata, the processing result of the data access request can be written to the target metadata buffer by the second thread in kernel mode. The processing result indicates whether the processing operation of the data access request by the second thread has been completed. The thread running on the target processor core is switched from the second thread to the first thread. The processing result is obtained from the target metadata buffer area by the first thread in kernel mode. If the processing result indicates that the processing operation of the data access request by the second thread has been completed, the target data is read by the first thread in user mode based on the first virtual address range and the page table of the first thread.

[0024] In one possible implementation, before adding the mapping between the first physical address range and the first virtual address range to the page table of the first thread, the computer device can also determine whether the size of the target data is an integer multiple of the memory page size. If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping between the first physical address range and the first virtual address range to the page table of the first thread is executed, where the memory page is the smallest unit of memory management for the computer device.

[0025] A memory page is a fixed-size block of data used by the operating system to allocate and manage physical memory. It is the basic unit of memory management; by dividing memory into fixed-size pages, the operating system can manage and allocate memory resources more efficiently. The size of a memory page is typically a power of 2, such as 4 kilobytes (KB), 8KB, 16KB, etc., with the specific size depending on the operating system and hardware architecture. When the size of the target data is an integer multiple of the memory page size, it ensures that the data completely occupies an integer number of memory pages and does not cross multiple memory page boundaries. Therefore, after adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, the first thread cannot access data other than the target data, thus effectively protecting data security.

[0026] In the second scenario, the target operation is a write operation. The requested metadata includes the target file's file descriptor, the size of the target data, and the target virtual address. The target data is the data that the first thread needs to write to the target file, and the target virtual address is the virtual base address corresponding to the memory region currently used to store the target data. In this case, based on the file descriptor, the second thread in user mode determines the file virtual address, which is the virtual base address for performing the target operation on the target file. Based on the file virtual address, the target virtual address, and the size of the target data, a second physical address range and a second virtual address range are determined. The second physical address range is the physical address range corresponding to the memory region currently used to store the target data, and the second virtual address range is the virtual address range corresponding to the memory region used to write the target data. The mapping relationship between the second physical address range and the second virtual address range is added to the second thread's page table, and it is confirmed that the second thread's processing operation for the data access request has been completed.

[0027] Currently, when handling write operations, file system service programs read the target data from the second physical address range and copy it to the corresponding location in the target file. This method requires multiple copies of the target data, resulting in significant memory overhead. This application, however, can directly add the mapping relationship between the second physical address range and the second virtual address range to the page table corresponding to the thread of the user-mode file system service program, without performing data copying. Data writing is achieved by modifying the page table, thus greatly reducing memory pressure and improving data access efficiency.

[0028] The process of determining the second physical address range and the second virtual address range based on the file virtual address, the target virtual address, and the size of the target data includes: using the file virtual address as the minimum value of the second virtual address range, and using the sum of the file virtual address and the size of the target data as the maximum value of the second virtual address range; determining the target physical address corresponding to the target virtual address based on the target virtual address, where the target physical address is the physical base address corresponding to the memory region currently used to store the target data, using the target physical address as the minimum value of the second physical address range, and using the sum of the target physical address and the size of the target data as the maximum value of the second physical address range.

[0029] It should be noted that this application modifies the page table corresponding to the second thread during write operations, allowing both the first and second threads to access the second physical address range through their own page tables; similarly, it modifies the page table corresponding to the first thread during read operations, allowing both the first and second threads to access the first physical address range through their own page tables. In this scenario, the first and second physical address ranges become shared physical addresses for both threads (i.e., both threads can perform write operations on the shared physical addresses). If both threads write data to these shared physical addresses via memory write operations, data conflicts will occur. Therefore, if data is written to a physical address range mapped by the page tables of multiple threads via memory write operations, a copy-on-write method must be used to avoid data conflicts.

[0030] In one possible implementation, after the data access request is processed by the second thread based on the request metadata, the processing result of the data access request can be written to the target metadata buffer by the second thread in kernel mode. The processing result indicates whether the processing operation of the data access request by the second thread has been completed. The thread running on the target processor core is switched from the second thread to the first thread. The processing result is obtained from the target metadata buffer area by the first thread in kernel mode.

[0031] In one possible implementation, before adding the mapping between the second physical address range and the second virtual address range to the page table of the second thread, the computer device can also determine whether the size of the target data is an integer multiple of the memory page size. If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping between the second physical address range and the second virtual address range to the page table of the second thread is performed, where the memory page is the smallest unit of memory management for the computer device.

[0032] When the size of the target data is an integer multiple of the memory page size, it can be ensured that the data completely occupies an integer number of memory pages and will not cross multiple memory page boundaries. Therefore, after adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, the first thread cannot access data other than the target data, thus effectively protecting data security.

[0033] Secondly, a data access device is provided, which has the function of implementing the data access method behavior described in the first aspect. The data access device includes at least one module for implementing the data access method provided in the first aspect.

[0034] Thirdly, a computer device is provided, comprising a processor and a memory, the memory being used to store a computer program for executing the data access method provided in the first aspect. The processor is configured to execute the computer program stored in the memory to implement the data access method described in the first aspect.

[0035] Optionally, the computer device may further include a communication bus for establishing a connection between the processor and the memory.

[0036] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is run on a computer or processor, the computer or processor performs the steps of the data access method described in the first aspect.

[0037] Fifthly, a computer program product is provided, comprising computer instructions that, when executed on a computer or processor, cause the computer to perform the steps of the data access method described in the first aspect. Alternatively, a computer program is provided that, when executed on a computer or processor, causes the computer or processor to perform the steps of the data access method described in the first aspect.

[0038] The technical effects achieved by the second, third, fourth, and fifth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect, and will not be repeated here. Attached Figure Description

[0039] Figure 1 is a schematic diagram of an implementation environment provided in an embodiment of this application;

[0040] Figure 2 is a schematic diagram of a computer device provided in an embodiment of this application;

[0041] Figure 3 is a schematic diagram of another computer device provided in an embodiment of this application;

[0042] Figure 4 is a flowchart of a data access method provided in an embodiment of this application;

[0043] Figure 5 is a schematic diagram of a fuse kernel module provided in an embodiment of this application;

[0044] Figure 6 is a schematic diagram of the structure of a data access device provided in an embodiment of this application. Detailed Implementation

[0045] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0046] To facilitate understanding, before providing a detailed explanation of the data access methods provided in the embodiments of this application, the terms, application scenarios, and implementation environments involved in the embodiments of this application will be introduced first.

[0047] First, the terms used in the embodiments of this application will be introduced.

[0048] Context switching: In a computer system, context switching is the process by which the operating system switches the current processor from one process or thread to another for execution. During this process, the operating system needs to save the current thread's state (i.e., context), which includes register contents, program counter, memory management information, etc., and then load the state (i.e., context) of the next thread.

[0049] Page Table: In a computer system, the page table is an important data structure in the operating system used to manage virtual memory. It maps the virtual address space to physical memory addresses. Each thread has its own page table, which helps the operating system manage memory and provide memory protection.

[0050] User-space file system: In a computer system, a user-space file system refers to a file system that performs file system functions in user space, that is, it creates and manages file system data and provides file system services in user space without modifying the kernel code.

[0051] The application scenarios involved in the embodiments of this application will be introduced next.

[0052] In computer devices, the software used to organize, store, and access data is called a file management system (or simply file system). In other words, a file system is a system that organizes, allocates, stores files, protects, and retrieves stored files within the storage space of a computer device. Most traditional file systems are implemented in kernel mode, meaning the file system is part of the operating system kernel and acquires and processes data in kernel mode. However, with the emergence of new applications such as artificial intelligence and big data, there is often a need for customized file system development to meet the requirements of these new applications. Furthermore, with the emergence of high-performance storage devices, new file systems need to be developed to fully utilize their high-performance characteristics. However, due to the inherent complexity of kernel development, which can easily lead to serious problems such as system crashes and is difficult to maintain later, and because some new hardware is not well-suited to kernel file systems, developing and modifying kernel file systems is extremely challenging.

[0053] To meet the file system requirements of new applications and devices, user-space file systems are currently commonly used for data acquisition and processing. That is, application threads can send data access requests to the user-space file system driver deployed in the operating system kernel. The user-space file system driver then forwards these requests to the corresponding user-space file system service thread. In other words, the user-space file system service thread is responsible for file creation, deletion, reading, and writing operations, and interacts with the user-space file system driver in the kernel through system call interfaces. Because the user-space file system service thread runs in user space, developing file system functionality does not require kernel modification. Furthermore, the rich programming languages ​​and library resources available in user space can be utilized, making development, debugging, and testing more convenient and efficient. In addition, programming errors in user-space development rarely lead to serious problems such as system crashes, and user-space file systems are easier to port between different operating systems compared to kernel file systems.

[0054] However, in the above scheme, after the application thread triggers a data access request, the operating system kernel needs to schedule the user-mode file system program thread to run through the scheduling mechanism. In this scheduling mechanism, the operating system kernel does not directly switch to the user-mode file system program thread to process the data after the application triggers a data access request. Instead, it adds the user-mode file system program thread to the scheduling queue and selects the thread in the scheduling queue to run based on the priority and other information of each thread. In this case, it will cause a certain degree of scheduling delay, especially when the system load is high or the number of threads is large, which will cause the application to wait for too long, resulting in poor data access efficiency. Furthermore, since the user-mode file system program's thread needs to process the corresponding file based on the information carried in the data access request, but the application thread and the user-mode file system program's thread each correspond to different memory spaces that are not interconnected, the application thread and the user-mode file system service program's thread transfer data (i.e., transfer the information carried in the data access request). In other words, the information carried in the data access request is copied from the memory space corresponding to the application thread to the memory space corresponding to the user-mode file system service program's thread for subsequent data processing. However, this method will increase memory overhead.

[0055] Based on this, embodiments of this application provide a data access method that, in response to a data access request triggered by a first thread, stores request metadata in a target metadata buffer, switches the thread running on the target processor core from the first thread to a second thread, retrieves the request metadata from the target metadata buffer, and processes the data access request based on the request metadata through the second thread. Since the target metadata buffer is a shared memory area of ​​the first and second threads, the first thread can directly store the request metadata in the buffer after triggering a data access request, and the second thread can directly read the data from it without data copying. This effectively reduces memory overhead and improves data transfer efficiency. Furthermore, embodiments of this application can also directly switch the thread running on the target processor core from the first thread to the second thread after triggering a data access request by the first thread, avoiding the waiting time in traditional scheduling mechanisms. This method enables rapid response to data access requests, thereby significantly improving data access efficiency. In addition, in this embodiment, the second thread (i.e., the thread of the file system service program) is the thread corresponding to the target processor core. That is, each processor core in the computer device is bound to a corresponding second thread. This ensures that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transmission latency can be significantly reduced. Furthermore, because each processor core has a corresponding file system service program thread, the operating system kernel does not need to handle thread scheduling between different cores, thus reducing the complexity of thread management.

[0056] The implementation environment involved in the embodiments of this application will be described next.

[0057] Please refer to Figure 1, which is a schematic diagram of an implementation environment provided in an embodiment of this application. This implementation environment includes a computer device 01, which includes a target processor core 11, and a first thread 111 runs on the target processor core. The first thread is a thread of an application program on the computer device. The target processor core also has a corresponding second thread 112, which is a thread of a file system service program on the computer device.

[0058] Computer device 01 is able to respond to a data access request triggered by the first thread, store the request metadata in the target metadata buffer, the data access request instructs to perform a target operation on a target file in the computer device, the request metadata includes descriptive information of the data access request, the target metadata buffer is a memory area shared by the first thread and the second thread; switch the thread running on the target processor core from the first thread to the second thread; retrieve the request metadata from the target metadata buffer, and process the data access request through the second thread based on the request metadata.

[0059] In other embodiments, please refer to FIG2, which is a schematic diagram of a computer device provided in an embodiment of this application. The computer device includes a software layer and a hardware layer. The software layer includes a scheduling-free fast switching unit 201, a metadata management unit 202, and a page table management unit 203. The hardware layer includes a target processor 204 and memory 205.

[0060] During the execution of the data access method of the target processor 204, the metadata management unit 202 is used to respond to the data access request triggered by the first thread and store the requested metadata in the target metadata buffer in the memory 205. The scheduling-free fast switching unit 201 is used to switch the thread running on the target processor core from the first thread to the second thread, or switch the thread running on the target processor core from the second thread to the first thread.

[0061] In one possible implementation, the requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a read operation, the target data is the data that the first thread needs to read from the target file, and the target virtual address refers to the virtual base address corresponding to the memory region used to store the read target data. In this case, the computer device can determine the file virtual address based on the file descriptor through a second thread in user mode; determine the first physical address range and the first virtual address range based on the file virtual address, the target virtual address, and the size of the target data; and add the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread through the page table management unit 203, and determine that the processing operation of the data access request by the second thread has been completed.

[0062] In another possible implementation, the requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a write operation, the target data is the data that the first thread needs to write to the target file, and the target virtual address refers to the virtual base address corresponding to the memory region currently used to store the target data. In this case, the computer device can also determine the file virtual address based on the file descriptor by a second thread in user mode; determine the second physical address range and the second virtual address range based on the file virtual address, the target virtual address, and the size of the target data; and add the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread through the page table management unit 203, and determine that the processing operation of the data access request by the second thread has been completed.

[0063] In other embodiments, the software layer also includes a thread management unit 206, in which case the thread management unit 206 is able to load a file system service program, create a second thread for the target processor core, and allocate a target metadata buffer for the target processor core.

[0064] In one possible implementation, the computer device includes at least one processor core, and the at least one processor core includes a target processor core. In this case, during the loading of the file system service program, the thread management unit 206 can create at least one thread of the file system service program based on the number of at least one processor, and establish a correspondence between the at least one thread of the file system service program and the at least one processor. Furthermore, for any one thread of the at least one file system service program, when the thread begins execution, a metadata buffer can be allocated for that thread in the memory of the computing device. Thus, each thread of the at least one file system service program is processed in the same way, thereby obtaining at least one metadata buffer.

[0065] It is understood that the execution subject of the embodiments of this application is a computer device, or in other words, the operating system kernel in the computer device. The computer device may be a server, a personal computer (PC), a mobile phone, a smartphone, a personal digital assistant (PDA), a wearable device, a handheld PC (PPC), a tablet computer, a smart car system, a smart TV, a smart speaker, etc.

[0066] Please refer to Figure 3, which is a schematic diagram of another computer device according to an embodiment of this application. This computer device may be the computer device 101 shown in Figure 1. The computer device includes at least one processor 301, a communication bus 302, a memory 303, and at least one communication interface 304.

[0067] Processor 301 can be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, or one or more integrated circuits for implementing the solutions of this application, such as application-specific integrated circuits (ASICs), programmable logic devices (PLDs), or combinations thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0068] The communication bus 302 is used to transmit information between the aforementioned components. The communication bus 302 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, it is represented by only one thick line in the figure, but this does not indicate that there is only one bus or one type of bus.

[0069] The memory 303 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile optical disc, a Blu-ray disc, etc.), a magnetic disk storage medium, or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but not limited thereto. The memory 303 may exist independently and be connected to the processor 301 via a communication bus 302. Alternatively, the memory 303 may be integrated with the processor 301.

[0070] Communication interface 304 uses any transceiver-like device for communicating with other devices or communication networks. Communication interface 304 includes a wired communication interface and may also include a wireless communication interface. The wired communication interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless communication interface may be a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.

[0071] In a specific implementation, as one example, processor 301 may include one or more CPUs, such as CPU0 and CPU1 as shown in FIG3.

[0072] In a specific implementation, as one embodiment, the computer device may include multiple processors, such as processor 301 and processor 305 as shown in FIG3. Each of these processors may be a single-core processor or a multi-core processor. Here, a processor may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0073] In a specific implementation, as one embodiment, the computer device may further include an output device 306 and an input device 307. The output device 306 communicates with the processor 301 and can display information in various ways. For example, the output device 306 may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 307 communicates with the processor 301 and can receive user input in various ways. For example, the input device 307 may be a mouse, a keyboard, a touchscreen device, or a sensing device, etc.

[0074] In some embodiments, memory 303 is used to store program code 310 for executing the scheme of this application, and processor 301 can execute program code 310 stored in memory 303. The program code 310 may include one or more software modules, and the computer device can implement the data access method provided in the embodiment of FIG4 below through processor 301 and program code 310 in memory 303.

[0075] Those skilled in the art should understand that the above-described computer devices are merely examples, and other existing or future computer devices that are applicable to the embodiments of this application should also be included within the scope of protection of the embodiments of this application, and are hereby incorporated by reference.

[0076] It should be noted that the application scenarios and implementation environments described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0077] Figure 4 is a flowchart of a data access method provided in an embodiment of this application. The method is applied to a computer device, which includes a target processor core. A first thread runs on the target processor core, and a second thread also runs on the target processor core. The first thread is a thread of an application program on the computer device, and the second thread is a thread of a file system service program on the computer device. Referring to Figure 4, the method includes the following steps.

[0078] Step 401: In response to the data access request triggered by the first thread, store the request metadata in the target metadata buffer. The data access request indicates that a target operation be performed on the target file in the computer device. The request metadata includes a description of the data access request. The target metadata buffer is a memory area shared by the first thread and the second thread.

[0079] In some embodiments, the target operation may be a read operation, a write operation, a file deletion operation, a file search operation, a file opening operation, a file closing operation, etc., and this application does not limit it.

[0080] In some embodiments, a data access request can be triggered when a first thread in user mode needs to access data through a file system service. For example, the first thread in user mode can trigger a data access request by calling a data access request function, passing the requested metadata as a parameter to the function.

[0081] In some embodiments, the data access request function is a kernel-mode function. Therefore, after the first thread in user mode calls the data access request function, the first thread will switch from user mode to kernel mode. During the switching process, the context of the first thread in user mode will be saved so that when the first thread is switched back to user mode, the first thread can execute subsequent tasks accurately.

[0082] As an example, in response to a data access request triggered by the first thread in user mode, the first thread descends from user mode to kernel mode, and then the first thread in kernel mode stores the requested metadata into the target metadata buffer.

[0083] Understandably, in the field of computer technology, regardless of the type of thread, any action performed by that thread in kernel mode can be considered as being executed by the operating system kernel.

[0084] Step 402: Switch the thread running on the target processor core from the first thread to the second thread.

[0085] In some embodiments, before storing the requested metadata in the target metadata buffer in response to a data access request triggered by the first thread, the computer device may also store the context of the second thread, which indicates the thread's runtime environment. In this case, the process of switching the thread running on the target processor core from the first thread to the second thread includes: storing the context of the first thread and running the second thread on the target processor core based on the context of the second thread.

[0086] It's important to note that thread context is a core concept in multithreaded programming. It refers to the execution state of a thread at a given moment. This state contains all the crucial information necessary for the thread to run, allowing it to resume its execution state when needed. This crucial information includes register values, the program counter, the stack pointer, and stack contents. CPU registers store intermediate data, addresses, and instruction counts related to thread execution. These register values ​​reflect the thread's computational state and instruction execution progress at a given moment. The program counter indicates the location of the next instruction the current thread will execute. The thread's call stack stores the state of function calls, including local variables and return addresses. The stack pointer points to the current top of the stack, while the stack contents record the sequence of function calls generated during thread execution.

[0087] For example, the operating system kernel can store the context of the first thread in kernel mode and run the second thread on the target processor core based on the context of the second thread. In other words, in this embodiment of the application, when switching threads, the first thread can be directly switched to the second thread, thereby avoiding the waiting time in traditional scheduling mechanisms. In this way, data access requests can be responded to quickly, thus significantly improving the efficiency of data access.

[0088] In some embodiments, before storing the context of the second thread, the computer device may also initialize a file system service program, that is, load the file system service program and create a second thread for the target processor core, thereby allocating a target metadata buffer for the target processor core.

[0089] In one possible implementation, the computer device includes at least one processor core, and the at least one processor core includes a target processor core. In this case, during the loading of the file system service program, at least one thread of the file system service program is created based on the number of at least one processor, and a correspondence is established between the at least one file system service program thread and the at least one processor. Furthermore, for any thread of the at least one file system service program, a metadata buffer can be allocated in the memory of the computing device when the thread begins execution. Thus, each thread of the at least one file system service program is processed in the same way to obtain at least one metadata buffer. Therefore, each at least one processor core in the computer device corresponds to one thread of the file system service program, and the computer's memory also contains a metadata buffer allocated for each processor core.

[0090] In the computer device of this application embodiment, each processor core is bound to a corresponding second thread. This ensures that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transmission latency can be significantly reduced. Furthermore, because each processor core has a corresponding file system service thread, the operating system kernel does not need to handle thread scheduling between different cores, thus reducing the complexity of thread management.

[0091] In some embodiments, after the file system service program is initialized, the second thread is in user mode. In this case, the computer device can store the context of the second thread in user mode and switch the second thread to kernel mode. Furthermore, the computer device can also store the context of the second thread in kernel mode and suspend the execution of the second thread.

[0092] It is understandable that, since the stored context of the second thread is the context of the second thread in kernel mode, the above implementation process of storing the context of the first thread and running the second thread directly on the target processor core based on the context of the second thread is as follows: storing the context of the first thread in kernel mode, and running the kernel-mode second thread directly on the target processor core based on the context of the second thread in kernel mode.

[0093] Step 403: Obtain the request metadata from the target metadata buffer, and process the data access request through a second thread based on the request metadata.

[0094] In some embodiments, the process of obtaining request metadata from the target metadata buffer includes: a second thread in kernel mode obtaining request metadata from the target metadata buffer.

[0095] In some embodiments, the target operation can be a read operation or a write operation. In different cases, the implementation methods of processing data access requests through a second thread based on request metadata are different, which will be described separately below.

[0096] In the first scenario, the target operation is a read operation. The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target data is the data that the first thread needs to read from the target file, and the target virtual address is the virtual base address corresponding to the memory region used to store the read target data. In this case, based on the file descriptor, the second thread in user mode determines the file virtual address, which is the virtual base address for performing the target operation on the target file. Based on the file virtual address, the target virtual address, and the size of the target data, a first physical address range and a first virtual address range are determined. The first physical address range is the physical address range corresponding to the storage location of the target data, and the first virtual address range is the virtual address range corresponding to the memory region used to store the read target data. A mapping relationship between the first physical address range and the first virtual address range is added to the page table of the first thread, and it is determined that the second thread's processing operation for the data access request has been completed.

[0097] Currently, when a file system service program processes a read operation, it reads the target data from the target file and copies it to the physical address range corresponding to the first virtual address range allocated by the application for storing the target data. The application can then retrieve the target data based on the first virtual address range. However, this method requires multiple copies of the target data, resulting in significant memory overhead. In contrast, the embodiments of this application directly add the mapping relationship between the first physical address range and the first virtual address range to the page table corresponding to the application's thread. The application's thread can directly access the target data through the first virtual address range; that is, data reading is achieved by modifying the page table without data copying. This greatly reduces memory pressure and improves data access efficiency.

[0098] In some embodiments, before determining the file virtual address based on the file descriptor by a second thread in user mode, the second thread can switch from kernel mode to user mode to execute the step of determining the file virtual address based on the file descriptor by a second thread in user mode.

[0099] In some embodiments, a second thread in user mode can determine the target file based on the file descriptor, and then determine the file's virtual address based on the target file. In one possible implementation, the second thread stores a first pointer corresponding to the target file, which indicates the address immediately following the end address of the last read operation performed by the application on the target file. In this case, the address pointed to by the first pointer can be directly determined as the file's virtual address. It should be noted that if the application did not perform a read operation on the target file in the last instance, the address pointed to by the first pointer is the virtual start address of the target file.

[0100] The process of determining the first physical address range and the first virtual address range based on the file virtual address, the target virtual address, and the size of the target data includes: taking the target virtual address as the minimum value of the first virtual address range, and taking the sum of the target virtual address and the size of the target data as the maximum value of the first virtual address range; determining the file physical address corresponding to the file virtual address based on the file virtual address, wherein the file physical address is the physical base address for performing the target operation on the target file, taking the file physical address as the minimum value of the first physical address range, and taking the sum of the file physical address and the size of the target data as the maximum value of the first physical address range.

[0101] In some embodiments, after the second thread processes the data access request based on the request metadata, the processing result of the data access request can be written to the target metadata buffer by the second thread in kernel mode. The processing result indicates whether the processing operation of the data access request by the second thread has been completed. The thread running on the target processor core is switched from the second thread to the first thread. The processing result is obtained from the target metadata buffer area by the first thread in kernel mode. If the processing result indicates that the processing operation of the data access request by the second thread has been completed, the target data is read by the first thread in user mode based on the first virtual address range and the page table of the first thread.

[0102] In one possible implementation, the process of switching the thread running on the target processor core from the second thread to the first thread includes: storing the context of the second thread, and running the first thread directly on the target processor core based on the context of the first thread.

[0103] For example, the context of the second thread in kernel mode is stored, and the first thread in kernel mode is run directly on the target processor core based on the context of the first thread in kernel mode.

[0104] In some embodiments, before adding the mapping between the first physical address range and the first virtual address range to the page table of the first thread, the computer device can also determine whether the size of the target data is an integer multiple of the memory page size. If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping between the first physical address range and the first virtual address range to the page table of the first thread is performed, where the memory page is the smallest unit of memory management of the computer device.

[0105] A memory page is a fixed-size block of data used by the operating system to allocate and manage physical memory. It is the basic unit of memory management; by dividing memory into fixed-size pages, the operating system can manage and allocate memory resources more efficiently. The size of a memory page is typically a power of 2, such as 4 kilobytes (KB), 8KB, 16KB, etc., with the specific size depending on the operating system and hardware architecture. When the size of the target data is an integer multiple of the memory page size, it ensures that the data completely occupies an integer number of memory pages and does not cross multiple memory page boundaries. Therefore, after adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, the first thread cannot access data other than the target data, thus effectively protecting data security.

[0106] In the second scenario, the target operation is a write operation. The requested metadata includes the target file's file descriptor, the size of the target data, and the target virtual address. The target data is the data that the first thread needs to write to the target file, and the target virtual address is the virtual base address corresponding to the memory region currently used to store the target data. In this case, based on the file descriptor, the second thread in user mode determines the file virtual address, which is the virtual base address for performing the target operation on the target file. Based on the file virtual address, the target virtual address, and the size of the target data, a second physical address range and a second virtual address range are determined. The second physical address range is the physical address range corresponding to the memory region currently used to store the target data, and the second virtual address range is the virtual address range corresponding to the memory region used to write the target data. The mapping relationship between the second physical address range and the second virtual address range is added to the second thread's page table, and it is confirmed that the second thread's processing operation for the data access request has been completed.

[0107] Currently, when processing write operations, the file system service program reads the target data from the second physical address range and copies it to the corresponding location in the target file. This method requires multiple copies of the target data, resulting in significant memory overhead. However, the embodiments of this application can directly add the mapping relationship between the second physical address range and the second virtual address range to the page table corresponding to the thread of the user-mode file system service program, without performing data copying. Data writing is achieved by modifying the page table, thus greatly reducing memory pressure and improving data access efficiency.

[0108] It should be noted that the above content describes in detail the processing method when the target operation is a read operation or a write operation. However, when the target operation is not a read operation or a write operation, the data access request can be processed by a second thread using existing processing methods. In other embodiments, regardless of the target operation, the data access request can be processed by a second thread using existing processing methods; this application does not limit this approach.

[0109] In some embodiments, before determining the file virtual address based on the file descriptor by a second thread in user mode, the second thread can switch from kernel mode to user mode to execute the step of determining the file virtual address based on the file descriptor by a second thread in user mode.

[0110] In some embodiments, a second thread in user mode can determine the target file based on the file descriptor, and then determine the file's virtual address based on the target file. In one possible implementation, the second thread stores a second pointer corresponding to the target file, which indicates the address immediately following the end address of the last write operation performed by the application on the target file. In this case, the address pointed to by the second pointer can be directly determined as the file's virtual address. It should be noted that if the application did not perform a write operation on the target file in the last instance, the address pointed to by the second pointer is the virtual start address of the target file.

[0111] The process of determining the second physical address range and the second virtual address range based on the file virtual address, the target virtual address, and the size of the target data includes: using the file virtual address as the minimum value of the second virtual address range, and using the sum of the file virtual address and the size of the target data as the maximum value of the second virtual address range; determining the target physical address corresponding to the target virtual address based on the target virtual address, where the target physical address is the physical base address corresponding to the memory region currently used to store the target data, using the target physical address as the minimum value of the second physical address range, and using the sum of the target physical address and the size of the target data as the maximum value of the second physical address range.

[0112] It should be noted that, in this embodiment, when processing write operations, the page table corresponding to the second thread is modified, allowing both the first and second threads to access the second physical address range through their own page tables; similarly, when processing read operations, the page table corresponding to the first thread is modified, allowing both the first and second threads to access the first physical address range through their own page tables. In this situation, the first and second physical address ranges become shared physical addresses for both threads (i.e., both threads can perform write operations on the shared physical address). If both the first and second threads write data to the shared physical address via memory write operations, data conflicts will occur. For example, if thread 1 and thread 2 share physical address range 'a', and thread 1 writes data 'x' to physical address range 'a', and then thread 2 writes data 'y' to physical address range 'a', the data in physical address range 'a' will be 'y', but the data 'x' written by thread 1 will be overwritten by 'y', resulting in data loss for thread 1. Therefore, if data is written to a physical address range mapped by the page tables of multiple threads via memory write operations, a copy-on-write method must be used to avoid data conflicts.

[0113] Copy-on-write is a mechanism proposed to resolve data conflicts in multi-threaded shared memory. When multiple threads share the same memory region and one thread attempts to write to that region, the system does not directly write to the shared region. Instead, the system creates a copy of the shared memory region for that thread and performs the write operation on that copy. In this way, each thread has its own copy of the memory region, thus avoiding data conflicts. It should also be noted that the write operation performed through the file system service program in this embodiment can be called a file write operation, while the memory write operation described above is different. A memory write operation refers to directly writing data to a given physical address. For example, the first thread can write data to the physical address mapped by its own page table.

[0114] In some embodiments, after the data access request is processed by the second thread based on the request metadata, the processing result of the data access request can be written to the target metadata buffer by the second thread in kernel mode. The processing result indicates whether the processing operation of the data access request by the second thread has been completed; the thread running on the target processor core is switched from the second thread to the first thread; and the processing result is obtained from the target metadata buffer area by the first thread in kernel mode.

[0115] In one possible implementation, the process of switching the thread running on the target processor core from the second thread to the first thread includes: storing the context of the second thread, and running the first thread directly on the target processor core based on the context of the first thread.

[0116] For example, the context of the second thread in kernel mode is stored, and the first thread in kernel mode is run directly on the target processor core based on the context of the first thread in kernel mode.

[0117] In some embodiments, before adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread, the computer device can also determine whether the size of the target data is an integer multiple of the memory page size. If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread is performed, where the memory page is the smallest unit of memory management of the computer device.

[0118] When the size of the target data is an integer multiple of the memory page size, it can be ensured that the data completely occupies an integer number of memory pages and will not cross multiple memory page boundaries. Therefore, after adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, the first thread cannot access data other than the target data, thus effectively protecting data security.

[0119] It is understood that when describing related actions in the embodiments of this application, the actions are limited to being executed by the first thread or the second thread in kernel mode. This is not intended to limit the solution of the embodiments of this application, but merely to more clearly illustrate the solution of the embodiments of this application. These actions that limit the execution of the first thread or the second thread in kernel mode are actually executed by the operating system kernel. In practical applications, the executing entity of the corresponding actions can be adjusted according to requirements, and the embodiments of this application do not limit this.

[0120] Next, the data access method provided in the embodiments of this application will be described again with examples.

[0121] Please refer to Figure 5. This embodiment of the application can be applied to a computer device with a Linux operating system. This computer device also deploys a user-space file system (FUSE) kernel module. With the support of the FUSE kernel module, developers only need to implement specific file operations according to the interfaces provided by FUSE to implement a user-space file system. The original FUSE kernel module includes a scheduling and communication module and a data transmission module. The scheduling and communication module uses a sleep-wake mechanism to switch between threads (i.e., the scheduling mechanism described above), while the data transmission module uses data copying to implement read / write operations and the transmission of information carried in data access requests. This embodiment of the application replaces the scheduling and communication module included in the original FUSE kernel module with the scheduling-free fast switching unit in Figure 2 above, and replaces the data transmission module with the metadata management unit and page table management unit in Figure 2 above.

[0122] During user-mode file system program initialization, the fuse kernel module creates at least one file system service program thread based on the number of at least one processor, and establishes a correspondence between the at least one file system service program thread and at least one processor. Furthermore, for any thread among the at least one file system service program threads, a metadata buffer is allocated in the computing device's memory when the thread begins execution. After the file system service program initialization is complete, the second thread is in user mode. In this case, the scheduling-free fast switching unit stores the second thread's user-mode context and switches the second thread to kernel mode, then stores the context of the second thread in kernel mode and suspends its execution. Responding to a data access request triggered by the first thread, the metadata management unit stores the requested metadata in the target metadata buffer, then stores the first thread's kernel-mode context through the scheduling-free fast switching unit. Based on the second thread's kernel-mode context, the kernel-mode second thread runs directly on the target processor core. When the target operation is a read operation, the fuse kernel module determines the file virtual address based on the file descriptor using a second thread in user mode. Based on the file virtual address, the target virtual address, and the size of the target data, it determines the first physical address range and the first virtual address range. The page table management unit adds the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread and confirms that the second thread's processing operation for the data access request has been completed. When the target operation is a write operation, the fuse kernel module determines the file virtual address based on the file descriptor using a second thread in user mode. Based on the file virtual address, the target virtual address, and the size of the target data, it determines the second physical address range and the second virtual address range. The page table management unit adds the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread and confirms that the second thread's processing operation for the data access request has been completed. Then, the metadata management unit writes the processing result of the data access request to the target metadata buffer. The scheduling-free fast switching unit switches the thread running on the target processor core from the second thread to the first thread; the first thread in kernel mode retrieves the processing result from the target metadata buffer area.

[0123] Since the target metadata buffer is a shared memory area for the first and second threads, the first thread can directly store the requested metadata into the buffer after triggering a data access request, and the second thread can directly read the data from it without copying the data. This effectively reduces memory overhead and improves data transfer efficiency. Furthermore, this embodiment can also switch the thread running on the target processor core directly from the first thread to the second thread after the first thread triggers a data access request, avoiding the waiting time in traditional scheduling mechanisms. This allows for rapid response to data access requests, significantly improving data access efficiency. In addition, in this embodiment, the second thread (i.e., the thread of the file system service program) is the thread corresponding to the target processor core. Each processor core in the computer device is bound to a corresponding second thread. This ensures that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transfer latency can be significantly reduced. Moreover, since each processor core has a corresponding file system service program thread, the operating system kernel does not need to handle thread scheduling between different cores, reducing the complexity of thread management.

[0124] Furthermore, in this embodiment, when processing write operations, the mapping relationship between the second physical address range and the second virtual address range is directly added to the page table corresponding to the thread of the user-mode file system program. When processing read operations, the mapping relationship between the first physical address range and the first virtual address range can be directly added to the page table corresponding to the thread of the application. The thread of the application can directly access the target data through the first virtual address range. That is, data writing and reading are achieved by modifying the page table without data copying, which greatly reduces memory pressure and improves data access efficiency.

[0125] Figure 6 is a schematic diagram of a data access device provided in an embodiment of this application. This data access device can be implemented as part or all of the aforementioned computer equipment by software, hardware, or a combination of both. Referring to Figure 6, the device includes: a storage module 601, a switching module 602, and a processing module 603.

[0126] Storage module 601 is used to store request metadata in a target metadata buffer in response to a data access request triggered by the first thread. The data access request indicates that a target operation be performed on a target file in the computer device. The request metadata includes a description of the data access request. The target metadata buffer is a memory area shared by the first thread and the second thread. For detailed implementation details, please refer to the corresponding content in the above embodiments, which will not be repeated here.

[0127] The switching module 602 is used to switch the thread running on the target processor core from the first thread to the second thread. For detailed implementation details, please refer to the corresponding content in the above embodiments; they will not be repeated here.

[0128] Processing module 603 is used to obtain request metadata from the target metadata buffer and, based on the request metadata, process the data access request through a second thread. For detailed implementation details, please refer to the corresponding content in the above embodiments; they will not be repeated here.

[0129] In one possible implementation, the storage module is specifically used for:

[0130] Store the context of the second thread, which indicates the thread's runtime environment;

[0131] The switching module is specifically used for:

[0132] Store the context of the first thread and run the second thread on the target processor core based on the context of the second thread.

[0133] In one possible implementation, the storage module is specifically used for:

[0134] Load the file system service program and create a second thread for the target processor core;

[0135] Allocate a target metadata buffer for the target processor core.

[0136] In one possible implementation, the requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a read operation, the target data is the data that the first thread needs to read from the target file, and the target virtual address refers to the virtual base address corresponding to the memory region used to store the read target data.

[0137] In one possible implementation, the processing module is specifically used for:

[0138] Based on the file descriptor, the file virtual address is determined by a second thread in user mode. The file virtual address is the virtual base address for performing the target operation on the target file.

[0139] Based on the file virtual address, the target virtual address, and the size of the target data, a first physical address range and a first virtual address range are determined. The first physical address range is the physical address range corresponding to the storage location of the target data, and the first virtual address range is the virtual address range corresponding to the memory area used to store the read target data.

[0140] Add a mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, and determine that the processing operation of the data access request by the second thread has been completed.

[0141] In one possible implementation, the processing module is specifically used for:

[0142] The processing result of the data access request is written to the target metadata buffer by a second thread in kernel mode. The processing result indicates whether the second thread has completed the processing operation of the data access request.

[0143] Switch the thread running on the target processor core from the second thread to the first thread;

[0144] The processing result is obtained from the target metadata buffer area by the first thread in kernel mode;

[0145] If the processing result indicates that the second thread has completed its processing of the data access request, the target data is read by the first thread in user mode, based on the first virtual address range and the page table of the first thread.

[0146] In one possible implementation, the processing module is specifically used for:

[0147] If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the first physical address range and the first virtual address range in the page table of the first thread is executed. The memory page is the smallest unit of memory management of a computer device.

[0148] In one possible implementation, the requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a write operation, the target data is the data that the first thread needs to write to the target file, and the target virtual address refers to the virtual base address corresponding to the memory region currently used to store the target data.

[0149] In one possible implementation, the processing module is specifically used for:

[0150] Based on the file descriptor, the file virtual address is determined by a second thread in user mode. The file virtual address is the virtual base address for performing the target operation on the target file.

[0151] Based on the file virtual address, the target virtual address, and the size of the target data, a second physical address range and a second virtual address range are determined. The second physical address range is the physical address range corresponding to the memory region currently used to store the target data, and the second virtual address range is the virtual address range corresponding to the memory region used to write the target data.

[0152] Add the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread, and determine that the processing operation of the data access request by the second thread has been completed.

[0153] In one possible implementation, the processing module is specifically used for:

[0154] The processing result of the data access request is written to the target metadata buffer by a second thread in kernel mode. The processing result indicates whether the second thread has completed the processing operation of the data access request.

[0155] Switch the thread running on the target processor core from the second thread to the first thread;

[0156] The processing result is obtained from the target metadata buffer area by the first thread in kernel mode.

[0157] In one possible implementation, the processing module is specifically used for:

[0158] If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread is executed. The memory page is the smallest unit of memory management of a computer device.

[0159] In this embodiment, since the target metadata buffer is a shared memory area for the first thread and the second thread, the first thread can directly store the request metadata in the buffer after triggering a data access request, and the second thread can directly read the data from it without copying the data. This effectively reduces memory overhead and improves data transfer efficiency. Furthermore, this embodiment can also switch the thread running on the target processor core directly from the first thread to the second thread after the first thread triggers a data access request, avoiding the waiting time in traditional scheduling mechanisms. This allows for rapid response to data access requests, significantly improving data access efficiency. In addition, in this embodiment, the second thread (i.e., the thread of the file system service program) is the thread corresponding to the target processor core. Each processor core in the computer device is bound to a corresponding second thread. This ensures that data access requests triggered on each processor can be directly processed by the corresponding second thread on that processor. Since data access requests do not need to be scheduled and processed across processor cores, thread scheduling and data transfer latency can be significantly reduced. Moreover, since each processor core has a corresponding file system service program thread, the operating system kernel does not need to handle thread scheduling between different cores, reducing the complexity of thread management.

[0160] Furthermore, in this embodiment, when processing write operations, the mapping relationship between the second physical address range and the second virtual address range is directly added to the page table corresponding to the thread of the user-mode file system program. When processing read operations, the mapping relationship between the first physical address range and the first virtual address range can be directly added to the page table corresponding to the thread of the application. The thread of the application can directly access the target data through the first virtual address range. That is, data writing and reading are achieved by modifying the page table without data copying, which greatly reduces memory pressure and improves data access efficiency.

[0161] It should be noted that the data access device provided in the above embodiments is only illustrated by the division of the above functional modules when performing data access. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the data access device and the data access method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0162] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the steps of the data access method described in the above embodiments.

[0163] This application also provides a computer program product containing instructions that, when executed on a computer or processor, cause the computer or processor to perform the steps of the data access method described in the above embodiments. Alternatively, a computer program is provided that, when executed on a computer or processor, causes the computer or processor to perform the steps of the data access method described in the above embodiments.

[0164] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital versatile disc (DVD)), or a semiconductor medium (e.g., solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiments of this application can be a non-volatile storage medium; in other words, it can be a non-transient storage medium.

[0165] It should be understood that "at least one" as mentioned herein refers to one or more, and "multiple" refers to two or more. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. In addition, in order to clearly describe the technical solutions of the embodiments of this application, the terms "first," "second," etc., are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and the terms "first," "second," etc., do not necessarily imply that they are different.

[0166] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the data access requests involved in the embodiments of this application are all obtained under full authorization.

[0167] The above descriptions are embodiments provided in this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made by those skilled in the art should be included within the protection scope of this application.

Claims

1. A data access method, characterized in that, The method is applied to a computer device, the computer device including a target processor core, on which a first thread runs, and the target processor core also has a corresponding second thread, wherein the first thread is a thread of an application program on the computer device, and the second thread is a thread of a file system service program on the computer device; the method includes: In response to a data access request triggered by the first thread, request metadata is stored in a target metadata buffer. The data access request indicates that a target operation be performed on a target file in the computer device. The request metadata includes a description of the data access request. The target metadata buffer is a memory area shared by the first thread and the second thread. Switch the thread running on the target processor core from the first thread to the second thread; The request metadata is obtained from the target metadata buffer, and the data access request is processed by the second thread based on the request metadata.

2. The method as described in claim 1, characterized in that, Before storing the requested metadata in the target metadata buffer in response to the data access request triggered by the first thread, the method further includes: Store the context of the second thread, the context indicating the thread's runtime environment; The step of switching the thread running on the target processor core from the first thread to the second thread includes: The context of the first thread is stored, and the second thread is run on the target processor core based on the context of the second thread.

3. The method as described in claim 2, characterized in that, Before storing the context of the second thread, the method further includes: Load the file system service program and create the second thread for the target processor core; Allocate the target metadata buffer for the target processor core.

4. The method according to any one of claims 1-3, characterized in that, The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a read operation. The target data is the data that the first thread needs to read from the target file. The target virtual address refers to the virtual base address corresponding to the memory region used to store the read target data.

5. The method as described in claim 4, characterized in that, The process of processing the data access request through the second thread based on the requested metadata includes: Based on the file descriptor, the file virtual address is determined by the second thread in user mode, and the file virtual address is the virtual base address for performing the target operation on the target file; Based on the file virtual address, the target virtual address, and the size of the target data, a first physical address range and a first virtual address range are determined. The first physical address range is the physical address range corresponding to the storage location of the target data, and the first virtual address range is the virtual address range corresponding to the memory area used to store the read target data. Add the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, and determine that the processing operation of the second thread on the data access request has been completed.

6. The method as described in claim 5, characterized in that, After processing the data access request through the second thread based on the request metadata, the method further includes: The second thread, which is in kernel mode, writes the processing result of the data access request into the target metadata buffer. The processing result indicates whether the second thread has completed the processing operation of the data access request. Switch the thread running on the target processor core from the second thread to the first thread; The processing result is obtained from the target metadata buffer area by the first thread, which is in kernel mode; If the processing result indicates that the second thread has completed its processing operation on the data access request, the target data is read by the first thread in user mode based on the first virtual address range and the page table of the first thread.

7. The method as described in claim 5 or 6, characterized in that, Before adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, the method further includes: If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread is executed, where the memory page is the smallest unit of memory management of the computer device.

8. The method according to any one of claims 1-3, characterized in that, The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a write operation. The target data is the data that the first thread needs to write to the target file. The target virtual address refers to the virtual base address corresponding to the memory region currently used to store the target data.

9. The method as described in claim 8, characterized in that, The process of processing the data access request through the second thread based on the requested metadata includes: Based on the file descriptor, the file virtual address is determined by the second thread in user mode, and the file virtual address is the virtual base address for performing the target operation on the target file; Based on the file virtual address, the target virtual address, and the size of the target data, a second physical address range and a second virtual address range are determined. The second physical address range is the physical address range corresponding to the memory region currently used to store the target data, and the second virtual address range is the virtual address range corresponding to the memory region used to write the target data. Add the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread, and determine that the processing operation of the second thread for the data access request has been completed.

10. The method as described in claim 9, characterized in that, After processing the data access request through the second thread based on the request metadata, the method further includes: The second thread, which is in kernel mode, writes the processing result of the data access request into the target metadata buffer. The processing result indicates whether the second thread has completed the processing operation of the data access request. Switch the thread running on the target processor core from the second thread to the first thread; The processing result is obtained from the target metadata buffer area by the first thread, which is in kernel mode.

11. The method as described in claim 9 or 10, characterized in that, Before adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread, the method further includes: If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread is executed, where the memory page is the smallest unit of memory management of the computer device.

12. A data access device, characterized in that, An apparatus for use in a computer device, the computer device including a target processor core, on which a first thread runs, and the target processor core also corresponding to a second thread, wherein the first thread is a thread of an application program on the computer device, and the second thread is a thread of a file system service program on the computer device; the apparatus includes: A storage module is configured to, in response to a data access request triggered by the first thread, store request metadata in a target metadata buffer, wherein the data access request indicates a target operation to be performed on a target file in the computer device, the request metadata includes a description of the data access request, and the target metadata buffer is a memory area shared by the first thread and the second thread; A switching module is used to switch the thread running on the target processor core from the first thread to the second thread; The processing module is used to obtain the request metadata from the target metadata buffer, and process the data access request through the second thread based on the request metadata.

13. The apparatus as claimed in claim 12, characterized in that, The storage module is specifically used for: Store the context of the second thread, the context indicating the thread's runtime environment; The switching module is specifically used for: The context of the first thread is stored, and the second thread is run on the target processor core based on the context of the second thread.

14. The apparatus as claimed in claim 13, characterized in that, The storage module is specifically used for: Load the file system service program and create the second thread for the target processor core; Allocate the target metadata buffer for the target processor core.

15. The apparatus according to any one of claims 12-14, characterized in that, The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a read operation. The target data is the data that the first thread needs to read from the target file. The target virtual address refers to the virtual base address corresponding to the memory region used to store the read target data.

16. The apparatus as claimed in claim 15, characterized in that, The processing module is specifically used for: Based on the file descriptor, the file virtual address is determined by the second thread in user mode, and the file virtual address is the virtual base address for performing the target operation on the target file; Based on the file virtual address, the target virtual address, and the size of the target data, a first physical address range and a first virtual address range are determined. The first physical address range is the physical address range corresponding to the storage location of the target data, and the first virtual address range is the virtual address range corresponding to the memory area used to store the read target data. Add the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread, and determine that the processing operation of the second thread on the data access request has been completed.

17. The apparatus as claimed in claim 16, characterized in that, The processing module is specifically used for: The second thread, which is in kernel mode, writes the processing result of the data access request into the target metadata buffer. The processing result indicates whether the second thread has completed the processing operation of the data access request. Switch the thread running on the target processor core from the second thread to the first thread; The processing result is obtained from the target metadata buffer area by the first thread, which is in kernel mode; If the processing result indicates that the second thread has completed its processing operation on the data access request, the target data is read by the first thread in user mode based on the first virtual address range and the page table of the first thread.

18. The apparatus as claimed in claim 16 or 17, characterized in that, The processing module is specifically used for: If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the first physical address range and the first virtual address range to the page table of the first thread is executed, where the memory page is the smallest unit of memory management of the computer device.

19. The apparatus according to any one of claims 12-14, characterized in that, The requested metadata includes the file descriptor of the target file, the size of the target data, and the target virtual address. The target operation is a write operation. The target data is the data that the first thread needs to write to the target file. The target virtual address refers to the virtual base address corresponding to the memory region currently used to store the target data.

20. The apparatus as claimed in claim 19, characterized in that, The processing module is specifically used for: Based on the file descriptor, the file virtual address is determined by the second thread in user mode, and the file virtual address is the virtual base address for performing the target operation on the target file; Based on the file virtual address, the target virtual address, and the size of the target data, a second physical address range and a second virtual address range are determined. The second physical address range is the physical address range corresponding to the memory region currently used to store the target data, and the second virtual address range is the virtual address range corresponding to the memory region used to write the target data. Add the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread, and determine that the processing operation of the second thread for the data access request has been completed.

21. The apparatus as claimed in claim 20, characterized in that, The processing module is specifically used for: The second thread, which is in kernel mode, writes the processing result of the data access request into the target metadata buffer. The processing result indicates whether the second thread has completed the processing operation of the data access request. Switch the thread running on the target processor core from the second thread to the first thread; The processing result is obtained from the target metadata buffer area by the first thread, which is in kernel mode.

22. The apparatus as claimed in claim 20 or 21, characterized in that, The processing module is specifically used for: If the size of the target data is an integer multiple of the memory page size, then the step of adding the mapping relationship between the second physical address range and the second virtual address range to the page table of the second thread is executed, where the memory page is the smallest unit of memory management of the computer device.

23. A computer device, characterized in that, The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the steps of the method according to any one of claims 1 to 11.

24. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed on a computer or processor, causes the computer or processor to perform the method as described in any one of claims 1 to 11.

25. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a computer or processor, cause the steps of the method as described in any one of claims 1 to 11 to be performed.