# US 10,310,916 B2 · Scalable spinlocks for non-uniform memory access

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,310,916 B2
- Document ID: US10310916B2
- Status: Granted
- Kind: B2
- Application number: 15/704,799
- Filed: 2017-09-14
- Published: 2019-03-14
- Granted: 2019-06-04
- Earliest claimed: 2017-09-14
- Assignees: Intel Corporation
- Applicants: Intel Corporation
- Inventors: Steven Mark Shaw; Hubert Nueckel
- Web page: https://patentgrep.com/patent/US10310916B2

## CPC

- G06F 9/526: {Mutual exclusion algorithms}
- G06F 9/5022: {Mechanisms to release resources}
- G06F 12/1466: {Key-lock mechanism}
- G06F 2212/1052: Security improvement
- G06F 2212/2542: Non-uniform memory access [NUMA] architecture
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Techniques are disclosed to provide scalable spinlocks for non-uniform memory access (NUMA). In some examples, a global spinlock configured to protect access to a shareable resource is protected by multiple local spinlocks, which are each configured to control access to the global spinlock. In a multi-socket NUMA system, the global spinlock is allocated on one of the sockets, and the local spinlocks are distributed over the multiple sockets. In some embodiments, one local spinlock is allocated on each of the multiple sockets. In other embodiments, the multiple local spinlocks may be equally distributed over the NUMA sockets. When contention for the global spinlock is low, processes can attempt to directly acquire the global spinlock. In contrast, when contention for the global spinlock is high, processes need to first acquire one of the local spinlocks associated with the global spinlock before attempting to acquire the global spinlock.

## Claims

### Claim 1

A computer system comprising:
a plurality of sockets, each socket of the plurality of sockets comprising at least one central processing unit (CPU) and locally attached memory, wherein each CPU in each socket is communicatively coupled to the locally attached memory of the socket;
a global spinlock configured to control access to a shareable resource, the global spinlock comprising a first flag and a second flag; and
a plurality of local spinlocks, each local spinlock of the plurality of local spinlocks configured to control access to the global spinlock;
wherein the first flag indicates whether the global spinlock is directly acquired, and the second flag indicates whether the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 2 (depends on 1)

The system of claim 1, wherein the plurality of local spinlocks and the plurality of sockets are same in number, and each local spinlock of the plurality of local spinlocks is allocated on a respective socket of the plurality of sockets.

### Claim 3 (depends on 1)

The system of claim 1, wherein the plurality of local spinlocks are equally distributed amongst the plurality of sockets.

### Claim 4 (depends on 1)

The system of claim 1, wherein each local spinlock is a test-and-set spinlock.

### Claim 5 (depends on 1)

The system of claim 1, wherein each local spinlock is a test and test-and-set spinlock.

### Claim 6 (depends on 1)

The system of claim 1, wherein the global spinlock is permitted to be globally acquired if the first flag indicates that the global spinlock is directly acquired.

### Claim 7 (depends on 1)

The system of claim 1, wherein the global spinlock is not permitted to be globally acquired if the second flag indicates that the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 8 (depends on 1)

The system of claim 1, wherein the global spinlock is acquirable only through a local spinlock of the plurality of local spinlocks if the second flag indicates that the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 9

A computer-implemented method to control access to a shareable resource, the method comprising:
allocating a global spinlock configured to control access to a shareable resource, the global spinlock comprising a first flag and a second flag; and
allocating a plurality of local spinlocks, each local spinlock of the plurality of local spinlocks configured to control access to the global spinlock;
wherein the first flag indicates whether the global spinlock is directly acquired, and the second flag indicates whether the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 10 (depends on 9)

The method of claim 9, wherein the global spinlock is allocated on one socket of a plurality of sockets.

### Claim 11 (depends on 10)

The method of claim 10, wherein the plurality of local spinlocks and the plurality of sockets are same in number, and each local spinlock of the plurality of local spinlocks is allocated on a respective socket of the plurality of sockets.

### Claim 12 (depends on 10)

The method of claim 10, wherein the plurality of local spinlocks are distributed amongst the plurality of sockets.

### Claim 13 (depends on 9)

The method of claim 9, wherein the global spinlock is one of a test and test-and-set spinlock or a test-and-set spinlock.

### Claim 14 (depends on 9)

The method of claim 9, further comprising:
in response to globally acquiring the global spinlock, setting the first flag to indicate that the global spinlock is directly acquired.

### Claim 15 (depends on 9)

The method of claim 9, further comprising:
in response to determining that the first flag indicates that the global spinlock is directly acquired, attempting to globally acquire the global spinlock.

### Claim 16 (depends on 15)

The method of claim 15, further comprising:
in response to spinning a first specific number of times attempting to globally acquire the global spinlock without acquiring the global spinlock, attempting to acquire a first local spinlock of the plurality of local spinlocks, wherein the first local spinlock is randomly selected.

### Claim 17 (depends on 16)

The method of claim 16, further comprising:
in response to acquiring the first local spinlock, attempting to locally acquire the global spinlock.

### Claim 18 (depends on 17)

The method of claim 17, further comprising:
in response to locally acquiring the global spinlock, setting the second flag to indicate that the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 19 (depends on 16)

The method of claim 16, further comprising:
in response to spinning a second specific number of times attempting to acquire the first local spinlock without acquiring the first local spinlock, attempting to acquire a second local spinlock of the plurality of local spinlocks, wherein the second local spinlock is randomly selected.

### Claim 20 (depends on 9)

The method of claim 9, further comprising:
in response to determining that the second flag indicates that the global spinlock is acquired through a local spinlock configured to control access to the global spinlock, attempting to acquire a first local spinlock of the plurality of local spinlocks.

### Claim 21

A computer program product including one or more non-transitory machine readable mediums encoded with instructions that when executed by one or more processors cause a process to be carried out to control access to a shareable resource, the process comprising:
allocating a global spinlock configured to control access to a shareable resource, the global spinlock comprising a first flag and a second flag; and
allocating a plurality of local spinlocks, each local spinlock of the plurality of local spinlocks configured to control access to the global spinlock;
wherein the first flag indicates whether the global spinlock is directly acquired, and the second flag indicates whether the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.

### Claim 22 (depends on 21)

The computer program product of claim 21, the process further comprising:
attempting to globally acquire the global spinlock; and
in response to globally acquiring the global spinlock, setting the first flag to indicate that the global spinlock is directly acquired.

### Claim 23 (depends on 21)

The computer program product of claim 21, the process further comprising:
spinning a first specific number of times attempting to acquire the global spinlock; and
in response to spinning the first specific number of times attempting to globally acquire the global spinlock without acquiring the global spinlock, attempting to acquire a first local spinlock of the plurality of local spinlocks.

### Claim 24 (depends on 23)

The computer program product of claim 23, the process further comprising:
in response to acquiring the first local spinlock, attempting to locally acquire the global spinlock.

### Claim 25 (depends on 24)

The computer program product of claim 24, the process further comprising:
in response to locally acquiring the global spinlock, setting the second flag to indicate that the global spinlock is acquired through a local spinlock configured to control access to the global spinlock.
