Computing device shared resource lock allocation
AssigneeHuawei Technologies Co., Ltd.
InventorShengyu Shen
Life of this patent
Estimating the term…
Abstract
A lock allocation method and apparatus, and a computing device to resolve a problem of lock contention, where the method includes a first node controller (NC) receives a first migration queue from a second NC, allocates a first target lock to a first central processing unit (CPU) associated with the first NC, deletes the first lock request at the queue head in the first migration queue when receiving a request for releasing the first target lock from the first CPU, changes a lock flag bit of a second lock request to a lock flag bit indicating a locked state when the first migration queue is not empty, determines a third NC sending the second lock request, and sends the first migration queue to the third NC.
Claims20
A lock allocation method implemented by a first node controller (NC) and comprising:
- receiving, from a second NC managing a first target lock, a first migration queue comprising at least one lock request for requesting the first target lock, wherein a first lock request is at a first queue head in the first migration queue and comprises a first identifier of the first NC;
- allocating the first target lock to a first central processing unit (CPU) associated with the first NC;
- deleting the first lock request when receiving a request for releasing the first target lock from the first CPU;
- changing a second lock flag bit of a second lock request to a locked state when a to-be-processed lock request exists in the first migration queue from which the first lock request is deleted, wherein the locked state indicates that the first target lock is occupied, wherein the second lock request is at the first queue head in the first migration queue from which the first lock request is deleted, and wherein the second lock request comprises a third identifier of a third NC sending the second lock request;
- sending a response packet to the second NC when the first migration queue from which the first lock request is deleted is empty, wherein the response packet indicates that all lock requests in the first migration queue are processed, wherein the lock requests comprise the at least one lock request;
- and
- sending the first migration queue to the third NC to instruct the third NC to change, based on the second lock flag bit, a lock flag bit of a lock request corresponding to the second lock request in a third local queue of the third NC and storing a lock request from a CPU associated with the third NC.
A computing device comprising:
- a plurality of central processing units (CPUs) comprising a first CPU and a second CPU;
- and
- a plurality of node controllers (NCs) in a one-to-one correspondence with the CPUs, wherein the NCs comprise a first NC associated with the first CPU, a second NC, and a third NC associated with the second CPU,
- wherein the first CPU is configured to:
- send, to the first NC, a third lock request requesting a first target lock;
- query a third lock flag bit of the third lock request in a first local queue of the first NC;
- access a shared resource corresponding to the first target lock when the third lock flag bit indicates a locked state;
- and
- send, to the first NC, a request for releasing the first target lock after accessing the shared resource,
- wherein the first NC is configured to:
- receive the third lock request from the first CPU;
- add the third lock request to the first local queue;
- add a first identifier of the first NC to the third lock request to obtain a first lock request;
- and
- send the first lock request to the second NC managing the first target lock, wherein the first local queue is configured to store a lock request from the first CPU, and wherein a remote queue of the first NC and associated with the first target lock is configured to store at least one lock request for requesting the first target lock,
- wherein the second NC is configured to:
- receive the first lock request;
- add the first lock request to the remote queue;
- remove the at least one lock request from the remote queue to generate a first migration queue, wherein a lock request at a first queue head in the first migration queue is the first lock request, and wherein the first lock request comprises the first identifier;
- change a first lock flag bit of the first lock request to the locked state;
- and
- send the first migration queue to the first NC,
- wherein the first NC is further configured to:
- receive the first migration queue;
- allocate the first target lock to the first CPU;
- delete the first lock request at the first queue head when receiving the request from the first CPU;
- change a second lock flag bit of a second lock request to the locked state when a to-be-processed lock request exists in the first migration queue from which the first lock request is deleted, wherein the second lock request is at the first queue head in the first migration queue from which the first lock request is deleted, wherein the locked state indicates that the first target lock is occupied, wherein the second lock request comprises a third identifier of the third NC sending the second lock request;
- and
- send the first migration queue to the third NC, and
- wherein the third NC is configured to:
- receive the first migration queue from the first NC;
- and
- change, according to the second lock flag bit, a lock flag bit of a lock request corresponding to the second lock request in a third local queue of the third NC and storing a lock request from the second CPU.
A first node controller (NC) comprising:
- a storage circuit configured to store instructions;
- and
- a processor coupled to the storage circuit and configured to execute the instructions to:
- receive, from a second NC managing a first target lock, a first migration queue comprising at least one lock request for requesting the first target lock, wherein a first lock request is at a first queue head in the first migration queue and comprises a first identifier of the first NC;
- allocate the first target lock to a first central processing unit (CPU) associated with the first NC;
- delete the first lock request when receiving a request for releasing the first target lock from the first CPU;
- change a second lock flag bit of a second lock request to a locked state when a to-be-processed lock request exists in the first migration queue from which the first lock request is deleted, wherein the locked state indicates that the first target lock is occupied, wherein the second lock request is at the first queue head in the first migration queue from which the first lock request is deleted, and wherein the second lock request comprises a third identifier of a third NC sending the second lock request;
- send a response packet to the second NC when the first migration queue from which the first lock request is deleted is empty, wherein the response packet indicates that all lock requests in the first migration queue are processed, wherein the lock requests comprise the at least one lock request;
- and
- send the first migration queue to the third NC to instruct the third NC to change, based on the second lock flag bit, a lock flag bit of a lock request corresponding to the second lock request in a third local queue of the third NC and storing a lock request from a CPU associated with the third NC.
Dependencies are inferred from the claim text.