The present disclosure relates to the field of data processing. More particularly it relates to transactional memory.
A data processing system may execute a number of threads of data processing. The threads may be executed on the same processing unit, or on separate processing units within the data processing system. Sometimes, the threads may need to access a shared resource and the nature of the data processing operations may be such that once a thread starts interacting with the shared resource, it may be necessary for a set of operations to complete atomically using the resource without another thread accessing the resource in the meantime.
Rather than employing lock-based mechanisms to control exclusive access to at least one target resource in such situations, a technique which has been developed for handling conflicts between threads accessing shared resources involves the use of transactional memory support. In particular, a data processing system may be provided with transactional memory support circuitry to support execution of a transaction, the transaction comprising a sequence of instructions executed speculatively and for which the processing circuitry is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point. If it becomes necessary to abort the transaction before the transaction end point is reached, for example because another thread is performing a conflicting access, then it is necessary to be able to restore the state of the processor to the state that existed before the transaction started.
By using transactional memory support, this can provide a more optimistic approach for handling conflicts between threads accessing shared resources than if a lock-based mechanism is used. In particular, each thread may optimistically start processing a critical section of code assuming that no conflicts with other threads will occur, and then if the end of the critical section is reached without any conflict being detected the results of the transaction can be committed. In cases where conflict is rare, using transactional memory support can improve performance by allowing more threads to concurrently process their critical sections of code.
However, it is typically considered necessary to provide a fallback path within the software being executed on the data processing system, so that forward progress can be guaranteed if it is not possible to complete certain transactions. Such a fallback path may, for example, use the earlier-mentioned lock-based mechanism. However, since use of the fallback path will typically result in serialisation of the threads, and thus result in performance degradation, it is desirable to avoid use of the fallback path unless absolutely necessary.
In one example arrangement, there is provided an apparatus comprising: processing circuitry to perform data processing in response to instructions; and transactional memory support circuitry to support execution of a transaction within a thread of data processing by the processing circuitry, the transaction comprising a sequence of instructions executed speculatively and for which the processing circuitry is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point; the transactional memory support circuitry comprising abort event detection circuitry to cause execution of the transaction to be aborted when an abort event is detected before the transaction has reached the transaction end point, and to cause abort status information to be stored for later reference when determining whether to retry execution of the transaction; wherein when the abort event arises due to a given exception event of a given type, the abort event detection circuitry is arranged to cause syndrome information to be captured for use when seeking to resolve the given exception event, and to cause the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved.
In another example arrangement, there is provided a method of handling transactions in an apparatus, comprising: employing processing circuitry to perform data processing in response to instructions; employing transactional memory support circuitry to support execution of a transaction within a thread of data processing by the processing circuitry, the transaction comprising a sequence of instructions executed speculatively and for which the processing circuitry is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point; aborting execution of the transaction when an abort event is detected by the transactional memory support circuitry before the transaction has reached the transaction end point; on aborting execution of the transaction, storing abort status information for later reference when determining whether to retry execution of the transaction; and when the abort event arises due to a given exception event of a given type, capturing syndrome information for use when seeking to resolve the given exception event, and causing the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved.
In a still further example arrangement, there is provided a computer program for controlling a host data processing apparatus to provide an instruction execution environment, comprising: processing program logic to support execution of a transaction within a thread of data processing, the transaction comprising a sequence of instructions executed speculatively and for which the processing program logic is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point; and abort event program logic to cause execution of the transaction to be aborted when an abort event is detected before the transaction has reached the transaction end point, and to cause abort status information to be stored for later reference when determining whether to retry execution of the transaction; wherein when the abort event arises due to a given exception event of a given type, the abort event program logic is arranged to cause syndrome information to be captured for use when seeking to resolve the given exception event, and to cause the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved.
In a yet further example arrangement, there is provided an apparatus comprising: processing means for performing data processing in response to instructions; and transactional memory support means for supporting execution of a transaction within a thread of data processing by the processing means, the transaction comprising a sequence of instructions executed speculatively and for which the processing means is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point; the transactional memory support means comprising abort event detection means for causing execution of the transaction to be aborted when an abort event is detected before the transaction has reached the transaction end point, and for causing abort status information to be stored for later reference when determining whether to retry execution of the transaction; wherein when the abort event arises due to a given exception event of a given type, the abort event detection means is for causing syndrome information to be captured for use when seeking to resolve the given exception event, and for causing the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved.
The present technique will be described further, by way of illustration only, with reference to examples thereof as illustrated in the accompanying drawings, in which:
Data processing systems employing a transactional memory architecture allow atomic and strongly isolated execution of blocks of instructions forming a transaction. The atomicity ensures that a transaction is seen by other threads (which may also be referred to as agents) as one operation, and the isolation ensures the strict separation between transactional and non-transactional code. Hence, systems employing transactional memory architectures can allow access to a data structure whose composition is dynamic in nature in a way that enables a set of operations to complete atomically using the data structure without a requirement to use locking mechanisms or the like.
By avoiding the use of locking mechanisms or the like this can give rise to significant improvements in performance, as it can allow threads to concurrently process critical sections of code, rather than those threads being forced to execute in a serial manner dependent on the acquisition of a lock. However, it is still typically necessary to provide a fallback path within the software executing on the data processing system, so that in the event that a transaction cannot complete atomically, and hence is aborted, forward progress can still be guaranteed through the use of the fallback path, which may for example employ a locking mechanism (more generally referred to as a mutex (mutual exclusion object) mechanism).
The techniques described herein seek to reduce the reliance on the fallback path, and in particular provide a mechanism that can in some situations seek to resolve the cause of a transaction being aborted, so that that transaction can be retried rather than immediately relying on the fallback path. In situations where retrying of the transaction is successful, this can enable a significant improvement in performance.
In particular, in accordance with the techniques described herein, an apparatus is provided that has processing circuitry for performing data processing in response to instructions, and transactional memory support circuitry for supporting execution of a transaction within a thread of data processing by the processing circuitry. The transaction comprises a sequence of instructions executed speculatively, and for which the processing circuitry is configured to prevent commitment of results of the speculatively executed instructions until the transaction has reached a transaction end point.
There are two ways in which a transaction may finish. Firstly, the transaction may reach the earlier-mentioned transaction end point, meaning that the transaction can be committed, in that its execution has been performed atomically and in a strongly isolated manner. However, alternatively the transaction may be aborted, in a situation where the hardware cannot ensure the atomicity or the strong isolation of the transactional code, for example due to a conflicting access by another thread to one of the shared resources.
Hence, the transactional memory support circuitry may be provided with abort event detection circuitry to cause execution of the transaction to be aborted when an abort event is detected before the transaction has reached the transaction end point. The abort event detection circuitry in that situation causes abort status information to be stored for later reference when determining whether to retry execution of the transaction.
Furthermore, when the abort event arises due to a given exception event of a given type, the abort event detection circuitry is arranged to cause syndrome information to be captured for use when seeking to resolve the given exception event, and to cause the abort status information to identify that a retry of the transaction is suggested at least in the case that the given exception event is resolved. By arranging, in situations where the abort occurs due to a given type of exception event, for syndrome information to be captured that can be used to seek to resolve that exception event, this enables proactive steps to be taken to seek to improve the chances that the transaction will successfully complete if retried, hence allowing for certain transactions to be retried successfully. This can significantly improve performance by avoiding alternative, lower performance, mechanisms being triggered to seek to perform the data processing required by the transaction.
Depending on implementation, the above described technique may be arranged so that the abort status information identifies that a retry of the transaction is always recommended, and hence the retry may be attempted without seeking to determine whether the given exception event has been resolved. However, in an alternative implementation, it is possible for an attempt to be made to resolve the given exception event, and for the abort status information to identify that a retry of the transaction is suggested in situations where it is determined that the given exception event has been resolved.
The exception events that may give rise to the need to abort a transaction can take a variety of forms. For example, those exception events may be exceptions that occur due to instruction execution by the processing circuitry, or could be interrupts received by the apparatus, relating to activities occurring within the system asynchronously to the instruction execution. Further, such exception events may occur due to events requiring a change in privilege level of the processing circuitry (also referred to as a change in exception level), since such privilege level changes are not typically allowed whilst the processing circuitry is within transactional state (i.e. whilst the processing circuitry is executing a transaction).
Furthermore, the techniques described herein can be applied to various different types of exception event, and in particular to any type of exception event where there is an expectation that by capturing suitable syndrome information, there is a possibility of resolving the exception event so that the transaction could be successfully retried. One particular example case where it has been found that significant performance benefits can be realised by adopting the techniques described herein is in relation to page faults. In particular, whilst page faults may represent permanent faults, for example because the process being executed by the processing circuitry does not have suitable security/permission rights to access particular ranges of addresses in memory, it is often the case that page faults occur for a much more benign reason, in particular because the memory page referenced by an address has not yet been mapped into the processor's page tables.
Such benign page fault exception events can be resolved, for example by using operating system software to update the required mappings so that when execution is resumed the page fault no longer arises. However, in typical transactional memory techniques, no distinction may be made between the different types of exception events, and accordingly the use of the fallback path would often be adopted instead to seek to make forward progress. For instance, in such implementations the abort status information may merely capture that the abort occurred due to an operation being attempted in transactional state that was architecturally prohibited in transactional state. It may hence be expected that retrying the transaction is not appropriate, and that instead the fallback path should be used. However, by using the techniques described herein, it is possible to allow for steps to be taken to seek to resolve certain types of exception event, thereby improving the likelihood that the transaction can be successfully retried, and thereby avoiding the use of any fallback mechanism in such instances.
In one example implementation, when the abort event arises due to an exception event of a type other than the given type, the abort event detection circuitry is arranged to cause the abort status information to identify that a retry of the transaction is not recommended. Hence, a retry of the transaction can be avoided in situations where it is not considered appropriate to seek to use the techniques described herein in order to seek to resolve an exception event. In particular, it is realised that there are certain types of exception event for which there is no prospect of resolving the exception event, and accordingly for which a retry of the transaction would not achieve any useful result. Hence, the techniques described herein can be limited to certain specific exception event types, such as the earlier-mentioned page fault exception.
In one example implementation, the processing circuitry may be arranged, following abort of the transaction, to reference the abort status information in order to determine whether to retry the transaction, or whether instead to employ a fallback path provided by the software being executed on the processing circuitry, the fallback path providing a non-transaction based mechanism for performing the data processing required by the transaction. As discussed earlier, the fallback path can be used to ensure that forward progress can be made. Purely by way of example, if multiple threads are seeking to execute transactions concurrently with each other, and the accesses performed by those threads consistently give rise to conflicts, resulting in the need to abort the transactions, then forward progress could be made by using a fallback path that adopted the earlier described lock-based mechanism, so as to allow the processing required by each of those transactions to be performed sequentially.
There are a number of different ways in which the syndrome information can be captured, and an attempt can be made to seek to resolve the exception event. In one example implementation, the abort event detection circuitry is arranged to cause the syndrome information to be captured by causing that syndrome information to be stored within a syndrome register, and is then arranged to cause the abort status information to identify that a retry of the transaction is suggested by arranging for the abort status information to identify that the abort event arose due to an exception of the given type. The processing circuitry can then be arranged, on detecting with reference to the abort status information that the abort event arose due to an exception of the given type, to execute a resolve function that references the syndrome register in order to seek to resolve the exception using the syndrome information. The processing circuitry can then be further arranged, following completion of the resolve function, to seek to retry the transaction.
Hence, considering the earlier specific example where the exception event type of interest is a page fault exception, the syndrome register can be used to capture as syndrome information the address giving rise to the page fault, which may for example be the virtual address specified by the relevant instruction being executed. Further, the abort status information may be arranged to specifically identify that the abort event arose due to a page fault. The processing circuitry (for example as a result of the software executing on the processing circuitry) can then detect that a page fault gave rise to the abort of the transaction, and can take steps to seek to resolve the page fault, using the address captured within the syndrome register. As such functionality is implemented outside of the critical section of code that is seeking to be performed as a transaction, any suitable function can be adopted in order to seek to invoke and resolve the page fault. As a particular example, a helper function could be used that seeks to load a value from the address stored in the syndrome register and then store this value back to the same location. Typically that activity will invoke the page fault, and the earlier described steps, for example by branching to the operating system software, can be used to update the required page mappings, so that such a page fault will no longer occur. After such steps have been taken, the transaction can be retried with an increased chance of success.
However, there are other mechanisms that can be used to capture the required syndrome information and use that information to resolve the exception. For example, rather than capturing the required syndrome information in a syndrome register, and then ensuring the software executing on the processing system has been adapted to seek to resolve the exception event, the abort event detection circuitry may be arranged to trigger execution of an exception handling routine as part of the activity of aborting the transaction. During that process, the syndrome information can be captured by passing that syndrome information to the exception handling routine. Execution of the exception handling routine by the processing circuitry then seeks to resolve the exception using the syndrome information. When adopting such a mechanism, the abort event detection circuitry can then be further arranged to cause the abort status information to be stored once the exception handling routine has been completed. Such an approach avoids the need for a specific syndrome register to be architecturally exposed, but in some implementations such a syndrome register could still be provided if desired. Further, it means that the abort status information can be adapted dependent on the outcome of the exception handling routine.
In one example implementation, the abort status information is arranged to identify that a retry of the transaction is suggested when execution of the exception handling routine causes the exception to be resolved. Conversely, the abort status information may be arranged to identify that a retry of the transaction is not recommended when execution of the exception handling routine causes the exception to remain unresolved.
It should be noted that when using this alternative mechanism, there is no requirement for the abort status information to identify the exception type that gave rise to the abort event, since an attempt to seek to resolve the exception was taken as part of the abort process, through direct triggering of a suitable exception handling routine. Nevertheless, if desired, the abort status information can be further arranged to identify that the abort event arose due to an exception of the given type, as in some implementations it may still be considered useful to capture that information.
As mentioned earlier, the given type of exception to which the present techniques are applied can be varied dependent on implementation, but in one example implementation is a page fault exception. By causing the abort status information to identify that a retry of the transaction is suggested following abort of the transaction due to the given exception being a page fault exception, the apparatus is enabled to successfully retry the transaction in the event that the page fault exception is a transient exception, thereby avoiding a need to employ the fallback path provided by the software being executed on the processing circuitry. A transient exception is an exception that will not necessarily occur again if the transaction is retried, and may also be referred to herein as a resolvable exception, since as discussed above certain steps can be implemented with the aim of resolving the issue that gave rise to the exception previously, and hence avoiding the exception occurring again if the transaction is retried. Such transient exceptions should be contrasted with permanent exceptions which cannot be resolved, and hence which do not lend themselves to the use of the technique described herein, as there is no expectation that a retry of the transaction will be any more likely to succeed than the previous attempt made to execute the transaction.
Transactional code within a program can be identified in a variety of ways, but in one example implementation the sequence of instructions forming the transaction is delimited by a transaction start instruction and a transaction end instruction. A number of processes can be implemented on execution of a transaction start instruction. For example, checks may be made to determine whether it is possible to successfully enter transactional state, which would allow the code of the transaction to then be executed. Further, assuming transactional state can be successfully entered, the transactional memory support circuitry may comprise restoration state storage circuitry to store transaction restoration state data that is captured in response to the transaction start instruction, such transaction restoration state data capturing sufficient state data about the system to enable that state to be restored in the event that the transaction in due course needs to be aborted.
In implementations where the handling of the abort event directly causes an exception handling routine to be triggered, then in one example implementation the transactional memory support circuitry may be arranged to cause the transaction restoration state data to be restored before the exception handling routine is triggered. Accordingly, by the time the exception handler is triggered, processing is then proceeding along a non-speculative code path.
There are a number of ways in which the abort status information can be updated in the event of an abort of the transaction. In one example implementation, the abort event detection circuitry is arranged, in response to detection of the abort event, to cause the transaction start instruction to be re-executed by the processing circuitry in order to cause the abort status information to be stored for later reference when determining whether to retry execution of the transaction. Hence, in such implementations, execution of the transaction start instruction can be used as a mechanism to capture the required abort status information, and in this instance the re-execution of the transaction start instruction will determine that the transactional state cannot be entered, and the abort status information will be updated to identify the reasons why.
There are a number of steps that can be taken on occurrence of the earlier-mentioned transaction end instruction. However, in summary, when the transaction end instruction is reached, this means that the transaction can be successfully completed. Accordingly, the processing circuitry may be configured to prevent commitment of results of the speculatively executed instructions of the transaction until the transaction end instruction is reached.
Whilst the threads of data processing may execute directly on the host hardware of the apparatus, in an alternative arrangement a corresponding computer program may be provided for controlling a host data processing apparatus to provide an instruction execution environment for execution of threads of data processing. The computer program may comprise processing program logic to support execution of a transaction within a thread of data processing (in a similar way to the support for transactions discussed above for a hardware implementation). Further abort event program logic may be provided that causes execution of the transaction to be aborted when an abort event is detected before the transaction has reached a transaction end point, and which causes abort status information to be stored for later reference when determining whether to retry execution of the transaction. When the abort event arises due to a given exception event of a given type, the abort event program logic may cause syndrome information to be captured for use when seeking to resolve the given exception event, and may also cause the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved.
Hence, a computer program may be provided which presents, to software executing above the computer program, a similar instruction environment to that which would be provided by an actual hardware apparatus having the features discussed above, even though there may not be any actual hardware providing these features in the host computer executing the computer program. Instead, the computer program, which may for example be a simulator or a virtual machine, may emulate the functionality of the hardware architecture by providing program logic (such as sets of instructions or data structures) which enables a generic host data processing apparatus to execute code intended for execution in an apparatus with transactional memory support, in a manner compatible with the results that would be achieved on the apparatus with transactional memory support. The computer program may be stored on a storage medium, and the storage medium may be a non-transitory storage medium.
Particular examples will now be described with reference to the Figures.
The apparatus 2 also has transactional memory support circuitry 20 which provides various resources for supporting hardware transactional memory (HTM). The HTM resources in the transactional memory support circuitry 20 may include for example speculative result storage 22 for storing speculative results of transactions, address tracking circuitry 24 for tracking the addresses accessed by a transaction, and abort event detection circuitry 26 for detecting abort events that require a transaction to be aborted. Such abort events can take a variety of forms. For example, an abort event may arise due an exception event occurring during a transaction, or due to conflicts between data accesses made by a transaction and data accesses made by other threads. The transactional memory support circuitry 20 may also include restoration state storage circuitry 28 for storing a snapshot of the architectural state data from the architectural registers 6 at the start of a transaction, so that this state can be restored to overwrite the speculative results of the transaction when a transaction is aborted.
The software executing on the apparatus 2 can be arranged to identify critical sections of code that are to be executed as a transaction. In one example implementation such critical sections of code are delimited by a transaction start instruction and a transaction end instruction, but alternatively any suitable mechanism for identifying blocks of code to be executed as transactions could be used. However, as discussed earlier, it is not guaranteed that it will be possible in all situations to execute the desired sections of code as transactions since, for example, data access conflicts between multiple threads concurrently seeking to execute transactions can result in transactions needing to be aborted. Hence, the program code will typically include a fallback path that can be used in order to provide a non-transaction based mechanism for performing the data processing required by the transaction, and in the event of transactions aborting that fallback path can be invoked in order to make forward progress.
However, as discussed earlier, it is desirable to only use the fallback path when absolutely necessary, as such a fallback path will typically require serialisation of the threads, and accordingly can result in performance degradation. In accordance with the techniques described herein, the abort event detection circuitry 26 is arranged so that, when an abort of a transaction is necessary due to an exception event of a given type, certain steps are taken to seek to resolve the reason for that exception occurring. The transaction can then be retried, and if successful the use of the fallback path can hence be avoided in that scenario.
The exception event type which causes the abort event detection circuitry 26 to take such steps may vary dependent on implementation, but for the purposes of the following discussion it will be assumed that the exception event type of interest is a page fault exception. When a page fault occurs, it has been found that in many situations that page fault can be resolved. In particular, whilst page faults can effectively represent permanent exceptions, for example because the process being executed does not have the required security or permission rights to access a region of memory seeking to be addressed, it is quite common that instead the page faults are effectively transient, for example due to the required pages of memory not yet being mapped into the processor's page tables. This can be resolved by standard mechanisms, for example by taking an exception to transition to operating system level code which has the appropriate level of privilege to handle this transient page fault, and hence which can update the relevant mappings so that when execution is resumed the page fault no longer occurs.
However, such a transition in privilege level cannot typically occur whilst within a transaction, and hence instead the transaction is aborted. In accordance with the techniques described herein, abortion of a transaction due to a page fault exception can be distinguished from other types of exception event that have given rise to an abort of the transaction, thereby enabling a different course of action to be taken in respect of such page fault exceptions. In particular, as will be discussed below, instead of merely deciding that the processing required by the transaction should instead be implemented using the fallback path, steps can be taken to seek to resolve the reason for the page fault exception arising, with the transaction then being retried. In situations where the page fault is indeed resolved, this can give rise to significant performance benefits by reducing occurrences where the fallback path needs to be utilised.
In accordance with the techniques described herein, when the abort event arises due to a page fault exception, the abort event detection circuitry 26 may be arranged to cause syndrome information to be captured for use when seeking to resolve the page fault exception, and in addition can cause abort status information captured when an abort occurs to identify that a retry of the transaction is suggested. This information in the abort status information is effectively a hint, indicating whether it is considered appropriate to retry the transaction or not. How the abort status information is utilised can vary dependent on implementations but, based on this hint, at least in certain situations the processing circuitry (or more particularly the software executing thereon) may reattempt to execute the transaction.
The syndrome information can be captured in a variety of ways, and indeed the information will take different forms dependent on the type of exception event for which the above described technique is being employed. However, for the specific example of a page fault exception, then the syndrome information may take the form of a page fault address identifying the address that the processing circuitry was seeking to access that gave rise to the page fault exception. This will for example specify a virtual address, and it may be that at the time of execution that virtual address was not able to be mapped to a physical address due to the processing circuitry not having access to appropriate page mapping information. In one example implementation, a syndrome register 40 may be provided within the system, into which that page fault address can be written by the abort event detection circuitry 26 in the event of detecting a page fault exception giving rise to the need to abort a transaction.
The above-mentioned abort status information, which is also referred to herein as transaction status information, can be stored in a variety of locations, and in one example implementation is stored within a register 35 forming one of the architectural registers 6. That transaction status register 35 can be populated with a variety of information that can be used to identify the reason for the failure of the transaction, but in accordance with one example implementation described herein is adapted so as to specifically identify a situation where the failure of the transaction resulted from a page fault exception. The transaction status information within the register 35 may also provide a retry field, which can be set or cleared to distinguish between situations where a retry of the transaction is suggested and situations where a retry of the transaction is not recommended, for example because it is not expected that a retry of the transaction will be successful. This information can then be used by the software executing on the processing circuitry when determining whether to retry the transaction, or whether instead to adopt the fallback path mechanism.
However, if the transaction fails, then the restoration state in storage 28 will be used to restore the processor state to the state that existed before the transaction was started. Further, the transaction status information (i.e. the earlier-mentioned abort status information) will be updated to a non-zero value, and accordingly will cause the “else” section of code shown in
Exception events can take a variety of forms, for example exceptions that occur due to instruction execution, interrupts that occur asynchronously to instruction execution, and exceptions that occur due to privilege level changes, and typically any of these types of exception event are not allowed to occur whilst the processing circuitry is in transactional state. Hence, if a page fault occurs inside a transaction, the transaction will typically abort, and re-execution of the transaction start instruction will return a non-zero value to form the abort status information. This abort status information may for example indicate that an operation was attempted in transactional state that was architecturally prohibited, and a retry hint may indicate that the transaction is unlikely to succeed if retried. However, with such information there may be no ability to detect a form of failure that might be transient, and hence for which a successful retry of the transaction may be possible if the reasons for the exception can be resolved. Without the use of the technique described herein it may typically not be known which instruction caused the failure and whether the failure was due to a page fault exception or some other type of exception.
Whilst reattempting to execute the transaction is architecturally permitted in some systems, it is expected that this would likely lead to the same failure, and accordingly it is typically the case that the program will then steer the program counter towards the fallback path. This in turn will cause other threads to abort their transactions since the lock address will typically be added to the read set of those transactions, and accordingly acquisition of the lock will cause the other transactions to abort. Those other threads will then need to wait for the lock to be released before they can resume execution of the code. This can ultimately mean that a single page fault occurring within a transaction can cause an entire system to stall except for one thread. Indeed, it has been observed that for certain programs this can mean that a pathological performance degradation is experienced when seeking to execute transactions within those programs, due to an abundance of page faults occurring inside the transactions.
In particular,
If it is determined that the transactional state can successfully be entered, then the abort status information is initialised at step 115. This can be done in a variety of ways, but in the implementation shown in
The abort status information can take a variety of forms, but in one specific example implementation comprises 64 bits of information that are produced by execution of the TSTART instruction to identify whether transactional state has been successfully entered, or to capture the reasons why transactional state has not been successfully entered (in the event that step 110 is reached). As shown in
Assuming the transaction state is successfully entered, then following step 120 the processing circuitry begins executing the instructions of the transaction at step 125. Whilst performing execution of the transaction, it is determined at step 130 whether the transaction commit point has been reached, which in one example implementation occurs when a transaction end instruction (also referred to herein as a transaction commit (TCOMMIT) instruction) is encountered. However, in the absence of reaching the transaction commit point, it is determined at step 135 whether the transaction needs to abort. As discussed earlier a variety of scenarios can give rise to the need to abort the transaction, but assuming the transaction does not need to be aborted the process returns to step 130.
It will be appreciated that at some point the transaction commit point will be reached or it will be determined that the transaction needs to be aborted. If the transaction commit point is reached, then at step 140 the speculative state created during the transaction (i.e. that information stored within the speculative result storage 22) is committed, and accordingly the restoration state can thereafter be discarded or permitted to be overwritten. At this point, processing of the transaction has successfully completed.
However, if it is determined at step 135 that it is necessary to abort the transaction, it is then determined at step 145 whether the abort is due to an exception event. As discussed earlier, there are other reasons that can give rise to the need to abort the transaction, for example the earlier-mentioned load/store conflict discussed with reference to
If at step 145 it is determined that the abort is due to an exception event, it is then determined at step 155 whether the exception event is of a determined type. In the example discussed herein, it will be assumed that the determined type is a page fault exception, but it will be also be appreciated that the techniques described herein are not limited to use in association with page fault exceptions, and any other suitable form of exception could also be processed in the manner described herein. If the exception event is not due to the determined type of exception, then the process proceeds to step 150, where again the restoration state is restored and the abort status information is updated. For exception events, the information captured within the abort status information might typically identify that a transaction retry is not recommended, since it may be expected that such a retry of the transaction will also result in failure.
However, if it is determined at step 155 that the exception event is of the determined type, for example is a page fault exception, then at step 160 the restoration state is again restored, but in addition steps are taken to allow the exception event to be resolved, and the abort status information is updated to identify that a retry of the transaction is suggested, at least in the event that the exception event is resolved. There are various ways in which steps can be taken to seek to resolve the exception event, and two alternative examples will be discussed herein with reference to
At step 210, the abort status information is updated to identify that the transaction failed due to the determined type of exception event. Hence, considering the example of a page fault exception, the abort status information created as a result of the re-execution of the TSTART instruction is modified so that it unambiguously identifies that the transaction failed due to a page fault instead of any other type of exception.
When it is determined appropriate to consider a retry of the transaction at step 215, then at step 220 it is determined whether the transaction status information identifies that the failure was due to the determined type of exception event, i.e. for the example given above whether the transaction failed due to a page fault exception. If not, then at step 225 the fallback is employed rather than retrying execution as a transaction.
However, if it is determined from the transaction status information that the failure was due to the determined type of exception event, then at step 230 code is executed to seek to resolve the exception event. This code can take a variety of forms, and indeed could be any helper function that seeks to re-invoke the page fault, and thereby cause the page fault to be resolved. It should be noted that at this point the code being executed is outside of the critical section of code defined by the transaction, and accordingly there is a great deal of flexibility as to the mechanisms that can be used to seek to resolve the exception event. At this point, the information stored within the syndrome register 40 is referenced, since as discussed earlier that will identify relevant information. In particular, for a page fault exception, it will identify the virtual address that gave rise to the page fault exception occurring, and accordingly a further access to that virtual address can be used as a mechanism for re-invoking the page fault, and seeking a resolution of that page fault exception. As will be discussed with reference later to
Following execution of the code at step 230, a retry of the transaction is attempted at step 235. In one example implementation this is achieved by returning to the processing at the top of
At step 260, it is determined whether the exception has been resolved by virtue of execution of the exception handler, and hence it is determined whether the exception was a transient exception. If it was not, then at step 265 the transaction status information is updated to identify that an error has occurred, and the retry bit is cleared. In particular, it is expected that a retry of the transaction is unlikely to be successful, and hence by clearing the retry bit it can be indicated that a retry of the transaction is not recommended.
However, if at step 260 it is determined that the exception has been resolved, then at step 270 the transaction status information can be updated to identify that the transaction failed, but that it should be retried. In particular, a retry of the transaction is recommended, since there is an expectation that a retry of the transaction will be successful.
When adopting the approach of
Irrespective of which of the above approaches is taken (i.e. whether the approach of
As also shown in
As also shown in
By virtue of the technique illustrated schematically in
Further, if the page fault is permanent and hence cannot be resolved (for example due to the code seeking to access the memory address in question having insufficient security/permission rights), then the program will typically fail and exit as per normal expected behaviour.
To the extent that example implementations have previously been described with reference to particular hardware constructs or features, in a simulated implementation equivalent functionality may be provided by suitable software constructs or features. For example, particular circuitry may be implemented in a simulated implementation as computer program logic. Similarly, memory hardware, such as a register or cache, may be implemented in a simulated implementation as a software data structure. In arrangements where one or more of the hardware elements referenced in the previously described examples are present on the host hardware (for example the host processor 415), some simulated implementations may make use of the host hardware, where suitable.
The simulator program 405 may be stored on a computer readable storage medium (which may be a non-transitory medium), and provides a virtual hardware interface (instruction execution environment) to the target code 400 (which may include applications, operating systems and a hypervisor) which is the same as the hardware interface of the hardware architecture being modelled by the simulator program 405. Thus, the program instructions of the target code 400 may be executed from within the instruction execution environment using the simulator program 405, so that a host computer 415 which does not actually have the hardware features of the apparatus 2 discussed above can emulate these features. The simulator program 405 may include processing program logic 420 to support execution of a transaction within a thread of data processing, and abort event program logic 425 to cause execution of the transaction to be aborted when an abort event is detected before the transaction has reached a transaction end point. The abort event program logic will cause abort status information to be captured for later reference when determining whether to retry execution of the transaction, and can implement the functionality discussed earlier in order to cause syndrome information to be captured, and for the abort status information to identify that a retry of the transaction is suggested at least in the event that the given exception event is resolved. Hence, the various program logic functions can provide functionality that is equivalent to the corresponding hardware blocks shown in
In the present application, the words “configured to . . . ” are used to mean that an element of an apparatus has a configuration able to carry out the defined operation. In this context, a “configuration” means an arrangement or manner of interconnection of hardware or software. For example, the apparatus may have dedicated hardware which provides the defined operation, or a processor or other processing device may be programmed to perform the function. “Configured to” does not imply that the apparatus element needs to be changed in any way in order to provide the defined operation.
Although illustrative embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes, additions and modifications can be effected therein by one skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims. For example, various combinations of the features of the dependent claims could be made with the features of the independent claims without departing from the scope of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
2014867.2 | Sep 2020 | GB | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/GB2021/051993 | 8/2/2021 | WO |