CN117234431B - Cache management method and device, electronic equipment and storage medium - Google Patents
Cache management method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN117234431B CN117234431B CN202311509909.5A CN202311509909A CN117234431B CN 117234431 B CN117234431 B CN 117234431B CN 202311509909 A CN202311509909 A CN 202311509909A CN 117234431 B CN117234431 B CN 117234431B
- Authority
- CN
- China
- Prior art keywords
- target
- value
- cache page
- target cache
- identifying
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000007726 management method Methods 0.000 title claims abstract description 106
- 230000007717 exclusion Effects 0.000 claims abstract description 64
- 230000004044 response Effects 0.000 claims abstract description 19
- 238000000034 method Methods 0.000 claims description 46
- 230000015654 memory Effects 0.000 claims description 34
- 238000012544 monitoring process Methods 0.000 claims description 4
- 238000004064 recycling Methods 0.000 claims 1
- 238000012545 processing Methods 0.000 abstract description 20
- 230000000694 effects Effects 0.000 abstract description 5
- 230000008569 process Effects 0.000 description 16
- 230000009286 beneficial effect Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 230000002159 abnormal effect Effects 0.000 description 2
- 230000003139 buffering effect Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- 239000007787 solid Substances 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Landscapes
- Memory System Of A Hierarchy Structure (AREA)
Abstract
The invention relates to the technical field of cache management, and discloses a cache management method, a cache management device, electronic equipment and a storage medium. The invention provides a cache management method, which comprises the following steps: receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data; determining a target cache page where target cache data are located; identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in a corresponding cache head of the target cache page; if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request. The problem that the cache pages have mutual exclusion access conflict can be solved, and the effect of effectively improving the processing performance of the RAID controller can be achieved.
Description
Technical Field
The present invention relates to the field of cache management technologies, and in particular, to a cache management method, a device, an electronic device, and a storage medium.
Background
In the related art, cache management efficiency can be improved by managing cache data in a hard disk through a disk array (Redundant Arrays of Independent Disks, RAID) controller. In the process of managing cache data, the following three basic operations may be performed on a cache page: write operation, read operation, and cache page data cache data drop operation. The cache page is the minimum granularity of cache management.
However, in the actual management process, since the write operation and the read operation have a mutual exclusion relationship with the cache data drop operation of the cache page data, when the RAID controller issues multiple cache management tasks at the same time, the processing performance of the data read-write request (SATA-IO command) sent by the server host is affected by triggering the cache page mutual exclusion protection mechanism.
In view of this, there is a need for a cache management method capable of improving processing performance for read and write requests.
Disclosure of Invention
In view of the above, the present invention provides a cache management method, apparatus, electronic device, and storage medium, so as to solve the problem of low processing performance of hard disk management cache data.
In a first aspect, the present invention provides a cache management method, including:
receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data;
determining a target cache page where target cache data are located;
identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in a corresponding cache head of the target cache page;
if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request.
The beneficial effects are that: according to the cache management method provided by the embodiment, whether the target data operation can be executed currently can be rapidly identified through the mutual exclusion zone bit field preset in the cache head data, and further when the target cache page is in an operable state, the target data operation can be executed on the target cache page to respond to the data operation request, so that the problem that the cache page has mutual exclusion access conflict can be solved, and the effect of effectively improving the processing performance of the RAID controller can be achieved.
In an alternative embodiment, the preset mutually exclusive flag bit field includes a first preset field and a second preset field; based on a preset mutual exclusion zone bit field in a corresponding cache head of a target cache page, identifying whether the target data operation is a non-mutual exclusion operation comprises the following steps:
identifying the current access type of the target cache page based on a first value corresponding to a first preset field, wherein the first preset field is used for identifying an exclusive mark of the target cache page;
if the current access state of the target cache page is allowed access, identifying whether the target data operation is a non-exclusive operation or not based on a second value corresponding to a second preset field, wherein the second preset field is used for identifying the operation which is allowed to be executed by the target cache page currently.
In an alternative embodiment, identifying the current access type of the target cache page based on the first value corresponding to the first preset field includes:
if the first numerical value is 1, identifying that the current access type of the target cache page is forbidden access;
and if the first value is 0, identifying the current access type of the target cache page as the allowed access.
In an alternative embodiment, identifying whether the target data operation is a non-exclusive operation based on a second value corresponding to the second preset field includes:
determining the maximum non-exclusive access times which correspond to the target data operation and can be executed;
if the second numerical value is smaller than the maximum non-exclusive access times, identifying the target data operation as non-exclusive operation, wherein the second numerical value is the non-exclusive access times of the current accumulated execution of the target cache page;
and if the second value is greater than or equal to the maximum non-exclusive access times, identifying the target data operation as a mutual exclusion operation.
In an alternative embodiment, if the target data operation is a read operation, the method for identifying that the target cache page is in an operable state includes:
caching both the first value and the second value in a temporary variable;
adding 1 to the second numerical value to obtain an updated third numerical value;
And identifying the management state of the target cache page based on a matching result between the first numerical value and the first target numerical value, wherein the first target numerical value is a numerical value which is required to be written into a first preset field for reading operation to be executed, and the management state comprises an operable state or an inoperable state.
In an alternative embodiment, identifying the management state of the target cache page based on the result of the match between the first value and the first target value includes:
if the first numerical value is not matched with the first target numerical value, identifying that the management state of the target cache page is an inoperable state;
if the first value is matched with the first target value, the management state of the target cache page is identified as an operable state, and the value of the preset mutex zone bit field is updated based on the first value and the third value.
In an alternative embodiment, if the target data operation is a read operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field.
In an alternative embodiment, performing a target data operation on a target cache page includes:
reading target cache data from the target cache page in response to the read operation;
subtracting 1 from the third value to obtain an updated fourth value in response to the target cache data being read;
Updating a preset mutual exclusion zone bit field according to the first value and the fourth value;
and responding to successful updating of the preset mutex flag bit field, and finishing the reading operation.
In an alternative embodiment, if the target data operation is a write operation, the method for identifying that the target cache page is in an operable state includes:
caching both the first value and the second value in a temporary variable;
setting the first value to 1 to obtain an updated fifth value;
and identifying the management state of the target cache page based on a matching result between the fifth value and a second target value, wherein the second target value is a value which is to be written into a first preset field when the write operation is to be executed.
In an alternative embodiment, identifying the management state of the target cache page based on the matching result between the first value and the target value to be written into the first preset field includes:
if the fifth numerical value is not matched with the second target numerical value, identifying that the management state of the target cache page is an inoperable state;
and if the fifth value is matched with the second target value, identifying the management state of the target cache page as an operable state, and updating the value of the preset mutex zone bit field based on the fifth value and the second value.
In an alternative embodiment, if the target data operation is a write operation, the maximum number of non-exclusive accesses is a minimum preset threshold corresponding to the second preset field.
In an alternative embodiment, performing a target data operation on a target cache page includes:
writing target cache data into a target cache page in response to the writing operation;
and setting the fifth value to 0 to finish the writing operation in response to the target cache data being written.
In an alternative embodiment, if the target data operation is a buffered data drop operation, receiving a data operation request includes:
monitoring the resource occupancy rate of the cache resource;
if the resource occupancy is greater than or equal to a specified threshold, generating and receiving a data operation request, wherein the data operation request is used for executing cache data disk-dropping operation on target cache data.
In an optional implementation manner, when the target data operation is a buffered data landing operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field.
In an alternative embodiment, performing a target data operation on a target cache page includes:
responding to the buffer data disk-dropping operation, setting the first value to 1, obtaining an updated sixth value, and writing third target data in a target buffer page into a physical storage medium;
Determining a seventh value currently corresponding to the second preset field, and subtracting 1 from the seventh value to obtain an updated eighth value;
updating a preset mutual exclusion zone bit field according to the sixth value and the eighth value;
and when the eighth value is monitored to be 0, confirming that the execution of the buffer data disk-dropping operation is finished, and recovering the target buffer page.
In an alternative embodiment, the first preset field and the second preset field are defined by means of bit fields.
The beneficial effects are that: the first preset field and the second preset field are defined in a bit field mode, so that occupation of memory space by a cache head corresponding to a target cache page can be effectively reduced, and hardware cost is reduced.
In an alternative embodiment, the method further comprises:
if the target data operation is allowed to be executed but the target cache page is in an inoperable state, the target data operation is suspended.
The beneficial effects are that: the cache management method provided by the embodiment is beneficial to improving the utilization rate of cache resources and avoiding busy-wait conditions, thereby being beneficial to improving the performance of the RAID controller for cache management of cache data.
In a second aspect, the present invention provides a cache management apparatus, including:
The receiving module is used for receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data;
the target determining module is used for determining a target cache page where target cache data are located;
the identification module is used for identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in the corresponding cache head of the target cache page;
and the first execution module is used for executing the target data operation on the target cache page if the target data operation is allowed to be executed and the target cache page is in an operable state, so as to respond to the data operation request.
In a third aspect, the present invention provides an electronic device, comprising: the cache management system comprises a memory and a processor, wherein the memory and the processor are in communication connection, the memory stores a computer request, and the processor executes the computer request, so that the cache management method of the first aspect or any corresponding implementation mode is executed.
In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon a computer request for causing a computer to execute the cache management method of the first aspect or any one of the embodiments corresponding thereto.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an operational model of a RAID controller according to the prior art;
FIG. 2 is a flow chart of a cache management method according to an embodiment of the invention;
FIG. 3 is a flow chart of another cache management method according to an embodiment of the invention;
FIG. 4 is a flow chart of a further cache management method according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a method of cache management according to an embodiment of the present invention;
FIG. 6 is a flow chart of another cache management method according to an embodiment of the invention;
FIG. 7 is a flow chart of a method of managing a cache in accordance with an embodiment of the present invention;
FIG. 8 is a block diagram showing a structure of a cache management apparatus according to an embodiment of the present invention;
Fig. 9 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in fig. 1, based on a communication connection between a server host and a PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) board card, the server host sends a data processing request to Input/Output (IO) preprocessing in a RAID controller chip through a PCI-Express bus, further determines a hit cache page in a double rate synchronous dynamic Random Access Memory (DDR) through cache management, and determines a key data structure for managing the cache page from a Static Random-Access Memory (SRAM) through cache management, so that data of a RAID hard disk group is managed through RAID calculation in combination with serial ATA (Serial Advanced Technology Attachment, SATA) driving.
There are three basic operations for a cache page, namely: write operation, read operation, cache page data cache data drop operation. Whether or not a mutually exclusive relationship exists between these operations is as follows:
1) The foreground read and the foreground read do not conflict;
2) The foreground write and the foreground write are mutually exclusive;
3) The foreground write and foreground read are mutually exclusive;
4) The foreground writing and the background cache page disk are mutually exclusive;
5) The foreground reading and the background buffer page landing disk do not conflict, but after the landing disk is completed, the foreground reading and the buffer page resource recovery are in conflict, and the recovery operation can be completed after the read operation is completed.
In view of this, an embodiment of the present invention provides a cache management method, including: receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data; determining a target cache page where target cache data are located; identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in a corresponding cache head of the target cache page; if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request. Through the mutual exclusion zone bit field preset in the cache head data, whether the target data operation can be executed currently or not can be rapidly identified, and further when the target cache page is in an operable state, the target data operation can be executed on the target cache page to respond to a data operation request, so that the problem that the cache page has mutual exclusion access conflict can be solved, and the effect of effectively improving the processing performance of the RAID controller can be achieved.
According to an embodiment of the present invention, there is provided an embodiment of a cache management method, it should be noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer executable requests, and that although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different from that herein.
In this embodiment, a cache management method is provided, which may be used for deploying electronic devices of a RAID controller chip, such as a mobile phone, a tablet computer, etc., and fig. 2 is a flowchart of a cache management method according to an embodiment of the present invention, as shown in fig. 2, where the flowchart includes the following steps:
step S201, a data operation request is received.
In an embodiment of the present invention, a data operation request is used to request that a target data operation be performed on target cache data. The data operation request may be issued by the server host through a PCIE bus. The target data operation may include: a read operation, a write operation, or a buffered data drop operation.
Step S202, determining a target cache page where target cache data is located.
In the embodiment of the invention, in order to facilitate targeted processing of the target cache data, the target cache page where the target cache data is currently located is identified, so as to ensure the effectiveness of the subsequent execution of the target data operation. The determination method of the target cache page is not limited at all, and the determination is performed according to actual requirements.
Step S203, based on the mutually exclusive flag bit field preset in the corresponding cache header of the target cache page, identifies whether the target data operation is allowed to be executed.
In the embodiment of the invention, the target cache page corresponds to a cache header (CacheHead) for managing data in the target cache page. In order to improve the response efficiency of the RAID controller, a mutual exclusion zone bit field is preset in a corresponding cache head of the target cache page, and whether the current access state of the target data operation for the target cache page is a mutual exclusion access operation or not is detected through the numerical value on the mutual exclusion zone bit field, so that the aim of rapidly identifying whether the target data operation is allowed to be executed is fulfilled.
In step S204, if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request.
In the embodiment of the invention, if the target data operation is allowed to be executed, the target operation data is not mutually exclusive operation for the current access state of the target cache page, and when the target cache page is in an operable state, the current target cache page is in an idle state, so that the target data operation can be executed on the target cache page to respond to the data operation request.
According to the cache management method provided by the embodiment, whether the target data operation can be executed currently can be rapidly identified through the mutual exclusion zone bit field preset in the cache head data, and further when the target cache page is in an operable state, the target data operation can be executed on the target cache page to respond to the data operation request, so that the problem that the cache page has mutual exclusion access conflict can be solved, and the effect of effectively improving the processing performance of the RAID controller can be achieved.
In some alternative embodiments, the target data operation is suspended if the target data operation is allowed to execute but the target cache page is in an inoperable state. That is, when the target cache page is in an inoperable state, the current target cache page is characterized as being in an occupied state, such as: occupied by other threads. Therefore, the target data operation is required to be suspended until the target cache page is in an idle state, and the target data operation is executed on the target cache page, so that the utilization rate of cache resources is improved, the busy waiting condition is avoided, and the performance of the RAID controller for cache management of cache data is improved.
In this embodiment, a cache management method is provided, which may be used in the above electronic device, such as a mobile phone, a tablet computer, etc., and fig. 3 is a flowchart of a cache management method according to an embodiment of the present invention, as shown in fig. 3, where the flowchart includes the following steps:
Step S301, a data operation request is received. Please refer to step S201 in the embodiment shown in fig. 2 in detail, which is not described herein.
In step S302, the target cache page where the target cache data is located is determined. Please refer to step S202 in the embodiment shown in fig. 2, which is not described herein.
Step S303, based on the preset mutual exclusion zone bit field in the corresponding cache header of the target cache page, identifying whether the target data operation is allowed to be executed.
Specifically, the preset mutually exclusive flag bit field includes a first preset field and a second preset field, and step S303 includes:
in step S3031, the current access type of the target cache page is identified based on the first value corresponding to the first preset field.
In the embodiment of the present invention, the first preset field is used to identify an exclusive flag of the target cache page. And in order to quickly determine the current access type of the target cache page and avoid invalid access, distinguishing the current access type by a first value corresponding to a first preset field. That is, the values on the first preset field are different, and the corresponding target cache pages are different in current access types. Wherein the current access type includes either prohibited access or allowed access.
In some optional embodiments, step S3031 includes:
And a1, if the first value is 1, identifying the current access type of the target cache page as forbidden access.
And a2, if the first value is 0, identifying the current access type of the target cache page as the allowed access.
Specifically, a first value on the first preset field is preconfigured to be 0 or 1. When the first value is 1, the current access type of the target cache page is forbidden access; when the first value is 0, the current access type of the target cache page is indicated as the allowed access.
In one example, when the first value is 0, the current access type of the target cache page is indicated as forbidden access; when the first value is 1, the current access type of the target cache page is indicated as the allowed access. That is, the current access type of the target cache page corresponding to the first value of 0 or 1 may be set according to the requirement, which is not limited in the present invention.
Therefore, by adopting the setting mode, the efficiency of identifying the current access type of the target cache page can be improved, and whether the target cache page can allow the target data operation to access the target data or not can be conveniently and quickly determined.
In step S3032, if the current access status of the target cache page is permission access, based on the second value corresponding to the second preset field, it is identified whether the target data operation is a non-exclusive operation.
In the embodiment of the present invention, the second preset field is used to identify the operation that the target cache page is currently allowed to perform. If the current access state of the target cache page is allowed access, the current target cache page is characterized to be capable of performing data access, whether the target data operation is a mutual exclusion operation or not is identified according to a second value corresponding to a second preset field, whether the target data operation is a non-mutual exclusion operation or not is identified, and therefore the problem that the cache page has mutual exclusion access conflict is avoided.
In some optional embodiments, step S3032 includes:
and b1, determining the maximum non-exclusive access times which can be executed corresponding to the target data operation.
And b2, if the second value is smaller than the maximum non-exclusive access times, identifying the target data operation as a non-exclusive operation.
And b3, if the second value is greater than or equal to the maximum non-exclusive access times, identifying the target data operation as the exclusive operation.
Specifically, the second value is the current accumulated number of non-exclusive accesses performed by the target cache page. In order to avoid that a certain target data operation occupies a target cache page for a long time, other data operations cannot be effectively executed, and further the performance of cache management is affected, different maximum non-exclusive access times are set for different data operations, and whether the target data operation is a mutual exclusion operation for the current access state of the target cache page or not is identified by comparing the second numerical value with the maximum executable non-exclusive access times corresponding to the target data operation, so that the identification efficiency can be effectively improved, and the problem that the cache page has mutual exclusion access conflict can be timely avoided.
In step S304, if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request. Please refer to step S204 in the embodiment shown in fig. 2 in detail, which is not described herein.
According to the cache management method provided by the embodiment, the current access state of the target cache page can be quickly identified and whether the target data operation can be allowed to be executed or not can be identified through the first preset field and the second preset field in the cache head, so that the target cache page resource can be safely processed under the condition that a plurality of data operations are concurrent, the problem that the target data operation and the access state of the target cache page have mutual exclusion conflict can be effectively solved, the management effect of the cache resource can be effectively improved, and the response efficiency of the RAID controller is improved.
In some optional embodiments, the first preset field and the second preset field are defined by adopting a bit field mode, so that occupation of a memory space by a cache head corresponding to the target cache page can be effectively reduced, and hardware cost is reduced.
In an example, the first preset field may be represented by an include flag, the second preset field may be represented by a non-include cnt, and then the data structure pseudocode of the corresponding cache header of the target cache page may be as follows:
Mutex flag structure {
non-exclusive cnt (3 bits);// non-exclusive counter
Exclude flag (1 bit);// exclusive flag
rsvd (4 bits);// reserved field
}
CacheHead Structure {
Original field
Struct MutexFlag mtx_flag;
}
Wherein, the CacheHead structure refers to a data structure of the cache head; the mutex flag structure refers to a preset mutual exclusion flag bit field; the reserved field belongs to the filling field and is used for guaranteeing the integrity of the data structure.
In some optional embodiments, if the target data operation is a read operation, the method for identifying that the target cache page is in an operable state includes:
step c1, caching the first value and the second value in the temporary variable.
And c2, adding 1 to the second numerical value to obtain an updated third numerical value.
And c3, identifying the management state of the target cache page based on a matching result between the first numerical value and the first target numerical value.
Specifically, after determining the target cache page, to avoid polluting the data, the first value and the second value are cached in the temporary variable. In this application, the read operation belongs to a non-exclusive operation, and since the read operation is allowed to be executed, the second value needs to be added by 1 to update the current number of non-exclusive accesses performed cumulatively, so as to obtain the third value.
The first value is matched with a first target value based on a Compare and Swap (CAS) principle, and then the management state of the target cache page is identified based on the matching result. The first target value is a value to be written into a first preset field when the read operation is to be executed, and the management state comprises an operable state or an inoperable state.
In some alternative embodiments, step c3 includes:
step c31, if the first value does not match the first target value, identifying that the management state of the target cache page is an inoperable state;
and c32, if the first value is matched with the first target value, identifying the management state of the target cache page as an operable state, and updating the value of the preset mutual exclusion zone bit field based on the first value and the third value.
That is, if the first value does not match the first target value, it indicates that the target cache page is currently occupied by another thread and needs to be preempted again, so that the management state of the target cache page can be identified as an inoperable state. If the first value is matched with the first target value, the fact that the target cache page is not occupied by other threads at present is characterized, the target cache page can be directly read, the management state of the target cache page can be recognized as an operable state, and the value of a preset mutual exclusion zone bit field is updated based on the first value and the third value.
In other alternative embodiments, the target data operation is a read operation, and the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field. For example: and if the maximum preset threshold value on the second preset field is 7, the maximum non-exclusive access times are 7, and further, when the second value is used for detecting whether the read operation is the exclusive operation, whether the second value is greater than or equal to 7 can be detected. If the second value is less than 7, then the read operation may be identified as a non-exclusive operation, which may allow the read operation to be performed. If the second value is greater than or equal to 7, then the read operation may be identified as a mutex operation, thereby disallowing the read operation to be performed.
In still other alternative embodiments, in the case where the target operation request is a read operation, step S304 includes:
step d1, responding to a read operation, and reading target cache data from a target cache page;
step d2, responding to the completion of reading the target cache data, subtracting 1 from the third value to obtain an updated fourth value;
step d3, updating a preset mutual exclusion zone bit field according to the first value and the fourth value;
and d4, responding to successful updating of the preset mutual exclusion zone bit field, and finishing the reading operation.
Specifically, in the process of executing the read operation on the target cache page, the target cache data is read from the target cache page, and then after the target cache data is read, the third value is subtracted by 1 to represent that the current read operation is executed, so that the non-exclusive access times of the current accumulated execution can be released, and the updated fourth value is obtained. And updating a preset mutual exclusion zone bit field according to the first value and the fourth value so as to ensure the consistency of the cache data and the thread safety of the current occupied target cache page.
After the updating of the preset mutual exclusion zone bit field is completed, the first numerical value is matched with the first target numerical value again based on the CAS principle, and then when the matching is successful, the current access state of the target cache page is characterized as being in a normal state, and the current access state is not preempted by other threads or is abnormal, so that the completion of the read operation can be determined.
In some alternative implementation scenarios, taking the target operation request as an example of a read operation, the process of performing cache management by the RAID controller may be as shown in fig. 4:
after entering a read operation entrance, storing a numerical value corresponding to a preset mutual exclusion zone bit field in a cache head corresponding to a target cache page into a temporary variable.
If the first value corresponding to the first preset field is 1, the reading operation is suspended.
If the first value corresponding to the first preset field is not 1 (for example, the first value is 0), whether the second value corresponding to the second preset field reaches the maximum preset threshold value corresponding to the second preset field is continuously judged. And if the second value corresponding to the second preset field reaches the maximum preset threshold value corresponding to the second preset field, suspending the reading operation.
And if the second value corresponding to the second preset field does not reach the maximum preset threshold value corresponding to the second preset field, the second value is +1, and a third value is obtained.
And identifying the management state of the target cache page based on a matching result between the first numerical value and the first target numerical value, and acquiring the numerical value corresponding to the preset mutual exclusion zone bit field again if the management state of the target cache page is an inoperable state.
If the management state of the target cache page is an operable state, updating the value of the preset mutex zone bit field based on the first value and the third value.
And in the process of executing the reading operation on the target cache page, reading target cache data from the target cache page, and subtracting 1 from the third value after the target cache data is read, so as to obtain an updated fourth value.
And updating a preset mutual exclusion zone bit field according to the first value and the fourth value so as to ensure the consistency of the cache data and the thread safety of the current occupied target cache page.
After the updating of the preset mutual exclusion zone bit field is completed, the first numerical value is matched with the first target numerical value again based on the CAS principle, and then when the matching is successful, the current access state of the target cache page is characterized as being in a normal state, and the current access state is not preempted by other threads or is abnormal, so that the completion of the read operation can be determined.
In some optional embodiments, if the target data operation is a write operation, the method for identifying that the target cache page is in an operable state includes:
step e1, caching the first value and the second value in the temporary variable.
And e2, setting the first value to be 1, and obtaining an updated fifth value.
And e3, identifying the management state of the target cache page based on the matching result between the fifth numerical value and the second target numerical value.
Specifically, after determining the target cache page, to avoid contaminating the data, the first value and the second value are cached in a temporary variable. In the present application, the write operation belongs to an exclusive operation, and since the write operation is allowed to be executed, the first value needs to be set to 1, so that the current access state of the target cache page is in the exclusive state, thereby avoiding the problem of mutual exclusion conflict in the process of executing the write operation, and further obtaining the fifth value.
The fifth value is matched with the second target value based on a comparison and Swap (CAS) principle, and the management state of the target cache page is identified based on the matching result. The second target value is a value to be written into the first preset field when the writing operation is to be executed.
In some alternative embodiments, step e3 includes:
step e31, if the fifth value does not match the second target value, identifying that the management state of the target cache page is an inoperable state;
and e32, if the fifth value is matched with the second target value, identifying the management state of the target cache page as an operable state, and updating the value of the preset mutual exclusion zone bit field based on the fifth value and the second value.
That is, if the fifth value does not match the second target value, it indicates that the target cache page is currently occupied by another thread and needs to be preempted again, so that the management state of the target cache page can be identified as an inoperable state. If the fifth value is matched with the second target value, the fact that the target cache page is not occupied by other threads at present is indicated, write operation can be directly performed on the target cache page, the management state of the target cache page can be recognized as an operable state, and the value of a preset mutual exclusion zone bit field is updated based on the fifth value and the second value.
In other alternative embodiments, if the target data operation is a write operation, the maximum number of non-exclusive accesses is a minimum preset threshold corresponding to the second preset field. For example: and if the minimum preset threshold value corresponding to the second preset field is 0, the maximum non-exclusive access times are 0, and further, if the read operation is the exclusive operation or not through the second value detection, whether the second value is larger than 0 or not can be detected. If the second value is equal to 0, then the read operation may be identified as a non-exclusive operation, which may allow the write operation to be performed. If the second value is greater than 0, then the write operation may be identified as a exclusive operation, thereby not allowing the write operation to be performed.
In still other alternative embodiments, in the case where the target operation request is a write operation, step S304 includes:
step f1, responding to a writing operation, and writing target cache data into a target cache page;
and f2, responding to the completion of writing the target cache data, setting the fifth value to 0, and completing the writing operation.
Specifically, in the process of executing the write operation on the target cache page, the target cache data is written into the target cache page, and then after the target data is written, the fifth value is set to 0, so that the current access state of the target cache page is in the non-exclusive state, and the write operation is completed.
In some alternative implementation scenarios, taking the target operation request as an example of a write operation, the process of performing cache management by the RAID controller may be as shown in fig. 5:
after entering a write operation entry, storing a numerical value corresponding to a preset mutual exclusion zone bit field in a cache head corresponding to a target cache page into a temporary variable.
If the first value corresponding to the first preset field is 1, suspending the writing operation.
If the first value corresponding to the first preset field is not 1 (for example, the first value is 0), whether the second value corresponding to the second preset field is greater than the minimum preset threshold corresponding to the second preset field is continuously judged. If the second value corresponding to the second preset field is larger than the minimum preset threshold value corresponding to the second preset field, suspending the writing operation.
And if the second value corresponding to the second preset field is equal to or smaller than the minimum preset threshold value corresponding to the second preset field, setting the first value to be 1 to obtain a fifth value.
And identifying the management state of the target cache page based on a matching result between the fifth value and the second target value, and acquiring the value corresponding to the preset mutual exclusion zone bit field again if the management state of the target cache page is an inoperable state.
And if the management state of the target cache page is an operable state, updating the value of the preset mutex zone bit field based on the fifth value and the second value.
And in the process of executing the writing operation on the target cache page, writing the target cache data into the target cache page, and setting the fifth value to 0 after the target data is written, so that the current access state of the target cache page is in a non-exclusive state, thereby completing the writing operation.
In this embodiment, a cache management method is provided, which may be used in the above electronic device, such as a mobile phone, a tablet computer, etc., and fig. 6 is a flowchart of a cache management method according to an embodiment of the present invention, as shown in fig. 6, where the flowchart includes the following steps:
in step S601, a data operation request is received.
Specifically, the step S601 includes:
in step S6011, the resource occupancy of the cache resource is monitored.
In the embodiment of the invention, in order to ensure the durability and the safety of the cache data, the resource occupancy of the cache resource is monitored, so that when the resource occupancy is greater than or equal to the specified threshold, a data operation request for executing the cache data disk-dropping operation on the target cache data can be timely triggered, thereby avoiding influencing the performance of the RAID controller for managing the cache data due to the shortage of memory cache resources. The specified threshold may be understood as a critical value of a resource occupancy that triggers the execution of a cache data drop operation on the target cache data.
If the resource occupancy is greater than or equal to a specified threshold, generating the data operation request; if the resource occupancy is smaller than the specified threshold, the memory cache resources are characterized to be relatively sufficient, and therefore the cache data disk-dropping operation can be omitted.
In step S6012, if the resource occupancy is greater than or equal to the specified threshold, a data operation request is generated and received.
In the embodiment of the invention, the data operation request is used for executing the buffer data disk-dropping operation on the target buffer data. When the resource occupancy is monitored to be greater than or equal to a specified threshold, the current cache resource is characterized as being tense, and further, a data operation request is generated and received by triggering a background task, so that target cache data can be released in time, and the stability and performance of cache management are guaranteed.
In step S602, the target cache page where the target cache data is located is determined.
Step S603, identify whether the target data operation is allowed to be executed based on the preset mutex flag bit field in the corresponding cache header of the target cache page.
In step S604, if the target data operation is allowed to be executed and the target cache page is in an operable state, the target data operation is executed on the target cache page in response to the data operation request.
Specifically, the step S304 includes:
step g1, responding to the buffer data disk-dropping operation, setting the first value as 1, obtaining an updated sixth value, and writing third target data in a target buffer page into a physical storage medium;
step g2, determining a seventh value currently corresponding to the second preset field, and subtracting 1 from the seventh value to obtain an updated eighth value;
step g3, updating a preset mutual exclusion zone bit field according to the sixth value and the eighth value;
and g4, when the eighth value is 0, confirming that the execution of the buffer data disk-dropping operation is finished, and recovering the target buffer page.
Specifically, in the process of executing the cache data landing operation on the target cache page, the first value is set to 1 to obtain an updated sixth value, so that the current access state of the target cache page is in an exclusive state, and the third target data in the target cache page is prevented from being damaged by the write operation in the process of writing the third target data in the target cache page into the physical storage medium. In the present application, the operation of dropping the buffered data belongs to a non-exclusive operation, so when the target buffered data is stored in the physical storage medium, a seventh value corresponding to the second preset field is determined, and the seventh value is subtracted by 1 to obtain an updated eighth value, and then the preset mutually exclusive flag bit field is updated according to the sixth value and the eighth value.
When the eighth value is monitored to be 0, other non-exclusive operations (such as reading operations) currently executed by the target cache page are all completed, so that execution completion of the cache data landing operation can be confirmed, the target cache page is recovered, and data integrity during execution of the other non-exclusive operations can be effectively guaranteed.
The cache management method provided by the embodiment can improve the overall performance of the system for managing the cache data by the RAID controller, thereby achieving the aim of optimizing the IO processing performance.
In some optional implementation scenarios, when the target data operation is a buffered data drop operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field. For example: and if the maximum preset threshold value on the second preset field is 7, the maximum non-exclusive access times are 7, and further, if the cache data disk-dropping operation is the exclusive operation or not through the second value detection, whether the second value is greater than or equal to 7 or not can be detected. If the second value is smaller than 7, the buffered data drop operation can be identified as a non-exclusive operation, and the buffered data drop operation can be allowed to be executed. If the second value is greater than or equal to 7, the buffered data drop operation may be identified as a mutex operation, and the buffered data drop operation is not allowed to be executed.
In other alternative implementation scenarios, taking the target operation request as an example of a cache data drop operation, the process of performing cache management by the RAID controller may be as shown in fig. 7:
after entering a buffer data disc-dropping operation inlet, storing a numerical value corresponding to a preset mutual exclusion zone bit field in a buffer head corresponding to a target buffer page into a temporary variable.
If the first value corresponding to the first preset field is 1, suspending the operation of the buffer data disk.
If the first value corresponding to the first preset field is not 1 (for example, the first value is 0), whether the second value corresponding to the second preset field reaches the maximum preset threshold value corresponding to the second preset field is continuously judged. And if the second value corresponding to the second preset field reaches the maximum preset threshold value corresponding to the second preset field, suspending the operation of the buffer data disc dropping.
And if the second value corresponding to the second preset field does not reach the maximum preset threshold value corresponding to the second preset field, the second value is +1, and a seventh value is obtained.
And identifying the management state of the target cache page based on a matching result between the first numerical value and the first target numerical value, and acquiring the numerical value corresponding to the preset mutual exclusion zone bit field again if the management state of the target cache page is an inoperable state.
If the management state of the target cache page is an operable state, updating the value of the preset mutex zone bit field based on the first value and the third value.
In the process of executing the buffer data disk-dropping operation on the target buffer page, the first value is set to 1, and the updated sixth value is obtained. And subtracting 1 from the seventh value after the target cache data are stored in the physical storage medium to obtain an updated eighth value, and updating a preset mutual exclusion zone bit field according to the sixth value and the eighth value. And when the eighth value is 0, confirming that the execution of the buffer data disk-dropping operation is finished, and recovering the target buffer page so as to ensure the data integrity when other non-exclusive operations are executed.
In yet other alternative implementation scenarios, the process of determining the current access type of the target cache page through the first preset field and the second preset field may be as follows:
1) When the include flag is set (first value is 1), access to the target cache page is prohibited.
2) When the exclusionary flag is not set (the first value is 0), and the non-exclusionary cnt is equal to 0 (the second value=0), non-exclusive (non-exclusionary) access to the target cache page is not allowed, and exclusive (exclusionary) access is allowed.
3) When the exclusionary flag is not set (the first value is 0), the non-exclusionary cnt is greater than or equal to 0 and less than 7 (0 < the second value < 7), non-exclusive (non-exclusionary) access to the target cache page is allowed, and exclusive (exclusionary) access is not allowed.
4) When the include flag is not set (first value is 0) and the non-include cnt is equal to 7 (second value=7), access to the target cache page is prohibited.
Wherein the write operation belongs to an exclusive operation; both read operations and buffered data drop operations are non-exclusive operations.
In other optional implementation scenarios, the cache management method provided by the invention can reduce the memory consumption of the cache head and lower the hardware cost. Because the CAS operation based on the bit domain is adopted, the size of about 3 bytes can be saved by a single cache head, and because the number of the cache heads is usually large, the cost of the RAID controller chip can be effectively reduced.
Furthermore, the purpose of optimizing the overall performance of IO processing can be achieved by limiting the upper limit of the number of times that the read operation occupies the lock, and the overall performance of the RAID controller in a system in which the read operation suppresses the write operation scene can be effectively improved.
In addition, the preset mutual exclusion zone bit field is defined in a bit field mode, so that portability of a chip firmware program can be improved, and a RAID controller can be independent of a Real-time operating system (Real-Time Operating System, RTOS) platform when performing cache management.
The embodiment also provides a cache management device, which is used for implementing the foregoing embodiments and preferred embodiments, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a cache management apparatus, as shown in fig. 8, including:
a receiving module 801, configured to receive a data operation request, where the data operation request is used to request to perform a target data operation on target cache data;
a target determining module 802, configured to determine a target cache page where target cache data is located;
the identifying module 803 is configured to identify whether the target data operation is allowed to be executed based on a preset mutual exclusion flag bit field in the cache header corresponding to the target cache page;
The first execution module 804 is configured to execute the target data operation on the target cache page in response to the data operation request if the target data operation is allowed to be executed and the target cache page is in an operable state.
In some optional embodiments, the preset mutually exclusive flag bit field includes a first preset field and a second preset field; the identification module 803 includes: the first identification unit is used for identifying the current access type of the target cache page based on a first numerical value corresponding to a first preset field, wherein the first preset field is used for identifying an exclusive mark of the target cache page; and the second identifying unit is used for identifying whether the target data operation is a non-exclusive operation or not based on a second value corresponding to a second preset field if the current access state of the target cache page is the allowed access, wherein the second preset field is used for identifying the operation which is allowed to be executed by the target cache page currently.
In some alternative embodiments, the first identification unit comprises: the first judging unit is used for identifying that the current access type of the target cache page is forbidden access if the first numerical value is 1; and the second judging unit is used for identifying the current access type of the target cache page as the allowed access if the first value is 0.
In some alternative embodiments, the second identifying unit includes: a first determining unit, configured to determine a maximum non-exclusive access number that the target data operation corresponds to being executable; the third judging unit is used for identifying the target data operation as the non-exclusive operation if the second numerical value is smaller than the maximum non-exclusive access times, and the second numerical value is the non-exclusive access times of the current accumulated execution of the target cache page; and the fourth judging unit is used for identifying the target data operation as the exclusive operation if the second value is greater than or equal to the maximum non-exclusive access times.
In some alternative embodiments, if the target data operation is a read operation, the identifying means for the target cache page to be in an operable state includes: the first buffer module is used for buffering the first numerical value and the second numerical value in a temporary variable; the first processing unit is used for adding 1 to the second numerical value to obtain an updated third numerical value; and the third identifying unit is used for identifying the management state of the target cache page based on a matching result between the first numerical value and the first target numerical value, wherein the first target numerical value is a numerical value which is required to be written into a first preset field for reading operation to be executed, and the management state comprises an operable state or an inoperable state.
In some alternative embodiments, the third identifying unit includes: the first state determining unit is used for identifying that the management state of the target cache page is an inoperable state if the first numerical value is not matched with the first target numerical value; and the second state determining unit is used for identifying the management state of the target cache page as an operable state if the first value is matched with the first target value, and updating the value of the preset mutual exclusion zone bit field based on the first value and the third value.
In some alternative embodiments, if the target data operation is a read operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field.
In some alternative embodiments, the first execution module 804 includes: the second processing unit is used for responding to the reading operation and reading target cache data from the target cache page; the third processing unit is used for subtracting 1 from the third value to obtain an updated fourth value in response to the completion of reading the target cache data; the first updating unit is used for updating a preset mutual exclusion zone bit field according to the first value and the fourth value; and the first execution unit is used for responding to successful updating of the preset mutual exclusion zone bit field and finishing the reading operation.
In some alternative embodiments, if the target data operation is a write operation, the identifying means for the target cache page to be in an operable state includes: the second buffer unit is used for buffering the first value and the second value in the temporary variable; a fourth processing unit, configured to set the first value to 1, and obtain an updated fifth value; and the fifth processing unit is used for identifying the management state of the target cache page based on a matching result between the fifth numerical value and a second target numerical value, wherein the second target numerical value is a numerical value which is required to be written into a first preset field for executing the writing operation.
In some alternative embodiments, the fifth processing unit comprises: a third state determining unit, configured to identify that the management state of the target cache page is an inoperable state if the fifth value does not match the second target value; and a fourth state determining unit, configured to identify that the management state of the target cache page is an operable state if the fifth value matches the second target value, and update the value of the preset mutex flag bit field based on the fifth value and the second value.
In some alternative embodiments, if the target data operation is a write operation, the maximum non-exclusive access number is a minimum preset threshold corresponding to the second preset field.
In some alternative embodiments, the first execution module 804 includes: a sixth processing unit configured to write target cache data into the target cache page in response to the write operation; and the second execution unit is used for responding to the completion of writing the target cache data, setting the fifth value to 0 and completing the writing operation.
In some alternative embodiments, if the target data operation is a buffered data drop operation, the receiving module 801 includes: the monitoring unit is used for monitoring the resource occupancy rate of the cache resource; and the request receiving unit is used for generating and receiving a data operation request if the resource occupancy is greater than or equal to a specified threshold value, wherein the data operation request is used for executing cache data disk-dropping operation on target cache data.
In some optional embodiments, when the target data operation is a buffered data drop operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field.
In some alternative embodiments, the first execution module 804 includes: the seventh processing unit is used for caching data disc-dropping operation, setting the first value as 1, obtaining an updated sixth value, and writing third target data in the target cache page into the physical storage medium; an eighth processing unit, configured to determine a seventh value currently corresponding to the second preset field, and subtract 1 from the seventh value to obtain an updated eighth value; the second updating unit is used for updating a preset mutual exclusion zone bit field according to the sixth value and the eighth value; and the third execution unit is used for confirming that the execution of the buffer data disc-dropping operation is completed and recovering the target buffer page when the eighth value is monitored to be 0.
In some alternative embodiments, the first preset field and the second preset field are both defined by means of bit fields.
In some alternative embodiments, the apparatus further comprises: and the second execution module is used for suspending the target data operation if the target data operation is allowed to be executed but the target cache page is in an inoperable state.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The cache management apparatus in this embodiment is presented in the form of functional units, where the units refer to ASIC (Application Specific Integrated Circuit ) circuits, processors and memories executing one or more software or fixed programs, and/or other devices that can provide the above described functionality.
The embodiment of the invention also provides an electronic device, which is provided with the cache management device shown in the figure 8.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an electronic device according to an alternative embodiment of the present invention, as shown in fig. 9, the electronic device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process requests executing within the electronic device, including requests stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 9.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores requests executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods shown to implement the above-described embodiments.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The electronic device further comprises input means 30 and output means 40. The processor 10, memory 20, input device 30, and output device 40 may be connected by a bus or other means, for example by a bus connection in fig. 9.
The input device 30 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, trackball, joystick, and the like. The output means 40 may include a display device, auxiliary lighting means (e.g., LEDs), tactile feedback means (e.g., vibration motors), and the like. Such display devices include, but are not limited to, liquid crystal displays, light emitting diodes, displays and plasma displays. In some alternative implementations, the display device may be a touch screen.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.
Claims (18)
1. A method for cache management, the method comprising:
receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data;
determining a target cache page in which the target cache data are located;
identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in a corresponding cache header of the target cache page, wherein the preset mutual exclusion zone bit field comprises a first preset field and a second preset field, the first preset field is used for identifying an exclusive mark of the target cache page, and the second preset field is used for identifying an operation which is allowed to be executed currently by the target cache page;
if the target data operation is allowed to be executed and the target cache page is in an operable state, executing the target data operation on the target cache page to respond to the data operation request;
the identifying whether the target data operation is allowed to be executed based on the preset mutual exclusion zone bit field in the corresponding cache header of the target cache page comprises: identifying the current access type of the target cache page based on a first value corresponding to the first preset field; if the current access state of the target cache page is allowed access, identifying whether the target data operation is a non-exclusive operation based on a second value corresponding to the second preset field includes: determining the maximum non-exclusive access times which correspond to the target data operation and can be executed; if the second numerical value is smaller than the maximum non-exclusive access times, identifying the target data operation as a non-exclusive operation, wherein the second numerical value is the non-exclusive access times of the current accumulated execution of the target cache page; and if the second value is greater than or equal to the maximum non-exclusive access times, identifying the target data operation as a mutual exclusion operation.
2. The method of claim 1, wherein the identifying the current access type of the target cache page based on the first value corresponding to the first preset field comprises:
if the first value is 1, identifying the current access type of the target cache page as forbidden access;
and if the first value is 0, identifying the current access type of the target cache page as the allowed access.
3. The method of claim 1, wherein if the target data operation is a read operation, the method of identifying that the target cache page is in an operable state comprises:
caching both the first value and the second value in a temporary variable;
adding 1 to the second numerical value to obtain an updated third numerical value;
and identifying a management state of the target cache page based on a matching result between the first value and a first target value, wherein the first target value is a value which is required to be written into the first preset field when the read operation is to be executed, and the management state comprises an operable state or an inoperable state.
4. The method of claim 3, wherein the identifying the management state of the target cache page based on the result of the match between the first value and the first target value comprises:
If the first numerical value is not matched with the first target numerical value, identifying that the management state of the target cache page is an inoperable state;
and if the first value is matched with the first target value, identifying that the management state of the target cache page is an operable state, and updating the value of the preset mutex zone bit field based on the first value and the third value.
5. A method according to claim 3, wherein if the target data operation is a read operation, the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field.
6. The method of claim 3, wherein the performing the target data operation on the target cache page comprises:
reading the target cache data from the target cache page in response to the read operation;
subtracting 1 from the third value to obtain an updated fourth value in response to the target cache data being read;
updating the preset mutual exclusion zone bit field according to the first value and the fourth value;
and responding to successful updating of the preset mutual exclusion zone bit field, and completing the reading operation.
7. The method of claim 1, wherein if the target data operation is a write operation, the method of identifying that the target cache page is in an operable state comprises:
caching both the first value and the second value in a temporary variable;
setting the first value to 1 to obtain an updated fifth value;
and identifying the management state of the target cache page based on a matching result between the fifth value and a second target value, wherein the second target value is a value to be written into the first preset field when the write operation is to be executed.
8. The method of claim 7, wherein the identifying the management state of the target cache page based on a result of the match between the first value and a target value to be written to the first preset field comprises:
if the fifth numerical value is not matched with the second target numerical value, identifying that the management state of the target cache page is an inoperable state;
and if the fifth value is matched with the second target value, identifying that the management state of the target cache page is an operable state, and updating the value of the preset mutex zone bit field based on the fifth value and the second value.
9. The method of claim 7, wherein if the target data operation is a write operation, the maximum non-exclusive access number is a minimum preset threshold corresponding to the second preset field.
10. The method of claim 7, wherein the performing the target data operation on the target cache page comprises:
writing the target cache data into the target cache page in response to the write operation;
and setting the fifth value to 0 in response to the target cache data being written to completion, and completing the writing operation.
11. The method of claim 1, wherein receiving the data operation request if the target data operation is a buffered data drop operation comprises:
monitoring the resource occupancy rate of the cache resource;
and if the resource occupancy is greater than or equal to a specified threshold, generating and receiving the data operation request, wherein the data operation request is used for executing cache data disk-dropping operation on target cache data.
12. The method of claim 11, wherein the maximum non-exclusive access number is a maximum preset threshold corresponding to the second preset field when the target data operation is the buffered data drop operation.
13. The method of claim 11, wherein the performing the target data operation on the target cache page comprises:
responding to the buffer data disc-dropping operation, setting the first value to be 1, obtaining an updated sixth value, and writing third target data in the target buffer page into a physical storage medium;
determining a seventh value currently corresponding to the second preset field, and subtracting 1 from the seventh value to obtain an updated eighth value;
updating the preset mutual exclusion zone bit field according to the sixth value and the eighth value;
and when the eighth value is 0, confirming that the execution of the cached data disk-drop operation is finished, and recycling the target cache page.
14. The method of claim 1, wherein the first predetermined field and the second predetermined field are each defined by means of a bit field.
15. The method according to claim 1, wherein the method further comprises:
if the target data operation is allowed to be executed but the target cache page is in an inoperable state, suspending the target data operation.
16. A cache management apparatus, the apparatus comprising:
the receiving module is used for receiving a data operation request, wherein the data operation request is used for requesting to execute target data operation on target cache data;
the target determining module is used for determining a target cache page where the target cache data are located;
the identifying module is used for identifying whether the target data operation is allowed to be executed or not based on a preset mutual exclusion zone bit field in a corresponding cache head of the target cache page, wherein the preset mutual exclusion zone bit field comprises a first preset field and a second preset field, the first preset field is used for identifying an exclusive mark of the target cache page, and the second preset field is used for identifying an operation which is allowed to be executed currently by the target cache page;
the first execution module is used for executing the target data operation on the target cache page if the target data operation is allowed to be executed and the target cache page is in an operable state, so as to respond to the data operation request;
wherein, the identification module includes: the first identification unit is used for identifying the current access type of the target cache page based on a first numerical value corresponding to the first preset field; the second identifying unit is configured to identify, based on a second value corresponding to the second preset field, whether the target data operation is a non-exclusive operation if the current access state of the target cache page is access permission, where the identifying unit includes: determining the maximum non-exclusive access times which correspond to the target data operation and can be executed; if the second numerical value is smaller than the maximum non-exclusive access times, identifying the target data operation as a non-exclusive operation, wherein the second numerical value is the non-exclusive access times of the current accumulated execution of the target cache page; and if the second value is greater than or equal to the maximum non-exclusive access times, identifying the target data operation as a mutual exclusion operation.
17. An electronic device, comprising:
a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein a computer request, the processor executing the cache management method of any one of claims 1 to 15 by executing the computer request.
18. A computer-readable storage medium, wherein the computer-readable storage medium has stored thereon a computer request for causing a computer to perform the cache management method of any one of claims 1 to 15.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311509909.5A CN117234431B (en) | 2023-11-14 | 2023-11-14 | Cache management method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311509909.5A CN117234431B (en) | 2023-11-14 | 2023-11-14 | Cache management method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117234431A CN117234431A (en) | 2023-12-15 |
CN117234431B true CN117234431B (en) | 2024-02-06 |
Family
ID=89093303
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311509909.5A Active CN117234431B (en) | 2023-11-14 | 2023-11-14 | Cache management method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117234431B (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101089829A (en) * | 2007-08-01 | 2007-12-19 | 杭州华三通信技术有限公司 | Shared buffer store system and implementing method |
CN102073533A (en) * | 2011-01-14 | 2011-05-25 | 中国人民解放军国防科学技术大学 | Multicore architecture supporting dynamic binary translation |
CN106537361A (en) * | 2014-07-17 | 2017-03-22 | 高通股份有限公司 | Method and apparatus for flexible cache partitioning by sets and ways into component caches |
CN110362504A (en) * | 2018-04-09 | 2019-10-22 | 英特尔公司 | Management to consistency link and multi-level store |
CN111417934A (en) * | 2017-12-05 | 2020-07-14 | Arm有限公司 | Apparatus and method for processing write operation |
CN112749103A (en) * | 2019-10-31 | 2021-05-04 | 华为技术有限公司 | Data cache system and control method of data cache system |
CN112749111A (en) * | 2019-10-31 | 2021-05-04 | 华为技术有限公司 | Method, computing device and computer system for accessing data |
US11074113B1 (en) * | 2020-05-21 | 2021-07-27 | EMC IP Holding Company LLC | Method and apparatus for performing atomic operations on local cache slots of a shared global memory |
CN116501267A (en) * | 2023-06-27 | 2023-07-28 | 苏州浪潮智能科技有限公司 | Independent redundant disk array card control method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200257630A1 (en) * | 2017-12-18 | 2020-08-13 | Mitsubishi Electric Corporation | Information processing apparatus, information processing method, and computer readable medium |
US11086672B2 (en) * | 2019-05-07 | 2021-08-10 | International Business Machines Corporation | Low latency management of processor core wait state |
-
2023
- 2023-11-14 CN CN202311509909.5A patent/CN117234431B/en active Active
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101089829A (en) * | 2007-08-01 | 2007-12-19 | 杭州华三通信技术有限公司 | Shared buffer store system and implementing method |
CN102073533A (en) * | 2011-01-14 | 2011-05-25 | 中国人民解放军国防科学技术大学 | Multicore architecture supporting dynamic binary translation |
CN106537361A (en) * | 2014-07-17 | 2017-03-22 | 高通股份有限公司 | Method and apparatus for flexible cache partitioning by sets and ways into component caches |
CN111417934A (en) * | 2017-12-05 | 2020-07-14 | Arm有限公司 | Apparatus and method for processing write operation |
CN110362504A (en) * | 2018-04-09 | 2019-10-22 | 英特尔公司 | Management to consistency link and multi-level store |
CN112749103A (en) * | 2019-10-31 | 2021-05-04 | 华为技术有限公司 | Data cache system and control method of data cache system |
CN112749111A (en) * | 2019-10-31 | 2021-05-04 | 华为技术有限公司 | Method, computing device and computer system for accessing data |
US11074113B1 (en) * | 2020-05-21 | 2021-07-27 | EMC IP Holding Company LLC | Method and apparatus for performing atomic operations on local cache slots of a shared global memory |
CN116501267A (en) * | 2023-06-27 | 2023-07-28 | 苏州浪潮智能科技有限公司 | Independent redundant disk array card control method and device |
Also Published As
Publication number | Publication date |
---|---|
CN117234431A (en) | 2023-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2014138411A1 (en) | System and method for tiered caching and storage allocation | |
TWI417724B (en) | Computer execution method, device, and computer program product for managing direct memory access to write page error using substitute page pool | |
CN101211289A (en) | Recovery action management system and method | |
CN110058880A (en) | The simulation of exclusive instruction | |
WO2021004256A1 (en) | Node switching method in node failure and related device | |
CN113722131A (en) | Method and system for facilitating fast crash recovery in a storage device | |
US9442790B2 (en) | Computer and dumping control method | |
US9460014B2 (en) | Sharing local cache from a failover node | |
US7536694B2 (en) | Exception handling in a multiprocessor system | |
CN117234431B (en) | Cache management method and device, electronic equipment and storage medium | |
US10025521B2 (en) | Obtaining additional data storage from another data storage system | |
CN108628761B (en) | Atomic command execution method and device | |
US20220067549A1 (en) | Method and Apparatus for Increasing the Accuracy of Predicting Future IO Operations on a Storage System | |
CN118312102A (en) | IO request processing method and device, storage equipment and storage medium | |
CN105279094A (en) | NAND Flash operation processing method, NAND Flash operation processing device and logic device | |
CN117234729A (en) | Dynamic memory protection method, device, computer equipment and storage medium | |
US20130318310A1 (en) | Processor processing method and processor system | |
US9058270B2 (en) | False sharing detection logic for performance monitoring | |
CN117009258A (en) | File system disk access method, device and equipment | |
CN108733479B (en) | Method for unloading solid state hard disk card and device using same | |
US20150269092A1 (en) | Information processing device and shared memory management method | |
EP4170503A1 (en) | Data reading method, data writing method, device, and system | |
US9239792B2 (en) | Sharing cache in a computing system | |
US7934067B2 (en) | Data update history storage apparatus and data update history storage method | |
CN115840635A (en) | Computing resource management method, electronic device, and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |