Abstract:
A memory allocation system is provided and includes nodes, one or more memories, and an allocation interface. Each of the nodes includes a respective set of processors. The one or more memories include memory elements for storing threads. The memory elements refer to respective portions of the one or more memories and are accessible to at least one of the nodes. The allocation interface is configured to allocate the memory elements to lockless list structures. Each of the lockless list structures is allocated to a respective set of the memory elements. The lockless list structures are partitioned for the processors. The allocation interface is configured to receive requests from the processors for the memory elements and adjust allocation of the memory elements between the lockless list structures according to a balancing metric.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    The present disclosure is a continuation application of U.S. patent application Ser. No. 13/458,355 filed on Apr. 27, 2012. The entire disclosure of the application referenced above is incorporated herein by reference. 
     
    
     BACKGROUND 
       [0002]    Slists are data structures that are lockless implementations of a LIFO (last in first out) list made available in operating systems. Slists are typically a desired choice of data structure to hold fixed size buffers that can be allocated and released without holding any spinlocks or other synchronization primitives. Slists may also be used for variable sized contents in the form of a lockless singly linked list. Other capabilities are provided in an operating system environment—such as lookaside lists which are built on Slists. 
         [0003]    However, in some scenarios, the use of Slists may not be desirable. For one example, a single Slist header may become a cache line contention hotspot on servers with many processors accessing the same Slist. This may be a scalability bottleneck in both native and Hyper-V virtualized scenarios. 
         [0004]    In another scenario, Slists are mainly used as packet caches or fixed size buffer repositories. However there are scenarios where more complex data structures or resources of possibly varying sizes have to be maintained in such a lockless list. It may be desired to have more operations than just ‘Push’ and ‘Pop’ for purposes such as load balancing, packet stealing, NUMA awareness and such other algorithmic requirements. These are often satisfied by another data structure abstraction to manage multiple Slists. Lookaside lists are one such example. 
         [0005]    Lookaside lists maintain a cache of fixed size buffers for speedy memory allocation and release. For processor affinity benefits, some operating systems also provide per-processor lookaside lists. These per-processor lookaside lists are generally (but not necessarily) backed by a global list to contain backup packets in case the per-processor list is empty. It may be desired to have extra resource allocations to have a fairly big global backup list to provide an abstraction of a single resource pool. When demand recedes, these extra memory allocations may be freed if there is demand for the memory. However, in certain scenarios resources cannot be over-allocated. This is particularly true for hardware drivers that define limits of their capacity—like maximum number of I/O requests a RAID controller can process. Advance algorithms tie these limits to Slist depths and avoid using spinlocks. Also extra overhead of allocs and frees cause memory fragmentation and costs CPU cycles. Lookaside lists that allocate more than the requisite quantity may not be used for these reasons. 
       SUMMARY 
       [0006]    The following presents a simplified summary of the innovation in order to provide a basic understanding of some aspects described herein. This summary is not an extensive overview of the claimed subject matter. It is intended to neither identify key or critical elements of the claimed subject matter nor delineate the scope of the subject innovation. Its sole purpose is to present some concepts of the claimed subject matter in a simplified form as a prelude to the more detailed description that is presented later. 
         [0007]    In one embodiment, systems and methods for managing the allocation of a plurality of memory elements stored within a plurality of lockless list structures are presented. These lockless list structures (such as Slists) may be made accessible within an operating system environment of a multicore processor. In some embodiments, the lockless list structures, Slists or the like may be embedded in other common data structures like hashes, trees, etc. to meet the different resource allocation and management requirements. 
         [0008]    Some embodiments may partition this plurality of lockless list structures and initially partition the memory elements among these lockless list structures. When a core processor (or other processing element) makes a request for allocating a memory element to itself, the system and/or method may search among the lockless list structures for an available memory element. When a suitable and/or available memory element is found, the system may allocate the available memory element to requesting core processor. 
         [0009]    In some embodiments, the system and/or method may then dynamically balance the set of memory elements among the various lockless list structures according to a suitable balancing metric. Such a possible metric might be to simply maintain substantial numerical equality of memory elements among the lockless list structures. Other metrics might include other load-balancing considerations—possibly based on the type of process running, possible contention situations or the like—e.g., such as mentioned above as to reduce CPU contention or avoiding over-allocation of memory resources. 
         [0010]    Other features and aspects of the present system are presented below in the Detailed Description when read in connection with the drawings presented within this application. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0011]    Exemplary embodiments are illustrated in referenced figures of the drawings. It is intended that the embodiments and figures disclosed herein are to be considered illustrative rather than restrictive. 
           [0012]      FIG. 1  illustrates an exemplary computer system in which the systems and techniques of the present application may be hosted and operating. 
           [0013]      FIG. 2A  is one embodiment of an adaptive hash structure system and method for the management of Slists. 
           [0014]      FIG. 2B  is an embodiment of a dynamic list swapping system and method for the management of Slists. 
           [0015]      FIG. 3  depicts a flow diagram in one embodiment of an adaptive hash system, as might be implemented in  FIG. 2A . 
       
    
    
     DETAILED DESCRIPTION 
       [0016]    As utilized herein, terms “component,” “system,” “interface,” and the like are intended to refer to a computer-related entity, either hardware, software (e.g., in execution), and/or firmware. For example, a component can be a process running on a processor, a processor, an object, an executable, a program, and/or a computer. By way of illustration, both an application running on a server and the server can be a component. One or more components can reside within a process and a component can be localized on one computer and/or distributed between two or more computers. 
         [0017]    The claimed subject matter is described with reference to the drawings, wherein like reference numerals are used to refer to like elements throughout. In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the subject innovation. It may be evident, however, that the claimed subject matter may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to facilitate describing the subject innovation. 
         [0018]    In order to meet the potential bottleneck of resources, the present application discloses a number of embodiments that allow for effective and efficient use of Slists. In one embodiment, Slists may be partitioned in an effective manner which addresses many aforementioned limitations while still maintaining the lockless nature of resource Slists, reducing cacheline contention, fixed quantity allocation and resource sharing/stealing between the lists. In other embodiments, these techniques may utilize processor affinity and NUMA awareness for optimal performance. 
         [0019]      FIG. 1  depicts a computer system diagram showing a multiple group, NUMA node (i.e., processor socket), multi-core system  100 . System  100 , as shown, comprises 2 groups—e.g., Group  0  ( 102   a ) and Group  1  ( 102   b ). In one embodiment, each group may comprise up to 64 (e.g. labeled 0 to 63) Logical Processors (LPs). 
         [0020]    It will be appreciated that a suitable system may have 1 group if there are fewer than 64 logical processors. Similarly, a system may have more than 2 groups. NUMA nodes are fully contained in a group so it may be possible that a group may have fewer than 64 logical processors. A system may have several (more than 2 groups) depending on the number of logical processors contained in the system. 
         [0021]    As is shown, each group may further comprise nodes  104  (i.e. processor sockets). Nodes in the diagram may also refer to NUMA (Non Uniform Memory Access) Nodes. In many current systems, NUMA nodes are Numbered 0 to 63 across the entire system spanning all groups; however, future systems may have a different number of nodes and the present application is not limited to such current specifications. Each such node may further comprise cores  106 . In this embodiment, each LP may be a core or a hardware thread. Logical Processors are uniquely numbered 0 to 63 within each group. 
         [0022]    In some computing environment, systems with more than one physical processor—or systems with physical processors that have multiple cores—can provide the operating system with multiple logical processors. A Logical Processor is one logical computing engine from the perspective of the operating system, application or driver. A “core” (or “core processor”) is one processor unit, which can consist of one or more logical processors. A physical processor may consist of one or more cores. A physical processor may be construed the same as a processor package, a socket, or a CPU. 
         [0023]    In addition, Cores  0  through C- 1  may share a memory resource  108 . Local memory access time between cores and memory on a given node may be faster than memory access time to other nodes. Connections  110  between nodes may be such that all nodes may access memory in all other nodes but memory access time may be slower than access local memory. 
         [0024]    It should be appreciated that all nodes may not be necessarily fully connected and, further, that memory access from one node to another may need to traverse an additional node to access memory on a 3rd node. 
       Slist Management 
       [0025]    The present application discloses many embodiments for the effective management of lockless list structures, Slists or the like.  FIGS. 2A and 2B  depicts two such embodiments—an adaptive hash function ( FIG. 2A ) and a dynamic Pop and Push structure ( FIG. 2B ) for Slist management. In these embodiments, it may be desirable to provide resource or packet management in lockless lists (like Slists) in order to: 
         [0026]    i) reduce CPU cache line contention; 
         [0027]    ii) avoid over-allocation of resources; 
         [0028]    iii) provide for resource sharing and stealing between the lists to adapt to resource demands with a maximum limit; 
         [0029]    iv) provide additional logic for NUMA topology awareness, processor affinity etc.; and/or 
         [0030]    v) provide specific memory allocation requirements like allocators, e.g., within 4 GB bounds and such other restrictions. No additional allocs and release of memory may be desired which may result in fragmentation which may be an issue—e.g., especially with 4 GB limits. 
         [0031]    In general, the techniques and embodiments of this present application tend to embed lockless list structures, Slists or the like in other common data structures like hashes, trees, etc. to meet the different resource allocation and management requirements. 
         [0032]    In many of the present embodiments, systems and methods for managing the allocation of a plurality of memory elements stored within a plurality of lockless list structures are presented. These lockless list structures (such as Slists) may be made accessible within an operating system environment of a multicore processor. 
         [0033]    These embodiments may partition this plurality of lockless list structures and initially partition the memory elements among these lockless list structures. When a core processor (or other processing element) makes a request for allocating a memory element to itself, the system and/or method may search among the lockless list structures for an available memory element. When a suitable and/or available memory element is found, the system may allocate the available memory element to requesting core processor. Such partitioning of lockless list structures may tend to reduce CPU contention. 
         [0034]    The system and/or method may then dynamically balance the set of memory elements among the various lockless list structures according to a suitable balancing metric. Such a possible metric might be to simply maintain substantial numerical equality of memory elements among the lockless list structures. Other metrics might include other load-balancing considerations—possibly based on the type of process running, possible contention situations or the like—e.g., such as mentioned above as avoiding over-allocation of memory resources. 
         [0035]    In another embodiment, a suitable allocation module may be implemented within the computer system (such as the one shown in  FIG. 1 —or in any other suitable multicore processing system). For merely one example, an allocation module may be executing on one of the core processors and implementing the dynamic memory allocation from there. As will be discussed in greater detail below, the allocation module may manage the dynamic partitioning of memory elements in a variety of data structures—e.g. dynamic hash structures or dynamic list swapping structures or the like. 
       Adaptive Hashing for Slist Management 
       [0036]      FIG. 2A  depicts an adaptive, dynamic hash system and technique ( 200 ) for managing Slists. As shown, hash module  202  is connected to one or more Slists  204  (e.g. Slist 0  through Slist 3 ). Each Slist may further comprises zero or more memory elements  206 . Each of these memory elements  206  may be of either fixed size buffers or variable sized buffers and/or data structures. 
         [0037]    In this embodiment, this hash of different Slists may be maintained by keying in a way that is associated with the system generally in a way that relates to the computing system topology and/or the multicore processor architecture. For example,  FIG. 2A  depicts two such topologies: (1) keying by the processor index (as shown by solid arrow lines for Group  0  labeled  208   a ); (2) or keying by NUMA node number (as shown by dashed arrow lines for Group  0  labeled  208   b,  further comprising nodes  210  and LPs  212 ). In these embodiments, the point of relating the index to the system topology may be to optimize the access time to minimize latency and contention with other processors in the system. As may be seen, memory elements may be adjusted and/or balanced between Slists (e.g.,  214 ), according to suitable metrics for load-balancing and/or allocations of memory resources. 
         [0038]    In one embodiment, it is possible to abstract a single logical Slist into multiple ones. In such a case, it may be possible to move the list entities between different lists so that allocations do not fail if one particular Slist is empty. All the Slists in the hash may be searched before allocation fails. It should be appreciated that different hash algorithms may also cater to system topology and optimization objectives such as NUMA or processor affinity extensions of these lists. 
         [0039]      FIG. 3  depicts one possible flowchart for the processing of Slist within a hash structure. At step  300 , the system starts to allocate memory resource and, at  302 , the system may calculate a hash index based on a desired key (for example, CPU number or NUMA ID, as indicated in  FIG. 2A ). The Slist may then be assigned to the hash(index), as calculated. 
         [0040]    The system may query, at  306 , as to whether the Slist in particular is empty, or devoid of memory elements—and, if so, the system may iterate through the other Slists to find a suitable resource. Once found, the resource may be allocated from, say, the next non-empty Slist. 
         [0041]    In the case where the Slist was not empty, the resource may be allocated therefrom at  310 . Whether an allocation was made at step  310  or at step  312 , the system may query whether the allocation was successful at  314 . If not, the system may at that time return an error message at  320  and end processing at  322 . 
         [0042]    However, if the allocation was successful, the memory resource may be utilized as allocated at  316 . Once the memory resource is no longer needed, the system may optionally release the resource back to the original or donor Slist and end the process at  322 . 
       Dynamic List Swapping 
       [0043]      FIG. 2B  shows yet another embodiment of the use of dynamic list swapping data structures ( 250 ) for the effective management of Slists. As may be seen, two separate Slists—e.g. one for Push (release)  252   a  and one for Pop (acquire/allocate)  252   b  operations—may be maintained and each may have memory elements  254  to allocate. Two different pointers ( 256   a  and  256   b ) may be used to access these Slists. In the course of operation, if the Pop Slist is empty (or some other suitable metric to balance memory resources) during an attempted allocation, it is possible to swap the pointers so that the previous Push Slist now becomes the Pop Slist and vice-versa. From that point on, it is now possible to try to allocate from this new Pop Slist. This technique is analogous to maintaining different ‘alloc’ and ‘free’ lists and switching them when ‘alloc’ list is empty. 
         [0044]    What has been described above includes examples of the subject innovation. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the claimed subject matter, but one of ordinary skill in the art may recognize that many further combinations and permutations of the subject innovation are possible. Accordingly, the claimed subject matter is intended to embrace all such alterations, modifications, and variations that fall within the spirit and scope of the appended claims. 
         [0045]    In particular and in regard to the various functions performed by the above described components, devices, circuits, systems and the like, the terms (including a reference to a “means”) used to describe such components are intended to correspond, unless otherwise indicated, to any component which performs the specified function of the described component (e.g., a functional equivalent), even though not structurally equivalent to the disclosed structure, which performs the function in the herein illustrated exemplary aspects of the claimed subject matter. In this regard, it will also be recognized that the innovation includes a system as well as a computer-readable medium having computer-executable instructions for performing the acts and/or events of the various methods of the claimed subject matter. 
         [0046]    In addition, while a particular feature of the subject innovation may have been disclosed with respect to only one of several implementations, such feature may be combined with one or more other features of the other implementations as may be desired and advantageous for any given or particular application. Furthermore, to the extent that the terms “includes,” and “including” and variants thereof are used in either the detailed description or the claims, these terms are intended to be inclusive in a manner similar to the term “comprising.”