Source: http://www.google.com/patents/US20070226440
Timestamp: 2016-10-26 05:21:20
Document Index: 366703347

Matched Legal Cases: ['art 312', 'art 314', 'art 314', 'art 302', 'art 318', 'art 354', 'art 348', 'art 350', 'art 342', 'art 366', 'art 320', 'art 310', 'art 324']

Patent US20070226440 - Read-copy-update (RCU) operations with reduced memory barrier usage - Google PatentsSearch Images Maps Play YouTube News Gmail Drive More »Sign inPatentsRead-copy-update (RCU) is performed within real-time and other types of systems, such that memory barrier usage within RCU is reduced. A computerized system includes processors, memory, updaters, and readers. The updaters update contents of a section of the memory by using first and second sets of per-processor...http://www.google.com/patents/US20070226440?utm_source=gb-gplus-sharePatent US20070226440 - Read-copy-update (RCU) operations with reduced memory barrier usageAdvanced Patent SearchTry the new Google Patents, with machine-classified Google Scholar results, and Japanese and South Korean patents.Publication numberUS20070226440 A1Publication typeApplicationApplication numberUS 11/738,482Publication dateSep 27, 2007Filing dateApr 21, 2007Priority dateMar 24, 2006Also published asUS7818306Publication number11738482, 738482, US 2007/0226440 A1, US 2007/226440 A1, US 20070226440 A1, US 20070226440A1, US 2007226440 A1, US 2007226440A1, US-A1-20070226440, US-A1-2007226440, US2007/0226440A1, US2007/226440A1, US20070226440 A1, US20070226440A1, US2007226440 A1, US2007226440A1InventorsPaul E. McKenney, Suparna BhattacharyaOriginal AssigneeMckenney Paul E, Suparna BhattacharyaExport CitationBiBTeX, EndNote, RefManPatent Citations (21), Referenced by (21), Classifications (10), Legal Events (3) External Links: USPTO, USPTO Assignment, EspacenetRead-copy-update (RCU) operations with reduced memory barrier usage
US 20070226440 A1Abstract
incrementing a per-task read-lock-nesting counter corresponding to a task performing the read-side critical section; where the per-task read-lock-nesting counter is equal to a third predetermined value,
prior to incrementing the per-task read-lock-nesting counter corresponding to the task performing the read-side critical section, disabling preemption and/or interrupts; and, after setting the per-task flip-counter bit corresponding to the task equal to the local flip-counter bit, enabling preemption and/or interrupts. 7. The method of claim 5, further comprising, to release the effective read lock in performing the read-side critical section,
decrementing the per-task read-lock-nesting counter corresponding to the task performing the read-side critical section; where the per-task read-lock-nesting counter is equal to zero,
prior to decrementing the per-task read-lock-nesting counter corresponding to the task performing the read-side critical section, disabling preemption and/or interrupts; and, enabling preemption and/or interrupts. 9. The method of claim 1, further comprising periodically performing:
a plurality of processors; memory accessible by the processors; one or more updating tasks to update contents of a section of the memory by using a first set and a second set of per-processor counters, a first set and a second set of per-processor need-memory-barrier bits, and a global flip-counter bit specifying which of the first set or the second set of the per-processor counters and the per-processor need-memory-barrier bits is a current set and which is a last set; and, one or more reading tasks to read the contents of the section of the memory by using the first set and the second set of per-processor counters, the first set and the second set of per-processor need-memory-barrier bits, and the global flip-counter bit, wherein no memory barriers are executed by the reading tasks. 12. The computerized system of claim 11, wherein an updating task is to update the contents of the section of the memory by:
copying the global flip-counter bit to a local flip-counter bit; where attempting to acquire a flip-counter-bit lock on the global-flip-counter bit is successful, where the global flip-counter bit has not changed while acquiring the flip-counter-bit lock, where any of the last set of per-processor need-memory-barrier bits is equal to a value other than zero, and where a sum of all of the last set of per-processor counters is equal to a first predetermined value,
13. The computerized system of claim 11, wherein a reading task is to read the contents of the section of the memory by first acquiring an effective read lock in performing a read operation, by:
incrementing a per-task read-lock-nesting counter corresponding to a task performing the read operation; where the per-task read-lock-nesting counter is equal to a third predetermined value,
14. The computerized system of claim 11, wherein each of the processors if further to periodically:
15. The computerized system of claim 11, wherein each of the processors if further to, in response to receipt of an inter-processor interrupt:
a tangible computer-readable medium; and, means in the medium for updating and reading a section of memory accessible by a plurality of processors by using a first set and a second set of per-processor counters, a first set and a second set of per-processor need-memory-barrier bits, and a global flip-counter bit specifying which of the first set or the second set of the per-processor counters and per-processor need-memory-barrier bits is a current set and which is a last set, wherein the means does not execute any memory barriers in reading the section of memory. 17. The article of manufacture of claim 16, wherein the means is for updating the contents of the section of the memory by:
18. The article of manufacture of claim 16, wherein the means is for reading the contents of the section of the memory by first acquiring an effective read lock in performing a read operation, by:
incrementing a per-task read-lock-nesting counter corresponding to a task performing the read operation; where the per-task read-lock-nesting counter is equal to one,
19. The article of manufacture of claim 16, wherein the means is further for periodically:
20. The article of manufacture of claim 16, wherein the means is further for, in response to receipt of an inter-processor interrupt:
[0001] The present patent application is a continuation-in-part of the previously filed and pending patent application entitled “Read-copy-update (RCU) operations with reduced memory barrier usage,” filed on Mar. 24, 2006, and assigned Ser. No. 11/388,364.
[0002] The present invention relates to performing read-copy-update (RCU) critical sections in such a way that memory-barrier atomic-instruction usage is reduced, as is important, for instance, in real-time systems.
[0003] Computerized systems are most generally used to maintain data. Data is created, modified, deleted, and read. In some types of systems, the worst-case time it takes to perform such operations is not important. That is, delays can be introduced when creating, modifying, deleting, and reading data, without affecting the needed average performance of the computerized system as a whole.
[0004] However, other types of systems, known as real-time systems, require that such worst-case delays be kept to a minimum, so that such systems essentially perform data-related operations in real-time, or in near-real-time. A real-time system may thus be considered a computer system that responds to operations by immediately updating the appropriate data and/or generating responses quickly enough to ensure that the system meets its response-time criteria. Therefore, delays that are introduced when creating, modifying, deleting, and reading data can hamper a system's ability to operate in real-time.
[0005] Some types of computerized systems use multiple processors. Such multiple-processor systems have to ensure serialized execution of critical sections of computer code that manipulate shared data structures. For example, if the data of a shared data structure is updated by one processor before it is read by another processor, it is important to ensure the order of these operations. That is, it is important to ensure that the data read by the latter processor is the updated version of the data as updated by the former processor. To ensure such serialized execution, various mechanisms for mutual exclusion can be employed. Mutual exclusion mechanisms ensure, for instance, that the data of a data structure is not read by one processor while another processor is currently updating that data.
[0006] Mechanisms for mutual exclusion that have been traditionally been used include spin locks, semaphores, reader-writer spin locks, and non-blocking synchronization, among other types of conventional such mechanisms. Even single-processor systems may require controlled concurrency when critical section code can be executed from both a process context as well an interrupt context. That is, during the updating of the data of a data structure by a process being executed by a processor, the processor may receive an interrupt which causes it to read that data. Therefore, it is important for the processor to recognize that the interrupt should not result in reading of the data until the process has finished updating the data.
[0007] For instance, for a spin lock, a process cannot update, or possibly cannot even read, a section of data until it acquires a lock on that data, such that it waits or “spins” until the lock can be acquired. While short-term mutual exclusions like spin locks are simple to use, with the advent of faster processors and memory interconnect speeds not keeping up with the speed of such processors, the cost of acquiring spin locks increases with each generation of computer architecture. The wider this gap is, the more cycles a processor has to wait for a slow memory interconnect to respond. Therefore, it has become increasingly necessary to look for alternatives to conventional spin-waiting locking models. This is especially true in the case of real-time systems.
[0008] Read-copy-update (RCU) is one such alternative mutual exclusion approach. In RCU, readers, which are threads or processes trying to access, but not modify, data, can access shared data without having to acquire any conventional type of lock. However, writers, which are threads or processes trying to update such data, have to use a special callback scheme to update the data. They update all the global references to the updated data with a new copy and use the callback scheme to free the old copy after all the processors have lost or released all local references to the data.
[0009] Because the write side of RCU is significantly more expensive in terms of execution time as compared to the read side, RCU is best suited for scenarios in which the data to be protected is read more often than it is written. For single-processor systems, RCU eliminates the need to mask interrupts for mutual exclusion purposes. RCU is thus suitable for mutual exclusion in network routing tables, device state tables, deferred deletion of data structures, and multiple-path input/output (I/O) device maintenance, among other applications.
[0010] However, the read side of such so-called “classic” RCU, while having nearly zero if not zero overhead to perform such a RCU read-side critical section (of code), is nevertheless not well suited for usage in real-time systems. This is because classic RCU disables preemption during RCU read-side critical sections. Preemption allows a high-priority realtime task to interrupt, or preempt, the execution of a lower-priority non-realtime task, thereby permitting the realtime task to attain its response-time goal. Therefore, disabling preemption can degrade realtime response time or latency. While some real-time applications can tolerate such degraded latency, many more absolutely cannot.
[0011] Other types of RCU are adapted for usage in real-time systems, but require significant overhead in performing an RCU read-side critical section. For instance, readers of a data structure commonly employ memory barriers so that they do not have to acquire any type of conventional lock on the data structure. A memory barrier is an explicit instruction to a processor that causes the processor to order read and writes to memory. That is, a memory barrier is more precisely a memory barrier instruction that places constraints on the order of execution of other instructions, such as read and write instructions. As such, the processor cannot reorder read or write accesses (i.e., memory loads and stores) across the memory barrier.
[0012] For example, a section of code may include three read or write instructions, followed by a memory barrier instruction, followed by another three read or write instructions. A processor executing this section of code may reorder the execution of the first three read or write instructions relative to one another, and may reorder the execution of the last three read or write instructions relative to one another. However, because of the memory barrier instruction, the processor is not allowed to reorder the first three read or write instructions relative to the last three read or write instructions, and vice-versa.
[0013] Utilizing memory barriers adds significant overhead to such real-time read-side RCU critical section. Such instructions are expensive in terms of added overhead, because they may be performed thousands of times slower than other operations. Furthermore, existing real-time RCU approaches may also employ atomic instructions, where atomicity means that a number of instructions are all performed, or none of them are. Atomic instructions are also expensive in terms of added overhead, and also may be performed thousands of times more slowly than other operations.
[0014] There is thus a need within the prior art for improved RCU performance within real-time systems, as well as within other types of systems. More specifically, memory barriers and atomic instructions should be used within the read side of RCU as sparingly as possible. For these and other reasons, therefore, there is a need for the present invention.
[0015] The present invention relates to read-copy-update (RCU) critical sections within real-time systems and other types of systems, and more particularly relates to reducing the usage of memory barriers within RCU. A method of one embodiment of the invention includes the following to perform an update operation on a section of memory to update the contents of that section of memory. A global flip-counter bit is copied to a local flip-counter bit. The global flip-counter bit specifies which of a first set of per-processor counters and a second set of per-processor counters is a current set of such per-processor counters and which is a last set of such per-processor counters. The global flip-counter bit also specifies which of a first set of per-processor need-memory-barrier bits and a second set of per-processor need-memory-barrier bits is a current set of such per-processor need-memory-barrier bits and which is a last set of such per-processor need-memory-barrier bits.
[0016] The method performs a number of steps or acts where the following four conditions are true. The first condition is that attempting to acquire a flip-counter-bit lock on the global-flip-counter bit is successful. The second condition is that the global flip-counter bit has not changed while acquiring the flip-counter-bit lock. The third condition is that the sum of the last set of per-processor counters is zero. The fourth condition is that all of the last set of per-processor need-memory-barrier bits are zero, such that none of the processors needs to execute a memory barrier.
[0017] The steps or acts that are performed where these four conditions are true are as follows. First, each of the current set of per-processor need-memory-barrier bits is incremented, using the local flip-counter bit. An inter-processor interrupt is then sent to execute a memory barrier if one is needed. Thereafter if all of the last set of per-processor need-memory-barrier bits are equal to two, then each of the current set of per-processor need-memory-barrier bits is set to zero, using the local flip-counter bit. The global flip-counter bit is inverted, and the flip-counter-bit lock is released.
[0018] The drawings referenced herein form a part of the specification. Features shown in the drawing are meant as illustrative of only some embodiments of the invention, and not of all embodiments of the invention, unless otherwise explicitly indicated, and implications to the contrary are otherwise not to be made.
[0019] FIG. 1 is a diagram showing the various data structures used to perform read-copy-update (RCU) while achieving reduced memory barrier usage, according to a preferred embodiment of the invention, and is suggested for printing on the first page of the patent.
[0020] FIG. 2 is a diagram of a system, according to an embodiment of the invention.
[0021] FIGS. 3A, 3B, 3C, 3D, and 3E are flowcharts of methods for performing RCU write-side and read-side critical-section while achieving reduced memory barrier usage, as well as for expediting write-side RCU grace periods, according to different varying embodiments of the invention.
[0022] In the following detailed description of exemplary embodiments of the invention, reference is made to the accompanying drawings that form a part hereof, and in which is shown by way of illustration specific exemplary embodiments in which the invention may be practiced. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention. Other embodiments may be utilized, and logical, mechanical, and other changes may be made without departing from the spirit or scope of the present invention. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined only by the appended claims.
[0023] FIG. 1 shows a computer-readable medium 100 depicting the various data structures that are employed to achieve read-copy-update (RCU) while having reduced memory barrier usage, according to an embodiment of the invention. In this section of the detailed description, these data structures are described. In the subsequent sections of the detailed description, how these data structures are actually used to provide RCU while achieving reduced memory barrier usage is described. The computer-readable medium 100 may be a recordable data storage medium, like a semiconductor memory, such as a dynamic random-access memory (DRAM), a magnetic medium, or another type of tangible computer-readable medium. The methods that are described herein can be implemented as computer programs, or other types of means, stored on the medium.
[0024] The data structures stored on the computer-readable medium 100 are used in conjunction with a system. The system includes multiple processors, like four such processors 102A, 102B, 102C, and 102D, collectively referred to as the processors 102. In another embodiment, however, there may be fewer than four processors 102 or more than four processors 102.
[0025] Furthermore, the data structures stored on the computer-readable medium 100 are used in conjunction with such a multiple-processor system on which there are a number of tasks 118A, 118B, 118C, . . . , 118N, collectively referred to as the tasks 118, running. Each of the tasks 118 is executed at any given moment in time by one of the processors 102. However, during the lifetime of a given task, the execution of the task may be switched among the processors 102. For instance, a task may first start execution on one processor, then switch execution to another processor, and so on. A task is a term used herein to signify a set of computer code executed by a processor. A task is thus used in a general and encompassing sense, and may include or also be referred to as a thread or a process. A given computer program may be made up of a number of such tasks that are executed serially and/or in parallel with one another.
[0026] The data structures stored on the computer-readable medium 100 may include two sets of per-processor counters: a first set of per-processor counters 104A, 104B, 104C, and 104D, collectively referred to as the first set of per-processor counters 104, and a second set of per-processor counters 106A, 106B, 106C, and 106D, collectively referred to as the second set of per-processor counters 106. The sets of per-processor counters 104 and 106 correspond to the processors 102 of the system. At any given time, one of the sets of per-processor counters 104 and 106 is a current set of per-processor counters. The other set of per-processor counters, which is not the current set of per-processor counters, is referred to as the last set of per-processor counters.
[0027] The per-processor counters 104 and 106 are used to track whether the processors 102 are currently engaged in an RCU read-side critical section. This operation is performed in relation to a critical section of program code, which can be a section of code guarded by a synchronization mechanism. As will be described in detail in subsequent sections of the detailed description, when a processor first engages in such an RCU read-side critical section, it increments its corresponding counter within the current set of per-processor counters. As will also be described in detail in subsequent sections of the detailed description, when the RCU read-side critical section is completely finished, the corresponding counter is decremented.
[0028] A real-time read operation is an RCU read-side critical section that has to be performed in order as compared to write-side RCU operations. For instance, within the prior art, such a critical real-time read-side section may always employ a memory barrier. However, as will be described in detail in subsequent sections of the detailed description, such critical real-time read-side sections in accordance with embodiments of the invention employ memory barriers only sparingly.
[0029] The per-processor counters 104 and 106 can be represented in the C programming language in one embodiment as follows:
[0000] static DEFINE_PER_CPU(atomic_t [2], rcu_flipctr) =
[0030] The data structures stored on the computer-readable medium 100 also may include two sets of per-processor need-memory-barrier bits: a first set of per-processor need-memory-barrier bits 108A, 108B, 108C, and 108D, collectively referred to as the need-memory-barrier bits 108, and a second set of per-processor need-memory-barrier-bits 110A, 110B, 110C, and 110D, collectively referred to as the need-memory-barrier bits 110. The sets of per-processor need-memory-barrier bits 108 and 110 correspond to the processors 102 of the system. At any given time, one of the sets of need-memory-barrier bits 108 and 110 is a current set of need-memory-barrier bits. The other set of need-memory-barrier bits, which is not the current set of such bits, is referred to as the last set of need-memory-barrier bits.
[0031] The per-processor need-memory-barrier bits 108 and 110 are used to track whether, on a per-processor basis, a memory barrier is required. As will be described in detail in subsequent sections of the detailed description, at some point when any of a given set of need-memory-barrier bits is equal to one, a memory barrier is executed. Thus, the need-memory-barrier bits 108 and 110 are set when the corresponding processor needs to execute a memory barrier in relation to performing a given RCU operation.
[0032] The per-processor need-memory-barrier bits 108 and 110 can be represented in the C programming language in one embodiment as follows:
[0033] static DEFINE_PER_CPU(int [2], rcu_need_mb)={0, 0};
[0034] The data structures stored on the computer-readable medium 100 also may include a global flip-counter bit 112 and a local flip-counter bit 114. The flip-counter bits 112 and 114 specify which of the sets of per-processor counters 104 and 106 is the current set of per-processor counters and which is the last set of per-processor counters. The flip-counter bits 112 and 114 also specify which of the sets of per-processor need-memory-barrier bits 108 and 110 is the current set of per-processor need-memory-barrier bits and which is the last set of per-processor need-memory-barrier bits.
[0035] For example, if the bits 112 and 114 are set equal to zero, then this can mean that the first set of per-processor counters 104 is the current set of per-processor counters, and the first set of need-memory-barrier bits 108 is the current set of need-memory-barrier bits. In such instance, the second set of per-processor counters 106 is the last set of per-processor counters, and the second set of need-memory-barrier bits 110 is the last set of need-memory-barrier bits. Likewise, if the bits 112 and 114 are set equal to one, then this can mean that the second set of counters 106 is the current set of counters, and the second set of need-memory-barrier bits 110 is the current set of such bits. In such instance, the first set of counters 104 is the last set of counters, and the first set of need-memory-barrier bits 110 is the last set of such bits.
[0036] The global flip-counter bit 112 is the primary bit that specifies which of the sets of counters 104 and 106 is the current set and which is the last set, and which of the sets of need-memory-barrier bits 108 and 110 is the current set and which is the last set. That is, the flip-counter bit 112 is global across all of the processors 102 of the system in question. By comparison, the local flip-counter bit 114 is used to copy the global flip-counter bit 112 when a given of the processors 102 is performing a read side RCU critical section, and is applicable to just that processor, as is described in more detail later in the detailed description. There may be an instance of the local flip-counter bit 114 for each execution of a read operation or a write operation by a processor.
[0037] The flip-counter bits 112 and 114 can be represented in the C programming language in one embodiment as follows:
[0038] static int rcu_flipctrbit=0;
[0039] static int local rcu_flipctrbit=0;
[0000] It is noted that the global rcu_flipctrbit is a global variable, whereas the local_rcu_flipctrbit is a local variable. This means that the rcu_flipctrbit is actually declared outside the scope of a function, whereas the local_rcu_flipctrbit is declared within each function in which it is used, as can be appreciated by those of ordinary skill within the art.
[0040] The data structures stored on the computer-readable medium 100 also may include a flip-counter-bit lock 116. The flip-counter-bit lock 116 is a lock for the global flip-counter bit 112. When a given task successfully acquires the flip-counter-bit lock 116, no other tasks are able to modify the global flip-counter bit 112 until the former task has released the lock 116. The flip-counter-bit lock 116 may be implemented as a conventional lock in one embodiment, as can be appreciated by those of ordinary skill within the art.
[0041] The flip-counter-bit lock 116 can be represented in the C programming language in one embodiment as follows:
[0042] DEFINE_SPINLOCK(rcu_fliplock);
[0043] The data structures stored on the computer-readable medium 100 may also include a set of per-task read-lock nesting counters 120A, 120B, 120C, . . . , 120N, collectively referred to as the per-task read-lock nesting counters 120. The read-lock nesting counters 120 correspond to the tasks 118 running on the processors 102 of the system. A given read side RCU critical section may include a nested group of RCU read side critical sections. For example, a first read-side critical section may include a nested second read side critical section, which may include a nested third read side critical section, and so on. The per-task read-lock nesting counters 120 thus track in which levels of nesting the corresponding tasks 118 currently are.
[0044] The incrementing of the per-processor counters 104 and 106 occurs just when the first, outer-most read side critical section is entered. Likewise, the decrementing of the per-processor counters 104 occurs just when the first, outer-most read side critical section is ultimately exited, after the exiting of the inner, nested read-side critical sections. This means that a memory barrier at most is executed just after exiting of the first, outer-most read-side critical section, and not after exiting any of the inner, nested read-side critical sections. As a result, the frequency of memory barrier execution is decreased in this way.
[0045] When a read-side critical section is entered by a given task, the per-task read-lock nesting counter corresponding to that task is incremented. Certain operations, such as incrementing of the per-processor counters 104 and 106, are performed only when, after incrementation of the appropriate per-task read-lock nesting counter, this nesting counter is equal to one, indicating that the first, outer-most read-side critical section has been entered. Likewise, when a read-side critical section is exited by a given task, the corresponding per-task read-lock nesting counter is decremented. Certain operations, such as performing a memory barrier, may be performed only when, after decrementation of the appropriate per-task read-lock nesting counter, this nesting counter is equal to zero, indicating that the first, outer-most read-side critical section has been exited.
[0046] The per-task read-lock-nesting counters 120 can be represented in the C programming language in one embodiment as follows, by adding them to a particular data structure:
[0000] struct task_struct {
[0047] The data structures stored on the computer-readable medium 100 finally may include a set of per-task flip-counter bits 122A, 122B, 122C, . . . , 122N, collectively referred to as the per-task flip-counter bits 122. The flip-counter bits 122 correspond to the tasks 118 running on the processors 102 of the system. As has been noted, a given task may begin execution on one of the processors 102, switch execution one or more times to other of the processors 102, and indeed finish execution on a completely different of the processors 102.
[0048] However, the per-processor counter of the sets of counters 104 and 106 that was initially incremented during a read side critical section by the task is the counter corresponding to the processor on which the task began execution. In order to track this counter, and thus the processor on which the task began execution, the per-task flip-counter pointer is set to point to the counter that was initially incremented. Therefore, even if the task changes processors, the correct counter will later be decremented when the read-side critical section is completed. In other words, the set of per-task flip-counter pointers bits 122 allows the tasks 118 to keep track of which of the sets of counters 104 and 106 that were originally incremented, and thus which of the processors 102 that they were executing on when first executed.
[0049] The per-task flip-counter bits 122 can be represented in the C programming language in one embodiment as follows, by adding them to a particular data structure:
[0050] FIG. 2 shows a system 200, according to an embodiment of the invention. The system 200 includes the multiple processors 102, the computer-readable medium 100 that stores the data structures of FIG. 1, the tasks 118, and a memory 202 accessible by the tasks 118. In one embodiment, the medium 100 and the memory 202 may be one and the same. The multiple processors 102 may be located on the same or different computing devices within the system 200, which are not specifically called out in FIG. 2. As can be appreciated by those of ordinary skill within the art, the system 200 may include other components, in addition to and/or in lieu of those depicted in FIG. 2.
[0051] The tasks 118 are able to access sections of the memory 202, such as the section 204 that is particularly depicted in FIG. 2, in at least two different ways. First, the tasks 118 may update the sections of the memory 202, as indicated by the arrow 206. Updating in this respect means changing the contents of a section of the memory 202, and can include deleting the contents as well. The section of the memory 202 in question may, for instance, have data stored therein in the form of a particular data structure. The updating process is particularly performed as a write-side read-copy-update (RCU) operation, as is described in more detail later in the detailed description. When a given of the tasks 118 is performing an update operation, it is referred to as an updating task, or an updater. Such updating utilizes at least some of the data structures that have been described in the previous section of the detailed description in relation to FIG. 1.
[0052] Second, the tasks 118 may read the sections of the memory 202, as indicated by the arrow 208. Reading in this respect means accessing the contents of a section of the memory 202, without actually changing the contents of the section of the memory 202. As before, the section of the memory 202 in question may, for instance, may have data stored therein in the form of a particular data structure. The reading process is particularly performed as a read-side read-copy-update (RCU) critical section, as is described in more detail later in the detailed description. When a given of the tasks 118 is performing a read operation, it is referred to as a reading task, or a reader. Such reading utilizes at least some of the data structures that have been described in the previous section of the detailed description in relation to FIG. 1.
[0053] In the embodiment of RCU operations described in the present section of the detailed description, each per-processor need-memory-barrier bit is capable of having one of three values. Each need-memory-barrier bit may have a first value, such as zero, indicating that the processor corresponding to this bit is not yet ready for a memory barrier. Each need-memory-barrier bit may also have a second value, such as one, indicated that a memory barrier is needed by the processor corresponding to this bit. Each need-memory-barrier bit may further have a third value, such as two, indicating that a memory barrier has been supplied, provided, or executed. It is noted that the terminology need-memory-barrier “bit” as used in relation to this embodiment of the invention is taken in a general and encompassing sense, such that the bit may indeed take on one of at least two different values. That is, the claimed invention is to be interpreted such that a “bit” is more generally a variable, for instance, that may take on at any given time one of more than two different values.
[0054] Furthermore, in the embodiment described in the present section of the detailed description, each per-task flip-counter pointer does not point to the per-processor counter that was incremented for a given processor, but rather records and preserves the value of the global flip-counter bit when the first, outer-most read-side critical section is entered. That is, rather than pointing to a given per-processor counter of the counters 104 and 106 of FIG. 1, for instance, a per-task flip-counter pointer instead “points” to which set of the counters 104 and 106 is the current set when the first, outer-most read-side critical section is entered. As such, the terminology per-task flip-counter “pointer” is subsequently referred to in this section of the detailed description as a per-task flip-counter “bit” since it records or preserves the value of another bit, the global flip-counter bit. However, the claimed invention is to be interpreted such that a per-task flip-counter “pointer” may take on the value of the global flip-counter bit, such that a per-task flip-counter “pointer” encompasses a per-task flip-counter “bit” as well.
[0055] FIGS. 3A and 3B show a method 300 that is performed by a task to perform an update operation on a section of memory, to update the contents of the section of memory, according to an embodiment of the invention. That is, the method 300 is a write-side read-copy-update (RCU) operation. The method 300 employs the data structures that have been described in relation to FIG. 1, as modified as has been described above, and can be performed in relation to the system that has been described in relation to FIG. 2.
[0056] The global flip-counter bit is copied to a local flip-counter bit (302). An attempt is made to acquire the flip-counter-bit lock on the global flip-counter bit (304). If the lock is not successfully acquired (306), then the updating task exits the method 300 (324), as in the method 300. Likewise, if the lock is successfully acquired (306), but the global flip-counter bit has changed while acquiring the lock (310), then the updating task exits the method 300 (324). Similarly, if the global flip-counter bit has not changed while acquiring the lock (310), but if any of the last set of per-processor need-memory-barrier bits is non-zero (312), then the updating task exits the method 300 (324). This is because if any of the need-memory-barrier bits is greater than zero, then one or more of the processors needs to execute a memory barrier, which has to be executed before any further updating can be performed, such that updating cannot be performed at this moment.
[0057] Furthermore, if all of the last set of per-processor need-memory-barrier bits are zero (312), but the sum of all of the last set of per-processor counters is not equal to zero (314), then the updating task exits the method 300 (324). It is noted that the test of part 312 is whether any of the last set of per-processor need-memory-barrier bits is zero, because, as will become apparent later in this section of the detailed description, if one of the need-memory-barrier bits is zero, then all of them will be zero.
[0058] It is noted that the sum of all of the last set of per-processor counters not being equal to zero in part 314 means that one or more tasks have not yet completed its read-side critical section. It is also noted that the test of part 314 as to whether the sum of all of the last set of per-processor counters is not equal to zero may not be satisfied merely if any of the last set of per-processor counters is not equal to zero, since the per-processor counters can be negative (in the event a reader gets preempted and migrates/gets scheduled to a different processor, and in such instance the sum could still be zero).
[0059] Where the sum of all of the last set of per-processor counters is equal to zero (314), then in one embodiment a memory barrier is immediately executed (316), especially where the system in relation to which the method 300 is being executed is a symmetric multiple-processor (SMP) system. This is because, in such systems, this memory barrier is needed so that the effects of part 302 are guaranteed to be in order in relation to the effects of part 318. Thereafter, each of the last set of per-processor need-memory-barrier bits is incremented (318). This operation uses the local flip-counter bit, in the sense that this bit specifies which of the sets of need-memory-barrier bits is the current set, and which is the last set, as has been described.
[0060] Thereafter, in one embodiment, the processor executing the update task of the method 300 sends an inter-processor interrupt (IPI) (320). The inter-processor interrupt is sent to the processor that needs to execute a memory barrier. The processor that receives the interrupt executes the memory barrier by performing the method 370 of FIG. 3E, as is described later in this section of the detailed description.
[0061] If any of the last set of per-processor need-memory-barrier bits are not now equal to two (322), then the updating task exits the method 300 (324). However, if all of the last set of per-processor need-memory-barrier bits are now equal to two (322), after incrementation, then each of the current set of per-processor need-memory bits is set to zero (326), again using the local flip-counter bit. Thus, the updating task indicates that none of the processors currently needs to execute a memory barrier. Thereafter, in one embodiment, a memory barrier is executed (328), especially where the system in relation to which the method 300 is being executed is an SMP system, as before.
[0062] The method 300 finishes by inverting the global flip-counter bit (330), and by releasing the flip-counter-bit lock (332). Inverting the global flip-counter bit switches the current and last sets of per-processor counters, as well as the current and last sets of per-processor need-memory-barrier bits. The method 300 thus acquires an effective temporal write lock on the section of memory in question (that is, the RCU-protected data), so that any memory removed from data structures prior to the previous flip may now be destructively updated (e.g., such as by having the memory freed for allocation for other purposes).
[0063] FIGS. 3C and 3D show a method 340 that is performed by a task to perform a read operation on a section of memory (that is, on RCU-protected data), to read the contents of the section of memory, according to an embodiment of the invention. That is, the method 340 is an RCU read-side critical section. The method 340 employs the data structures that have been described in relation to FIG. 1, as modified as has been described above, and can be performed in relation to the system that has been described in relation to FIG. 2. The portion of the method 340 of FIG. 3C is specifically for acquiring the equivalent of a read lock on the section of memory, and for reading the contents of the section of memory. By comparison, the portion of the method 340 of FIG. 3D is specifically for releasing this effective read lock from the section of memory that the contents of which have been read.
[0064] First, preemption and/or interrupts as to the processor executing the reading task performing the method 340 may be disabled (342). Preemption and/or interrupts may be disabled so that a preempting task, or an interrupt, does not acquire or modify the effective read lock that is acquired by the reading task performing the part of the method 340 in FIG. 3C. Next, the per-task read-lock nesting counter corresponding to the reading task performing the method 340 is incremented (344). If this read-lock-nesting counter is not equal to one (346), then the method 340 proceeds to part 354. This is because the current performance of the method 340 is not in relation to the first, outer-most read-side critical section, but rather is in relation to an inner, nested read-side critical section, and therefore the preparatory work that has already been performed by the first, outer-most read-side critical section does not need to be performed.
[0065] Thus, where the read-lock-nesting counter is equal to one (346), then the method 340 proceeds to part 348, and the global flip-counter bit is copied to the local flip-counter bit (348). The per-processor counter of the current set of per-processor counters corresponding to the processor currently executing the reading task performing the method 340 is incremented (350). This operation uses the local flip-counter bit, in the sense that this bit specifies which of the sets of per-processor counters is the current set, and which is the last set, as has been described. s Incrementation of the per-processor counter in part 350 may be performed atomically in one embodiment of the invention.
[0066] The per-task flip-counter bit corresponding to the reading task performing the method 340 is then set equal to the local flip-counter bit (352). This operation records and preserves which of the two sets of per-processor counters is the current set and which is the last set at this time, and which of the two sets of need-memory-barrier bits is the current set and which is the last set at this time. If preemption and/or interrupts have been previously disabled in part 342, they are now enabled (354), because the effective read lock on the section of memory (i.e., RCU-protected data) that the contents of which are to be read has been acquired. The method 340 proceeds to access the contents of this section of memory (356), as desired.
[0067] Once the contents of the section of memory (i.e., RCU-protected data) have been read, the effective read lock has to be released if the reading task currently performing the method 340 is performing the first, outer-most read-side critical section, as opposed to an inner, nested read-side critical section. Therefore, the per-task read-lock-nesting counter for the reading task performing the method 340 is decremented (358). If after decrementation this read-lock-nesting counter is not zero (360), then the method 340 proceeds to part 366, as is described later in the detailed description. Thus, a memory barrier does not need to be executed. In such situations, embodiments of the invention avoid having to execute a memory barrier for read-side critical sections.
[0068] However, if after decrementation the read-lock-nesting counter for the task performing the method 340 is zero, then preemption and/or interrupts may again be optionally disabled (360). Preemption and/or interrupts may be disabled so that a preempting task, or an interrupt, does not modify the effective read lock that is released by the reading task performing the part of the method 340 in FIG. 3D.
[0069] The per-processor counter within the set of per-processor counters specified by the per-task flip-counter bit, and which corresponds to the processor currently executing the reading task performing the method 340, is then decremented (364). That is, the per-task flip-counter bit specifies one of the two sets of per-processor counters. Within this specified set of counters, the counter that corresponds to the processor currently executing the task performing the method 340 is decremented. Finally, preemption and/or interrupts are now enabled (366), because the effective read lock on the section of memory (i.e., RCU-protected data) that the contents of which are to be read has been released. The method 340 is then finished (368).
[0070] FIG. 3E shows a method 370 that may be performed at various times to increase performance of the RCU operations described in relation to FIGS. 3A, 3B, 3C, and 3D, according to an embodiment of the invention. However, the method 370 is not needed to implement the RCU operations described in relation to FIGS. 3A, 3B, 3C, and 3D. Rather, the method 370 may be called, as desired or on a periodic basis, so that any needed memory barriers are executed. For example, the method 370 may be performed during “down” or slow times of a given processor, when the processor may not, for instance, be actively executing any task. As another example, the method 370 may be performed as part of interrupt processing or when a given processor has been preempted by a preempting task, such that the method 370 is performed before beginning the processing of the interrupt or the preempting task in question. More specific, the method 370 is performed in response to a processor having received an inter-processor interrupt (IPI) from another processor perform part 320 of the method 300 of FIGS. 3A and 3B.
[0071] As a third example, as can be appreciated by those of ordinary skill within the art, in implementations of write-side RCU operations that require callback processing, the method 370 can be performed as part of this callback processing, to accelerate what are known in the art as “grace periods.” That is, a callback may be scheduled by an updating task prior to its exiting in part 310 and/or part 324 of the method 300 of FIGS. 3A and 3B. When all the reading tasks in question have finished, the updating task is “called back” so that it can again attempt to perform the method 300 of FIGS. 3A and 3B through completion. Furthermore, there may be a grace period that the updating task can wait such that after this period of time it is guaranteed that the updating task will be able to perform the method 300 of FIGS. 3A and 3B through completion. However, the end of the grace period will be delayed until all the processors execute a memory barrier 358. If the updating task, then, does not want to be delayed awaiting a given processor's memory barrier, it may choose to perform the method 370 as to that processor.
[0072] Therefore, when the method 370 is executed by a given processor, if the per-processor need-memory-barrier bit of the last set of such need-memory-barrier bits for this processor is not equal to one (372), then the method 370 is exited (374). This is because a memory barrier does not need to be executed, such that one should not be executed. However, if the need-memory-barrier bit in question is equal to one (372), then a memory barrier is executed (376). As a result, this per-processor need-memory-barrier bit is then incremented (378), so that it now has a value of two, indicating that a memory barrier has been provided or supplied.
[0073] Embodiments of the invention provide for advantages over the prior art. Specifically, memory barriers are never employed during the read side of real-time RCU operations. When a read lock is released after a read operation has been performed, the per-task read-lock-nesting counter corresponding to the task performing this operation is decremented. Only if this counter is then equal to zero is the-per processor counter pointed to by the per-task flip-counter pointer decremented. At some later point in time—and not part of the read side of a real-time RCU operation—periodically a processor examines this counter to determine whether to execute a memory barrier. Only where this other counter is (i.e., becomes) equal to zero, where a corresponding per-processor need-memory-barrier is equal to one, and where this other counter is within the last set of per-processor counters, is a memory barrier executed. A memory barrier may further be executed during the update side of real-time RCU operations in response to the sending of an inter-processor interrupt (IPI).
[0074] Therefore, memory barriers are not executed for any read operations. As a result, real-time read-side RCU critical sections are performed significantly more quickly in relation to the invention than in the prior art. Furthermore, at least some embodiments of the invention take advantage of naturally occurring memory barriers, which are memory barriers performed in relation to other operations occurring within the computerized system in question.
[0075] It is noted that, although specific embodiments have been illustrated and described herein, it will be appreciated by those of ordinary skill in the art that any arrangement calculated to achieve the same purpose may be substituted for the specific embodiments shown. This application is thus intended to cover any adaptations or variations of embodiments of the present invention. As such, it is manifestly intended that this invention be limited only by the claims and equivalents thereof.
Patent CitationsCited PatentFiling datePublication dateApplicantTitleUS5442758 *Jul 19, 1993Aug 15, 1995Sequent Computer Systems, Inc.Apparatus and method for achieving reduced overhead mutual exclusion and maintaining coherency in a multiprocessor system utilizing execution history and thread monitoringUS5608893 *Jun 7, 1995Mar 4, 1997Sequent Computer Systems, Inc.Method for maintaining data coherency using thread activity summaries in a multicomputer systemUS5727209 *Nov 1, 1996Mar 10, 1998Sequent Computer Systems, Inc.Apparatus and method for achieving reduced overhead mutual-exclusion and maintaining coherency in a multiprocessor system utilizing execution history and thread monitoringUS6038646 *Jan 23, 1998Mar 14, 2000Sun Microsystems, Inc.Method and apparatus for enforcing ordered execution of reads and writes across a memory interfaceUS6191992 *Dec 29, 1998Feb 20, 2001Oki Electric Industry Co., LtdFirst-in-first-out storage device including synchronized full-state detention and empty-state detentionUS6219690 *Nov 1, 1996Apr 17, 2001International Business Machines CorporationApparatus and method for achieving reduced overhead mutual exclusion and maintaining coherency in a multiprocessor system utilizing execution history and thread monitoringUS6886162 *Jul 31, 1998Apr 26, 2005International Business Machines CorporationHigh speed methods for maintaining a summary of thread activity for multiprocessor computer systemsUS6996812 *Jun 18, 2001Feb 7, 2006International Business Machines CorporationSoftware implementation of synchronous memory barriersUS20020176369 *May 22, 2001Nov 28, 2002Mitsubishi Electric Research Laboratories, Inc.Method and system for minimizing error in bandwidth allocation with an optimal number of renegotiationsUS20020194436 *Jun 18, 2001Dec 19, 2002International Business Machines CorporationSoftware implementation of synchronous memory BarriersUS20030014558 *May 20, 2002Jan 16, 2003Kyushu UniversityBatch interrupts handling device, virtual shared memory and multiple concurrent processing deviceUS20030108053 *Dec 9, 2002Jun 12, 2003Nec CorporationNode-to-node data transfer method and node-to-node data transfer apparatusUS20050050374 *Jul 20, 2004Mar 3, 2005Tomohiro NakamuraMethod for synchronizing processors in a multiprocessor systemUS20050149470 *Feb 26, 2003Jul 7, 2005Ryoichi FujieData transmission apparatus, and data transmission methodUS20050179634 *Apr 20, 2005Aug 18, 2005Bu Lin-KaiMethod and related apparatus for driving pixels located in a row of an LCD panel toward the same average voltage valueUS20050198030 *Mar 8, 2004Sep 8, 2005Mckenney Paul E.Efficient support of consistent cyclic search with read-copy-updateUS20050223004 *Mar 30, 2004Oct 6, 2005Mckenney Paul EAtomic renaming and moving of data files while permitting lock-free look-upsUS20060265373 *May 20, 2005Nov 23, 2006Mckenney Paul EHybrid multi-threaded access to data structures using hazard pointers for reads and locks for updatesUS20070091102 *Oct 25, 2006Apr 26, 2007John BrothersGPU Pipeline Multiple Level Synchronization Controller Processor and MethodUS20080215784 *Apr 11, 2008Sep 4, 2008International Business Machines CorporationRealtime-safe read copy update with per-processor read/write locksUS20080313238 *Aug 15, 2008Dec 18, 2008International Business Machines CorporationRead-Copy Update System And Method* Cited by examinerReferenced byCiting PatentFiling datePublication dateApplicantTitleUS7953708Jul 28, 2008May 31, 2011International Business Machines CorporationOptimizing grace period detection for preemptible read-copy update on uniprocessor systemsUS7953778May 31, 2011International Business Machines CorporationEfficient support of consistent cyclic search with read-copy update and parallel updatesUS8020160Sep 13, 2011International Business Machines CorporationUser-level read-copy update that does not require disabling preemption or signal handlingUS8055918Nov 8, 2011International Business Machines CorporationOptimizing preemptible read-copy update for low-power usage by avoiding unnecessary wakeupsUS8108696Jan 31, 2012International Business Machines CorporationOptimizing non-preemptible read-copy update for low-power usage by avoiding unnecessary wakeupsUS8185704May 22, 2012International Business Machines CorporationHigh performance real-time read-copy updateUS8195893Nov 3, 2008Jun 5, 2012International Business Machines CorporationEliminating synchronous grace period detection for non-preemptible read-copy update on uniprocessor systemsUS8307173Nov 6, 2012International Business Machines CorporationHigh performance real-time read-copy updateUS8407503Sep 27, 2010Mar 26, 2013International Business Machines CorporationMaking read-copy update free-running grace period counters safe against lengthy low power state sojournsUS8495311 *Jun 25, 2009Jul 23, 2013International Business Machines CorporationUpdating shared variables atomicallyUS9459963Sep 3, 2009Oct 4, 2016International Business Machines CorporationSafely rolling back transactions in a transactional memory system with concurrent readersUS20090254764 *Apr 3, 2008Oct 8, 2009International Business Machines CorporationOptimizing Preemptible Read-Copy Update for Low-Power Usage by Avoiding Unnecessary WakeupsUS20090292705 *Nov 26, 2009International Business Machines CorporationEfficient support of consistent cyclic search with read-copy update and parallel updatesUS20100023559 *Jul 28, 2008Jan 28, 2010International Business Machines CorporationOptimizing grace period detection for preemptible read-copy update on uniprocessor systemsUS20100023732 *Jan 28, 2010International Business Machines CorporationOptimizing non-preemptible read-copy update for low-power usage by avoiding unnecessary wakeupsUS20100023946 *Jul 28, 2008Jan 28, 2010International Business Machines CorporationUser-level read-copy update that does not require disabling preemption or signal handlingUS20100115235 *Nov 3, 2008May 6, 2010International Business Machines CorporationEliminating Synchronous Grace Period Detection For Non-Preemptible Read-Copy Update On Uniprocessor SystemsUS20100332769 *Jun 25, 2009Dec 30, 2010International Business Machines CorporationUpdating Shared Variables AtomicallyUS20110055183 *Mar 3, 2011International Business Machines CorporationHigh Performance Real-Time Read-Copy UpdateUS20110055630 *Sep 3, 2009Mar 3, 2011International Business Machines CorporationSafely Rolling Back Transactions In A Transactional Memory System With Concurrent ReadersWO2016071358A1 *Nov 3, 2015May 12, 2016Hella Kgaa Hueck & Co.Electronic device for blocking interrupt requests* Cited by examinerClassifications U.S. Classification711/163, 711/154International ClassificationG06F13/00, G06F12/14Cooperative ClassificationG06F9/3851, G06F9/526, G06F9/522European ClassificationG06F9/52E, G06F9/52B, G06F9/38E4Legal EventsDateCodeEventDescriptionMay 24, 2007ASAssignmentOwner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW YFree format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:MCKENNEY, PAUL E.;BHATTACHARYA, SUPARNA;REEL/FRAME:019347/0151;SIGNING DATES FROM 20070212 TO 20070308Owner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW YFree format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:MCKENNEY, PAUL E.;BHATTACHARYA, SUPARNA;SIGNING DATES FROM 20070212 TO 20070308;REEL/FRAME:019347/0151Apr 4, 2012ASAssignmentOwner name: FACEBOOK, INC., CALIFORNIAFree format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:INTERNATIONAL BUSINESS MACHINES CORPORATION;REEL/FRAME:027991/0454Effective date: 20120327Mar 19, 2014FPAYFee paymentYear of fee payment: 4RotateOriginal ImageGoogle Home - Sitemap - USPTO Bulk Downloads - Privacy Policy - Terms of Service - About Google Patents - Send FeedbackData provided by IFI CLAIMS Patent Services