Multi-Die CPU Spin Lock Segmentation for Thread Fairness

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The existing CPU processing mechanism for critical sections is inefficient due to unnecessary thread detection and interruptions, leading to longer execution times and suboptimal resource utilization when multiple threads compete for a spin lock.

Innovation Solution

Introducing a mutual exclusion lock (mutex) for each CPU die, allowing threads to compete for and obtain a mutex, then for a spin lock, execute the critical section, and release both locks efficiently, enabling the owner to maximize CPU resource usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If the OS interrupts the spin lock owner to wake up waiting threads to ensure fairness, then thread fairness is improved, but the critical section execution time increases and CPU resources are wasted

Engineering Contradiction:
Improvethread fairnessVSAvoidcritical section execution efficiency
Core Design Contradiction:
Ease of operationVSProductivity

Solution Approach 1:

The patent divides the single spin lock into multiple spin locks, one for each CPU die. This segmentation allows different CPU dies to access different spin locks simultaneously, eliminating the need to interrupt the current owner to wake up waiting threads on other dies, thus improving both fairness and execution efficiency

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces a new dimension of parallelism by creating separate spin lock instances for each CPU die. This dimensional separation enables concurrent access across different physical processing units, transforming the sequential single-lock model into a parallel multi-lock model that improves throughput without sacrificing fairness

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Ease of operation

If multiple threads continuously detect the spin lock status to ensure they can compete fairly, then thread responsiveness is improved, but unnecessary detection operations increase and execution time increases

Engineering Contradiction:
Improvethread responsivenessVSAvoiddetection operation time
Core Design Contradiction:
Ease of operationVSLoss of time

Solution Approach 1:

By segmenting the spin lock into die-specific instances, threads on different CPU dies can detect and acquire locks independently without interfering with each other. This eliminates unnecessary detection operations for threads on other dies, reducing wasted time while maintaining responsiveness

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent extracts the detection and locking mechanism from a centralized single spin lock to distributed per-die spin locks. This extraction removes the harmful effect of unnecessary cross-die detection operations, allowing each thread to detect only the relevant lock for its die, thereby reducing detection time overhead

Inventive Principle:
Principle #2Taking out (Extraction)

3Device complexity

If a single spin lock is used for all CPU dies to ensure centralized control, then lock management simplicity is improved, but CPU resource utilization decreases when multiple threads compete

Engineering Contradiction:
Improvelock management complexityVSAvoidCPU resource utilization
Core Design Contradiction:
Device complexityVSProductivity

Solution Approach 1:

The patent segments the centralized spin lock into multiple distributed spin locks, one per CPU die. This segmentation increases CPU resource utilization by allowing parallel lock acquisitions across different dies, while the complexity increase is minimal since each die manages its own lock independently

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent combines multiple per-die spin locks into a unified locking mechanism that works across the entire multi-die CPU. This merging approach maintains relative simplicity in lock management while enabling parallel execution and improving overall resource utilization compared to a single centralized lock

Inventive Principle:
Principle #5Merging (Combining)

Data Source

PatentUS11269693B2Method, apparatus, and electronic device for improving CPU performance
Publication Date: 2022.03.08 ADVANCED NEW TECHNOLOGIES CO LTD
  • US11269693B2 patent drawing
  • US11269693B2 patent drawing
  • US11269693B2 patent drawing

AI summary

Implementations of this specification provide a method, an apparatus, and an electronic device for improving performance of a central processing unit (CPU) comprising a plurality of CPU dies. The method includes the following: enabling threads in each CPU die of the CPU to compete for a mutex of a respective CPU die; identifying the plurality of threads that have obtained the mutexes; enabling the plurality of threads that have obtained the mutexes to compete for a spin lock of the CPU; identifying, from the plurality of threads, a target thread that has obtained the spin lock; executing a critical section corresponding to the target thread that has obtained the spin lock; and releasing the mutex and the spin lock that are obtained by the target thread.