The disclosed embodiments relate generally to accessing data in persistent memory, for example a storage device having one or more non-volatile memory devices.
In a computer system having a processor, persistent memory, an application executed in user space, and an operating system and various drivers executed in kernel space, when an application requests access to physical memory, the request typically specifies or is associated with one or more virtual memory addresses. In some systems configured to access persistent memory using block access, a file system maps the virtual addresses to block identifiers (sometimes called block IDs), which are then mapped to physical addresses in persistent memory by a block driver or the like. Typically, when using block access, entire blocks are accessed as a whole, and when a block is updated or overwritten, a new copy of the entire block is written to a new location in persistent memory and the old copy of the block in persistent memory is invalidated. In some systems configured to access persistent memory using memory mapped access, virtual addresses specified by an application are mapped to physical memory addresses using virtual address to physical address mapping mechanisms included in most modern processors and operating systems. Typically these two approaches, block access and memory mapped access, are mutually exclusive. As a result, an application typically can access any particular file, or database, or other data group (sometimes called a dataset) using block access, or memory mapped access, but not both.
Without limiting the scope of the appended claims, after considering this disclosure, and particularly after considering the section entitled “Detailed Description” one will understand how the aspects of various embodiments are implemented and used to access the same physical portions of persistent memory in multiple modes of access. The disclosed embodiments can access the same physical persistent memory region of an electronic device in a memory mapped mode of access and a block mode of access, and use a single address map to facilitate both modes of access.
So that the present disclosure can be understood in greater detail, a more particular description may be had by reference to the features of various embodiments, some of which are illustrated in the appended drawings. The appended drawings, however, merely illustrate pertinent features of the present disclosure and are therefore not to be considered limiting, for the description may admit to other effective features.
In accordance with common practice the various features illustrated in the drawings may not be drawn to scale. Accordingly, the dimensions of the various features may be arbitrarily expanded or reduced for clarity. In addition, some of the drawings may not depict all of the components of a given system, method or device. Finally, like reference numerals may be used to denote like features throughout the specification and figures.
The various implementations described herein include systems, methods and/or devices used to enable both block access and memory mapped access to the same data in persistent memory or to the same portions of persistent memory.
(A1) In some embodiments, a method for managing persistent memory in one or more persistent memory devices includes detecting a first memory request from a user application to access first specified data in a first data group (e.g., a specified file or database or other dataset) in persistent memory. The method includes, prior to detecting the first memory request, storing an address map having mapping data specifying a mapping between virtual addresses, used by the user application to access the first data group, and physical addresses in persistent memory at which data and metadata for the first data group is stored. The mapping is consistent with both a memory mapped mode of access to data in the first data group and a block mode of access to data in the first data group. Further, in accordance with the first memory request being a request to access the first specified data in the first data group using the memory mapped mode of access, the first memory request is translated into a persistent memory access command to access one or more locations in persistent memory that are determined in accordance with one or more virtual addresses specified by the first memory request and the stored mapping data. On the other hand, in accordance with the first memory request being a request to access the first specified data in the first data group using the block mode of access, the first memory request is translated into a persistent memory access command to access one or more blocks in persistent memory that are determined in accordance with one or more virtual addresses specified by the first memory request and the stored mapping data.
(A2) In some embodiments of the method of A1, the virtual addresses are in a virtual address space having first portions (e.g., portions sometimes herein called pages) of a first size (e.g., operating system page size), and the persistent memory has second portions (e.g., physical memory portions sometimes herein called blocks, or blocks of memory) of a second size different from the first size. The mapping data specifies a mapping between each first portion to an integer number of second portions, wherein the integer number is greater than one.
(A3) In some embodiments of the method of A1 or A2, the method further includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the memory mapped mode of access, executing the persistent memory access command using a non-atomic method of execution. On the other hand, in accordance with the first memory request being a request to access the first specified data in the first data group using a block mode of access, the persistent memory access command is executed using an atomic method of execution.
(A4) In some embodiments the method of A1-A3 further includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the block mode of access, executing the persistent memory access command via a file system and block driver. The method also includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the memory mapped mode of access, executing the persistent memory access command using direct access to the persistent memory that bypasses the file system and block driver.
(A5) In some embodiments of the method of A1, a first sequence of memory requests is received, including the first memory request, and, prior to receiving the first sequence of memory requests, a block mode access command is received. The method further includes processing the first sequence of memory requests, including the first memory request, using the block mode of access and, after processing the first sequence of memory requests, receiving a memory mapped access command and a second sequence of memory requests, and processing the second sequence of memory requests using the memory mapped mode of access.
(A6) In some embodiments of the method in A5, in response to the memory mapped access command, the memory map is updated, as needed, such that the first portions of the virtual address space are each mapped to a contiguous set of the second portions in the physical address space. For example, the memory map is updated, as needed, such that respective pages in a set of pages in the virtual address space used by the application are each mapped to a contiguous set of blocks (i.e., at a contiguous set of physical locations) in persistent memory.
(A7) In some embodiments of the method of A1, the method further includes executing the persistent memory command to access the one or more locations in persistent memory by accessing a first location and a second location of the one or more locations in the persistent memory, the first location corresponding to a location within a first contiguous region of the persistent memory at which the metadata for the first data group is stored, and the second location corresponding to a location within a second contiguous region of the persistent memory at which the data for the first data group is stored.
(A8) In some embodiments of the method of A7 the first location and the second location correspond to an index value (i.e., the same index value) associated with the first data group. For example, the address map maps a virtual address specified by the user application (e.g., maps a block ID corresponding to the virtual address specified by a first memory request) to an index value, which corresponds to (or specifies) both a metadata entry in a contiguous metadata region of the persistent memory and a data block in a contiguous data region of the persistent memory.
(A9) In some embodiments of the method of A8, the index value is identified from the address map.
(A10) In some embodiments of the method of A7, accessing the first location is performed prior to accessing the second location, wherein accessing the first location comprises identifying, from the metadata stored at the first location, the second location at which the data for the first data group is stored. The method further includes accessing the second location, which comprises accessing the data for the first data group in accordance with the identified second location.
(A11) In some embodiments of the method of A10, the first location corresponds to a first index value, and the second location corresponds to a second index value distinct from the first index value.
(A12) In some embodiments of the method of A1, the persistent memory is organized into a sequence of extents, each extent having a respective first contiguous region for storing metadata and a respective second contiguous region for storing data.
(A13) In yet another aspect, a computing system includes non-volatile memory, one or more processors, and means for performing of the method of any one of A1 to A12 described above. For example, in some embodiments the means for performing of the method of any one of A1 to A12 comprises one or more software programs stored in memory of the computer system and configured for execution by the one or more processors.
(A14) In yet another aspect, a non-transitory computer-readable storage medium stores one or more programs (sometimes called software programs) configured for execution by one or more processors of a computing system, the one or more programs including instructions for causing the computing system to perform the method of any one of A1 to A12 described above.
In some embodiments, persistent memory 112 includes non-volatile RAM (NVRAM). Stated another way, in these embodiments, persistent memory 112 is implemented, at least in part, using NVRAM. However, persistent memory 112 may include multiple forms of non-volatile memory, such as two or more of battery-backed DRAM, flash memory, resistance RAM (RRAM), ferroelectric RAM, magnetoresistive RAM, phase-change RAM, or the like. The methods and embodiments of computer system 100 described herein are independent of the particular technology or technologies used to implement persistent memory 112.
Similarly, the main memory of computer system 100 (e.g., memory 402,
User application 102 is typically executed in user space, while operating system 104, file system 106 and persistent memory manager 108 are typically executed in kernel space. When a memory mapped mode of access is used, virtual addresses specified by memory access commands issued by user application 102 are translated by a virtual address translator 114 into physical addresses, which are then used to directly access memory. In some implementations, computer system 100 includes one or more processors (e.g., CPUs 400,
Depending on the virtual addresses used by application 102, the memory that is directly accessed (in response to memory access commands issued by user application 102) is the main memory (e.g., memory 402,
When a block mode of access is used, virtual addresses specified by memory access commands issued by user application 102 are conveyed by operating system 104 to file system 106, and those virtual addresses are translated by file system 106 into block identifiers and then physical addresses by file system 106 and/or persistent memory manager 108. The resulting physical addresses are physical addresses of memory blocks in persistent memory 112. Persistent memory manager 108 executes block mode persistent memory access commands, using those physical addresses, in order to read, write, invalidate and/or erase data in persistent memory 112, as specified by user program 102.
One of the features of the embodiments described herein is that user application 102 can access the same first data group using both the block mode of access and the memory mapped mode of access.
Although
Address map 110-A maps block identifiers 210, often called block IDs, to offsets or indices 212 in persistent memory 112. For example, block identifier A is mapped to offset or index 1, which corresponds to metadata entry 206-1 and data entry 208-1. Similarly, block identifier B is mapped to offset or index 2, which corresponds to metadata entry 206-2 and data entry 208-2. However, as shown in
It is further noted that the block IDs 210 in address map 110-A (and in address map 110-B,
As noted above, the block ID corresponding to the specified virtual address is mapped, by address map 110-A, to an offset or index by address map 110-A. When the block mode of access is being used, the data block 208 identified by the offset or index is accessed as a whole. Furthermore, in some embodiments, when the memory mapped mode of access is being used, the aforementioned least significant physical bits of the virtual address are added to the starting address for the identified data block to obtain (e.g., compute) the physical address corresponding to the specified virtual address used by user application 102, and then that physical address in persistent memory is accessed directly.
In these embodiments, contiguous metadata region 202 has a sequence of a metadata entries 306-1, 306-2, etc., where each metadata entry 306 has a fixed size (e.g., 128 bytes, or the like). However, compared with the metadata entries 206 in
Data region 204 has a sequence of a data entries (sometimes called data blocks) 308-1, 308-2, etc., where each data entry or block 308 has the second fixed size (e.g., 512 bytes, 1K byte, 4K bytes, 8K bytes, or the like) that is different from and typically much larger than (e.g., in some embodiments, at least four times as large as) the fixed size of the metadata entries 306. In the embodiments shown in
Address map 110-B maps block identifiers 310, also called block IDs, to offsets or indices 312 for metadata region 202 of persistent memory 112. For example, block identifier A is mapped to offset or index 1, which corresponds to metadata entry 306-1. Similarly, block identifier B is mapped to offset or index 2, which corresponds to metadata entry 306-2. However, as shown in
As explained above with reference to
Using the address map 110-B and persistent memory 112 organizational scheme shown in
For example, assuming that block IDs B, C and D in
More specifically, if the block mode of access is being used, the entire persistent memory data block 308-4 corresponding to data offset j+2 is accessed as a whole. But, if the memory mapped mode of access is being used, the least significant bits of the virtual address, which were removed when determining the corresponding block ID, are added to the starting address for the identified data block to obtain (e.g., compute) the physical address corresponding to the specified virtual address used by user application 102, and then that physical address in persistent memory is accessed directly.
It is noted that the sequence of operations described above is but one non-limiting example of how a memory access command specifying a virtual address is translated into a physical memory access command. Other sequences of operations may be used in various implementations.
In some embodiments, operating system 104 includes a virtual address translator 114 that translates virtual addresses used by user application 102 to physical memory addresses, such as addresses in persistent memory 112. In some embodiments, virtual address translator 114 controls address translation hardware in processor(s) 400 that is configured for translating virtual addresses into physical addresses. As described in more detail below, virtual address translator 114 (and/or corresponding hardware in processor(s) 400) translates virtual addresses to physical memory addresses in persistent memory 112 in accordance with address mapping data in address map 110. Further, in some embodiments, persistent memory 112 is part of computer system 100, while in other embodiments, persistent memory 112 is in a system or subsystem, such as a solid-state storage device, that is separate from, but connected to, computer system 100.
Each of the above identified elements may be stored in one or more of the previously mentioned memory devices, and corresponds to a set of instructions for performing a function described above. The above identified modules or programs (i.e., sets of instructions) need not be implemented as separate software programs, procedures or modules, and thus various subsets of these modules may be combined or otherwise re-arranged in various embodiments. In some embodiments, memory 402 may store a subset of the modules and data structures identified above. Furthermore, memory 402 may store additional modules and data structures not described above. In some embodiments, the programs, modules, and data structures stored in memory 402, or the computer readable storage medium of memory 402, provide instructions for implementing respective operations in the methods described below with reference to
Although
The method 500 begins, in some embodiments, by (502) storing an address map (e.g., in accordance with some embodiments, the address map 110-A of
Optionally, method 500 includes receiving (504) from an application (e.g., user application 102) a block access mode command, thereby notifying the operating system 104 that persistent memory 112 is to be accessed using a block mode of access when responding to commands from the application. In some other embodiments, block mode or access (sometimes called block access mode) may be the default mode, in which case a block access mode command need not be sent by the application unless switching from memory mapped access mode to block access mode.
Next, method 500 includes detecting or receiving (506) from the application one or more memory access requests to access data in a specified file or region of persistent memory. It is noted that the application may also be executing commands that access other memory media, such as main memory, but only commands to access persistent memory are addressed here.
Each such received command is executed (508). In block access mode, executing a command or memory access request to access data in the specified file or region of persistent memory includes mapping the virtual address or addresses specified by the memory access request to one or more physical addresses or physical address ranges in persistent memory. In some embodiments, a respective virtual address specified by a memory access request is mapped or translated into a physical address in persistent memory using any of the methodologies described above with respect to
When executing memory access commands using the block mode of access, entire blocks (e.g., data blocks 208 or 308,
Furthermore, in some embodiments, memory access commands executed using the using a block mode of access are executed using an atomic method of execution. As a result, when the memory access command is a write command, failure of the command to execute results in none of the data specified by the command being stored in persistent memory, and successful execution of the command results in all of the data specified by the command being stored in the persistent memory.
More generally, as used herein, the term “atomic” refers to an operation that either succeeds as a whole, or fails as a whole. For example, an atomic execution of a write command specifying a block of write data will not be interrupted until either the block of write data is written to persistent memory, or the operation fails and the block is not written to persistent memory. Thus, the atomic execution of the write command in the given example will end in either a write completion of the specified write data, or a failure to write any blocks of data. In such an example, an atomic execution of the write command will not result in a partial completion, i.e., write completion of only a portion of the specified write data. With respect to read commands, atomic execution of a read command results in either all of the requested data being returned to the requesting application (i.e., in the case of success, execution of the command succeeds as a whole), or none of the requested data being returned to the requesting application (i.e., in the case of failure, execution of the command fails as a whole).
Method 500 further includes receiving (510) a memory mapped access mode command, which instructs the computer system to use the memory mapped mode of access, either generally when accessing data in persistent memory, or when accessing one or more specified data groups (e.g., one or more files, databases or other datasets). In some circumstances, after receiving the memory mapped mode of access command (510), method includes updating (512) the memory map as needed. In particular, in some embodiments, after receiving such a mode command, and before executing any memory access commands using the memory mapped mode of access, the address map is inspected to determine if each page in the portion of the virtual address space to which the mode command applies is mapped to a contiguous set of data blocks in persistent memory. If any pages in the portion of the virtual address space to which the mode command applies are not mapped to a contiguous set of data blocks in persistent memory, data is moved within persistent memory and the address map is correspondingly updated to the extent necessary so that each such page is mapped to a contiguous set of data blocks in persistent memory. This process is sometimes herein called “page aligning” virtual memory (or the portion of the virtual address space for a specified file, database or dataset) with physical memory.
As noted above, virtual address translator 114 (and/or corresponding hardware in processor(s) 400,
Once the memory map is updated (512), as needed, method 500 continues with detecting or receiving (514) memory access requests (e.g., detecting or receiving memory access commands from the user application) to access data in a specified file, database or other data set in persistent memory, and executing (516) each such detected or received memory access command using the memory mapped mode of access. As described above, in the memory mapped mode of access, virtual addresses are translated into physical addresses by the computer system's processor(s) and operating system, for example using a virtual address translator. The resulting physical addresses are then used to directly access persistent memory (e.g., directly accessing the specified physical addresses in persistent memory). Furthermore, such direct access bypasses the file system and persistent memory manager.
In some embodiments, the operation 512 is performed by a background process, and execution of memory access commands is allowed to begin and continue, using the memory mapped mode of operation, until the application attempts to access a portion of the virtual address space that is not page aligned with data blocks in persistent memory. At that point, operation 512 is performed or completed, after which execution of memory access commands, using the memory mapped mode of operation, is allowed to resume.
In some circumstances, after performing operations 510-516, the application may switch back to the block mode of access for accessing the specified file, database or other data set in persistent memory, in which case the method continues by performing operations 504-508, as described above.
Additional details concerning the processing steps for method 500, as well as details concerning additional processing steps, are presented below with reference to
With reference to the computer system 100 of
In some embodiments the virtual addresses are (604) in a virtual address space (e.g., volatile memory) with first portions of a first size (e.g., portions sometimes herein called pages), and the persistent memory (e.g., persistent memory 112) having second portions (e.g., physical memory portions sometimes herein called data blocks, or blocks of memory) of a second size different from the first size. The mapping data specifies a mapping between each first portion to an integer number of second portions, where the integer number is greater than one (e.g., a page in the virtual address space is at least four times the size of a data block in persistent memory, and more generally the first portions are between 4 and 256 times the size of the second portions, in some embodiments).
In some embodiments, the persistent memory is organized (606) into a sequence of extents (e.g., see extents 200, as shown in
Next, method includes detecting (608) or receiving a first memory request from the user application to access first specified data in a first data group (e.g., a file, database, data set or specified region of persistent memory) in persistent memory. In response to detecting or receiving the first memory request, and in accordance (610) with the first memory request being a request to access the first specified data in the first data group using a block mode of access, the first memory request is translated (612) into a persistent memory access command to access one or more blocks in persistent memory that are determined in accordance with one or more virtual addresses specified by the first memory request and the stored mapping data. As explained above with reference to
In some embodiments, the method further includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the block mode of access, executing (614) the persistent memory access command using an atomic method of execution. Atomic execution of the persistent memory access command is discussed above with reference to operation 508 of
Further, in some embodiments the method includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the block mode of access, executing (616) the persistent memory access command via a file system and block driver. For example, in some embodiments, a file system (e.g. file system 106,
Optionally, operations 608-612 or 608-616 are repeated for additional memory requests from the user application, while the application or system continue to operate in the block mode of access.
In response to detecting or receiving the first memory request, and in accordance with the first memory request being (620) a request to access the first specified data in the first data group using the memory mapped mode of access, the first memory request is translated (622) into a persistent memory access command to access one or more locations in persistent memory that are determined in accordance with one or more virtual addresses specified by the first memory request and the stored mapping data. Further, in some embodiments, accordance with the first memory request being a request to access the first specified data in the first data group using the memory mapped mode of access, the persistent memory access command is executed (624) using a non-atomic method of execution. Thus, when using the memory mapped mode of access, persistent memory access commands are executed without a guarantee that the execution will either succeed as a whole, or fail as a whole. As a result, there is a small possibility of the first data group being left in an inconsistent state as a result of a failed execution of a persistent memory access command that is executed using the memory mapped mode of access.
The method also includes, in accordance with the first memory request being a request to access the first specified data in the first data group using the memory mapped mode of access, executing (626) the persistent memory access command using direct access to the persistent memory that bypasses the file system and block driver.
In some embodiments, method 600 includes receiving (630) a first sequence of memory requests, including the first memory request, and, prior to receiving the first sequence of memory requests, receiving a block mode access command. The method further includes (630) processing the first sequence of memory requests, including the first memory request, using the block mode of access and, after processing the first sequence of memory requests, receiving a memory mapped access command and a second sequence of memory requests, and processing the second sequence of memory requests using the memory mapped mode of access. In some embodiments, in response to the memory mapped access command, the memory map is updated (632), as needed, such that the first portions of the virtual address space are each mapped to a contiguous set of the second portions in the physical address space. For example, the memory map is updated, as needed, such that respective pages in a set of pages in the virtual address space used by the application are each mapped to a contiguous set of blocks (i.e., at a contiguous set of physical locations) in persistent memory. Additional aspects of updating the address map in response to the memory mapped access command are discussed above with respect to operation 512 of method 500.
In some embodiments, method 600 further includes executing (640) the persistent memory command to access the one or more locations in persistent memory by accessing a first location and a second location of the one or more locations in the persistent memory. The first location corresponds to a location within a first contiguous region of the persistent memory at which the metadata for the first data group is stored, and the second location corresponds to a location within a second contiguous region of the persistent memory at which the data for the first data group is stored.
In some embodiments, the first location and the second location correspond 642) to an index value (i.e., the same index value) associated with the first data group. Furthermore, in some embodiments, the index value is identified (644) from the address map. For example, as shown in
In some embodiments, such as embodiments using an address map 110-B and persistent memory organization scheme as shown in
It will be understood that, although the terms “first,” “second,” etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first transistor could be termed a second transistor, and, similarly, a second transistor could be termed a first transistor, without changing the meaning of the description, so long as all occurrences of the “first transistor” are renamed consistently and all occurrences of the “second transistor” are renamed consistently. The first transistor and the second transistor are both transistors, but they are not the same transistor.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the claims. As used in the description of the embodiments and the appended claims, the singular forms “a,” “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term “and/or” as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. It will be further understood that the terms “comprises” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof
As used herein, the term “if” may be construed to mean “when” or “upon” or “in response to determining” or “in accordance with a determination” or “in response to detecting,” that a stated condition precedent is true, depending on the context. Similarly, the phrase “if it is determined [that a stated condition precedent is true]” or “if [a stated condition precedent is true]” or “when [a stated condition precedent is true]” may be construed to mean “upon determining” or “in response to determining” or “in accordance with a determination” or “upon detecting” or “in response to detecting” that the stated condition precedent is true, depending on the context.
The foregoing description, for purpose of explanation, has been described with reference to specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the claims to the precise forms disclosed. Many modifications and variations are possible in view of the above teachings. The embodiments were chosen and described in order to best explain principles of operation and practical applications, to thereby enable others skilled in the art.
This application claims priority to U.S. Provisional Patent Application No. 62/200,573, filed Aug. 3, 2015, which is hereby incorporated by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
62200573 | Aug 2015 | US |