Hmb switch implementation method and device based on linux system and computer device
By introducing HMB functionality into the Linux system, the problem of poor performance of DRAM-Less SSDs was solved, flexible function control was achieved, and testing and development efficiency was improved.
Patent Information
- Application Number
- CN202210693358.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-17
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2042-06-17
Smart Images

Figure CN114913912B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of solid state disks, and particularly relates to an HMB switch implementation method and device based on a Linux system, computer equipment and a storage medium. BACKGROUND
[0002] With the development of solid state disk technology, current NVME SSD (Solid State Disk) is widely used in notebook computers, desktop computers and some mobile phones. The external DRAM (Dynamic Random Access Memory) matched with the SSD can be used as a read-write buffer or store FTL data, so as to realize high-speed reading and writing. However, some SSDs give priority to chip size or cost factors and do not match external DRAM. These DRAM-Less SSDs have slow access speed and poor performance (especially random access performance).
[0003] In order to solve this problem, the NVME protocol adds a standard as an option to allow DRAM-Less SSDs to borrow DRAM (Host Memory) from a host device and use them as a buffer (Buffer). This is the use of Host Memory Buffer (HMB) function. Whether to enable HMB has a great difference in the performance of DRAM-Less SSDs. SUMMARY
[0004] Therefore, it is necessary to provide an HMB switch implementation method and device based on a Linux system, computer equipment and a storage medium in view of the above technical problems.
[0005] An HMB switch implementation method based on a Linux system, the method comprising:
[0006] viewing the HMB size allocated by the host for the SSD and determining whether the current HMB function has been turned on;
[0007] obtaining a program uninstall command and uninstalling the current NVME driver;
[0008] modifying the configuration parameters of the NVME driver and reloading the NVME driver with the modified parameters;
[0009] viewing the HMB size allocated by the host for the SSD again to determine whether the HMB function has been turned off.
[0010] In one embodiment, the step of viewing the HMB size allocated by the host for the SSD and determining whether the current HMB function has been turned on comprises:
[0011] If the HMB size allocated by the host for the SSD is not 0, it indicates that the current HMB function has been turned on.
[0012] An uninstall command is obtained, and the current NVME driver is uninstalled.
[0013] The value of the configuration parameter of the driver is set to 0, and the NVME driver with the modified parameter is reloaded.
[0014] In one embodiment, the step of checking the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on further comprises:
[0015] If the HMB size allocated by the host for the SSD is 0, it indicates that the current HMB function has been turned off.
[0016] An uninstall command is obtained, and the current NVME driver is uninstalled.
[0017] The value of the configuration parameter of the driver is set to the HMB space of a certain size allocated by the SSD, and the NVME driver with the modified parameter is reloaded.
[0018] In one embodiment, the step of checking the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on further comprises:
[0019] The maximum value of HMB supported by the NVME driver of the host is obtained.
[0020] An HMB switch implementation device based on a Linux system, comprising:
[0021] A first checking module is configured to check the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on.
[0022] An uninstall module is configured to obtain an uninstall command and uninstall the current NVME driver.
[0023] A loading module is configured to modify the configuration parameter of the NVME driver and reload the NVME driver with the modified parameter.
[0024] A second checking module is configured to check the HMB size allocated by the host for the SSD to determine whether the HMB function has been turned off.
[0025] In one embodiment, the device further comprises a function turning-off module configured to:
[0026] If the HMB size allocated by the host to the SSD is not 0, it indicates that the current HMB function has been turned on.
[0027] Obtain a program uninstall command to uninstall the current NVME driver;
[0028] Set the drive configuration parameter value to 0, and reload the NVME driver with the modified parameter.
[0029] In one embodiment, the apparatus further comprises a function turning-on module for:
[0030] If the HMB size allocated by the host to the SSD is 0, it indicates that the current HMB function has been turned off.
[0031] Obtain a program uninstall command to uninstall the current NVME driver;
[0032] Set the drive configuration parameter value to a certain size of HMB space allocated by the SSD, and reload the NVME driver with the modified parameter.
[0033] In one embodiment, the apparatus further comprises an obtaining module for:
[0034] Obtain the maximum value of HMB supported by the host NVME driver.
[0035] A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the above methods.
[0036] A computer readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the steps of any of the above methods.
[0037] The above HMB switch implementation method, apparatus, computer device and storage medium based on a Linux system can actively enable the HMB function when the host loads the NVME driver after power-on, and can turn off or turn on the HMB function after entering the Linux system. This scheme facilitates the testing and development of the SSD HMB function, and can effectively improve the efficiency of testing and development. BRIEF DESCRIPTION OF DRAWINGS
[0038] Figure 1 A flowchart of the HMB switch implementation method based on a Linux system in one embodiment;
[0039] Figure 2 A flowchart of the HMB switch implementation method based on a Linux system in another embodiment;
[0040] Figure 3 A flowchart of a Linux system-based HMB switch implementation method in another embodiment;
[0041] Figure 4 A structural block diagram of a Linux system-based HMB switch implementation device in an embodiment;
[0042] Figure 5 A structural block diagram of a Linux system-based HMB switch implementation device in another embodiment;
[0043] Figure 6 A structural block diagram of a Linux system-based HMB switch implementation device in another embodiment;
[0044] Figure 7 A structural block diagram of a Linux system-based HMB switch implementation device in another embodiment;
[0045] Figure 8 An internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0046] In order to make the purposes, technical solutions and advantages of the present application clearer, further detailed description will be made to the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0047] At present, the external DRAM matched with the SSD can be used as a read-write buffer or store FTL data, so as to realize high-speed read-write. However, some SSDs give priority to chip size or cost factors and do not match with external DRAM. These DRAM-Less SSDs have slow access speed and poor performance. In order to solve this problem, the NVME protocol adds a standard as an option to allow DRAM-Less SSDs to borrow DRAM from host devices and use them as buffers, which is to use the Host Memory Buffer function. Whether to enable HMB has a large difference in performance of DRAM-Less SSDs.
[0048] Based on this, the present application provides a Linux system-based HMB switch implementation method, which aims to enable the HMB function to be switched through a driver under the Linux system.
[0049] In an embodiment, as shown in Figure 1 , a Linux system-based HMB switch implementation method is provided, which comprises:
[0050] Step 102, check the HMB size allocated by the host for the SSD, and determine whether the current HMB function has been turned on;
[0051] Step 104, get the program uninstall command and uninstall the current NVME driver;
[0052] Step 106, modify the configuration parameters of the NVME driver, and reload the NVME driver with the modified parameters;
[0053] Step 108, check the HMB size allocated by the host for the SSD again to determine whether the HMB function has been turned off.
[0054] In the embodiment, an HMB switching implementation method based on a Linux system is provided. For an NVME SSD supporting an HMB function, the host actively enables the HMB function when loading the NVME driver at power-on, and the HMB function is turned off and turned on again after entering the Linux system. The method specifically includes the following steps:
[0055] First, check the HMB size allocated by the host for the SSD, and determine whether the current HMB function has been turned on. Specifically, the HMB size allocated by the host for the SSD can be checked by sending a command. If the result is 0, it means that the HMB function is turned off. If the result is a non-zero value, such as 64M, it means that the HMB function is turned on.
[0056] In one embodiment, before the step of checking the HMB size allocated by the host for the SSD and determining whether the current HMB function has been turned on, the method further includes: obtaining the maximum HMB value supported by the host NVME driver. Specifically, the maximum HMB value supported by the host NVME driver can be obtained by a command first. For example, if the result is 128MB, it means that the SSD supports a maximum of 128M of HMB space. When modifying the configuration parameters later, the value cannot exceed this size.
[0057] Next, get the program uninstall command and uninstall the current NVME driver. Then, modify the configuration parameters of the NVME driver, and reload the NVME driver with the modified parameters. Specifically, if the HMB function is to be turned off, the parameter is modified to 0. If the HMB function is to be turned on again, the parameter is modified to a non-zero value, such as 64 or 128. Finally, check the HMB size allocated by the host for the SSD again to determine whether the HMB function has been turned off.
[0058] In the above embodiment, for the NVME SSD supporting the HMB function, when the NVME driver is loaded after power-on, the host actively enables the HMB function, and after entering the Linux system, the HMB function can be closed or restarted. The scheme is convenient for testing and development of the SSD HMB function, and can effectively improve the efficiency of testing and development.
[0059] In one embodiment, as shown in Figure 2 , a Linux system-based HMB switching implementation method is provided, and the method further includes:
[0060] In step 202, if the HMB size allocated by the host for the SSD is not 0, it indicates that the current HMB function has been opened.
[0061] In step 204, a program uninstall command is obtained, and the current NVME driver program is unloaded.
[0062] In step 206, the drive configuration parameter value is set to 0, and the NVME driver program with the modified parameter is reloaded.
[0063] In one embodiment, as shown in Figure 3 , a Linux system-based HMB switching implementation method is provided, and the method further includes:
[0064] In step 302, if the HMB size allocated by the host for the SSD is 0, it indicates that the current HMB function has been closed.
[0065] In step 304, a program uninstall command is obtained, and the current NVME driver program is unloaded.
[0066] In step 306, the drive configuration parameter value is set to a certain size of HMB space allocated by the host for the SSD, and the NVME driver program with the modified parameter is reloaded.
[0067] In the embodiment, the implementation process of closing the HMB function and the implementation process of opening the HMB function are provided respectively.
[0068] The implementation process of closing the HMB function: open the command line terminal, send the command modprobe -r nvme to uninstall the NVME driver. Reload the NVME driver with the modified parameter. The command is modprobe nvme max_host_mem_size_mb=0. Here, the parameter value is 0, indicating that the host closes the HMB function, and the host allocates 0MB space to the SSD.
[0069] The implementation process of opening the HMB function: open the command line terminal, send the command modprobe -r nvme to unload the NVME driver. Reload the NVME driver with modified parameters. Command: modprobe nvme max_host_mem_size_mb=128. The parameter value here is 128, indicating that the host opens the HMB function, and the host allocates 128MB of space to the SSD for use.
[0070] The following is described with a specific example:
[0071] The test environment includes: the test machine is a desktop or a notebook computer, and a Linux operating system is installed; the SSD is an NVME SSD supporting the HMB function; the NVME driver is the native driver of the Linux system; and the command used is the command of the Linux system. The specific execution steps are as follows:
[0072] 1. Get the maximum value of the HMB supported by the host NVME driver, and the result is 128MB.
[0073] 2. Check the size of the HMB allocated by the host to the SSD, which is 64MB for this SSD.
[0074] 3. Unload the NVME driver.
[0075] 4. Load the NVME driver with modified parameters, and set the parameter value to 0.
[0076] 5. Check the size of the HMB obtained by the SSD, which is displayed as 0MB, and the HMB function has been closed at this time.
[0077] 6. Check the size of the HMB supported by the driver, which is 0, indicating that the HMB has been closed again.
[0078] 7. If it is necessary to reopen the HMB function, unload the NVME driver first, and then load the driver with a parameter value of 64.
[0079] 8. Check the size of the HMB obtained by the SSD, which is displayed as 64MB of HMB space obtained by the SSD again, indicating that the HMB has been reopened.
[0080] It should be understood that, although Figures 1-3 the steps in the flowchart are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this article, the execution of these steps has no strict order limitation, and these steps can be executed in other orders. Moreover, Figures 1-3At least one of the steps in the method can comprise a plurality of sub-steps or a plurality of stages, which sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the order of the execution of the sub-steps or stages is not necessarily sequential, but can be performed alternately or in rotation with other steps or sub-steps or stages of other steps.
[0081] In one embodiment, as shown in FIG. 4, there is provided an HMB switch implementation device 400 based on a Linux system, which device comprises: Figure 4
[0082] A first checking module 401 is configured to check the HMB size allocated by the host to the SSD, and determine whether the HMB function has been turned on or not.
[0083] An uninstalling module 402 is configured to obtain a program uninstalling command and uninstall the current NVME driver.
[0084] A loading module 403 is configured to modify the configuration parameters of the NVME driver, and reload the NVME driver with the modified parameters.
[0085] A second checking module 404 is configured to check the HMB size allocated by the host to the SSD again, and determine whether the HMB function has been turned off or not.
[0086] In one embodiment, as shown in FIG. 4, there is provided an HMB switch implementation device 400 based on a Linux system, which device further comprises a function turning-off module 405 configured to: Figure 5 If the HMB size allocated by the host to the SSD is not 0, it indicates that the HMB function has been turned on.
[0087] Obtain a program uninstalling command and uninstall the current NVME driver.
[0088] Set the value of the driver configuration parameter to 0, and reload the NVME driver with the modified parameters.
[0089] In one embodiment, as shown in FIG. 4, there is provided an HMB switch implementation device 400 based on a Linux system, which device further comprises a function turning-on module 406 configured to:
[0090] Figure 6 If the HMB size allocated by the host to the SSD is 0, it indicates that the HMB function has been turned off.
[0091] Obtain a program uninstalling command and uninstall the current NVME driver.
[0092] Set the value of the driver configuration parameter to 0, and reload the NVME driver with the modified parameters.
[0093] Setting the drive configuration parameter value to SSD allocates a certain size of HMB space, and reloading the NVME driver with modified parameters.
[0094] In one embodiment, as shown in Figure 7 A Linux system-based HMB switch implementation device 400 is provided, which also includes an acquisition module 407 configured to:
[0095] Acquire the maximum HMB value supported by the host NVME driver.
[0096] For specific limitations of the Linux system-based HMB switch implementation device, please refer to the limitations of the Linux system-based HMB switch implementation method described above, which will not be repeated here.
[0097] In one embodiment, a computer device is provided, and its internal structure diagram can be as shown in Figure 8 The computer device includes a processor, a memory, and a network interface connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a Linux system-based HMB switch implementation method.
[0098] Those skilled in the art can understand, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0099] In one embodiment, a computer device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program to implement the steps in each of the above method embodiments.
[0100] In one embodiment, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by the processor to implement the steps in each of the above method embodiments.
[0101] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, storage, databases, or other media in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0102] The technical features of the above embodiments can be combined in any way. In order to make the description simple, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.
[0103] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of the patent of the present application should be subject to the appended claims.
Claims
1. A Linux system-based HMB switch implementation method, the method comprising: checking the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on, including: if the HMB size allocated by the host for the SSD is not 0, it indicates that the current HMB function has been turned on; if the HMB size allocated by the host for the SSD is 0, it indicates that the current HMB function has been turned off; obtaining a program uninstall command and uninstalling the current NVME driver; modifying the configuration parameters of the NVME driver, and reloading the NVME driver with the modified parameters, including: if the HMB size allocated by the host for the SSD is not 0, setting the drive configuration parameter value to 0 and reloading the NVME driver with the modified parameters; if the HMB size allocated by the host for the SSD is 0, setting the drive configuration parameter value to a certain size of HMB space allocated by the SSD and reloading the NVME driver with the modified parameters; checking the HMB size allocated by the host for the SSD again to determine whether the HMB function has been turned off; wherein, before the step of checking the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on, the method further comprises: obtaining the maximum HMB value supported by the host NVME driver.
2. A Linux system-based HMB switch implementation device, characterized in that, The Linux system-based HMB switch implementation device comprises: a first checking module, configured to check the HMB size allocated by the host for the SSD to determine whether the current HMB function has been turned on, including: if the HMB size allocated by the host for the SSD is not 0, it indicates that the current HMB function has been turned on; if the HMB size allocated by the host for the SSD is 0, it indicates that the current HMB function has been turned off; an uninstalling module, configured to obtain a program uninstall command and uninstall the current NVME driver; a loading module, configured to modify the configuration parameters of the NVME driver, and reload the NVME driver with the modified parameters, including: if the HMB size allocated by the host for the SSD is not 0, setting the drive configuration parameter value to 0 and reloading the NVME driver with the modified parameters; if the HMB size allocated by the host for the SSD is 0, setting the drive configuration parameter value to a certain size of HMB space allocated by the SSD and reloading the NVME driver with the modified parameters; a second checking module, configured to check the HMB size allocated by the host for the SSD again to determine whether the HMB function has been turned off; The device further comprises an obtaining module, configured to: obtain the maximum HMB value supported by the host NVME driver.
3. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the method of claim 1.
4. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the steps of the method of claim 1.