# US 2003/0212731 A1 · Apparatus and method for periodic load balancing in a multiple run queue system

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

- Number: US 2003/0212731 A1
- Document ID: US20030212731A1
- Status: Published application
- Kind: A1
- Application number: 10/449,200
- Filed: 2003-05-30
- Published: 2003-11-13
- Earliest claimed: 2000-02-17
- Assignees: International Business Machines Corporation
- Inventors: Larry Bert Brenner; Luke Matthew Browning
- Web page: https://patentgrep.com/patent/US20030212731A1

## CPC

- G06F 9/5088: {involving task migration}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An apparatus and methods for periodic load balancing in a multiple run queue system are provided. The apparatus includes a controller, memory, initial load balancing device, idle load balancing device, periodic load balancing device, and starvation load balancing device. The apparatus performs initial load balancing, idle load balancing, periodic load balancing and starvation load balancing to ensure that the workloads for the processors of the system are optimally balanced.

## Claims

### Claim 1

A method of balancing workload among a plurality of local run queues, comprising:
identifying a heaviest local run queue and a lightest local run queue, the heaviest local run queue being a local run queue with a highest load average and the lightest local run queue being a local run queue with a lowest load average;
calculating a difference in load average between the heaviest local run queue and the lightest local run queue; and
performing load balancing if the difference exceeds a threshold amount.

### Claim 2 (depends on 1)

The method of claim 1, wherein performing load balancing includes:
identifying an unbound thread assigned to the heaviest local run queue; and
reassigning the unbound thread to the lightest local run queue.

### Claim 3 (depends on 2)

The method of claim 2, wherein reassigning the unbound thread includes:
obtaining a lock for the unbound thread; and
changing a run queue pointer of the thread to identify the lightest local run queue.

### Claim 4 (depends on 2)

The method of claim 2, wherein identifying an unbound thread includes:
obtaining a lock for the heaviest local run queue; and
scanning the heaviest local run queue for an unbound thread, wherein the scanning of the heaviest local run queue starts with threads having a medium priority.

### Claim 5 (depends on 1)

The method of claim 1, wherein if the lightest local run queue has benefited from idle load balancing within a determine period of time, load balancing is prevented.

### Claim 6 (depends on 3)

The method of claim 3, wherein changing the run queue pointer of the thread to identify the lightest local run queue includes holding the thread in a temporary queue prior to changing the run queue pointer of the thread to identify the lightest local run queue.

### Claim 7 (depends on 1)

The method of claim 1, wherein the threshold amount is 1.5.

### Claim 8 (depends on 5)

The method of claim 5, wherein idle load balancing includes:
identifying an idle local run queue;
scanning the plurality of local run queues for a run queue that satisfies idle load balancing criteria; and
if a local run queue is found that satisfies the idle load balancing criteria, stealing a thread from the local run queue satisfying the idle load balancing criteria.

### Claim 9 (depends on 8)

The method of claim 8, wherein scanning the plurality of local run queues for a run queue that satisfies idle load balancing criteria includes identifying a local run queue that has a largest number of threads, contains more threads than a selected threshold, and contains at least one unbound thread.

### Claim 10 (depends on 9)

The method of claim 9, wherein the selected threshold is a fraction of a smoothed average load factor of the plurality of local run queues.

### Claim 11

A computer program product in a computer readable medium for balancing workload among a plurality of local run queues, comprising:
first instructions for identifying a heaviest local run queue and a lightest local run queue, the heaviest local run queue being a local run queue with a highest load average and the lightest local run queue being a local run queue with a lowest load average;
second instructions for calculating a difference in load average between the heaviest local run queue and the lightest local run queue; and
third instructions for performing load balancing if the difference exceeds a threshold amount.

### Claim 12 (depends on 11)

The computer program product of claim 11, wherein the third instructions include:
instructions for identifying an unbound thread assigned to the heaviest local run queue; and
instructions for reassigning the unbound thread to the lightest local run queue.

### Claim 13 (depends on 12)

The computer program product of claim 12, wherein the instructions for reassigning the unbound thread include:
instructions for obtaining a lock for the unbound thread; and
instructions for changing a run queue pointer of the thread to identify the lightest local run queue.

### Claim 14 (depends on 12)

The computer program product of claim 12, wherein the instructions for identifying an unbound thread include:
instructions for obtaining a lock for the heaviest local run queue; and
instructions for scanning the heaviest local run queue for an unbound thread, wherein the scanning of the heaviest local run queue starts with threads having a medium priority.

### Claim 15 (depends on 11)

The computer program product of claim 11, wherein the third instructions include instructions for not performing the load balancing if the lightest local run queue has benefited from idle load balancing within a determine period of time.

### Claim 16 (depends on 13)

The computer program product of claim 13, wherein the instructions for changing the run queue pointer of the thread to identify the lightest local run queue include instructions for holding the thread in a temporary queue prior to changing the run queue pointer of the thread to identify the lightest local run queue.

### Claim 17 (depends on 11)

The computer program product of claim 11, wherein the third instructions include instructions for setting the threshold amount to 1.5.

### Claim 18

A workload balancing apparatus for balancing workload among a plurality of local run queues in a multiple run queue system, comprising:
means for identifying a heaviest local run queue and a lightest local run queue, the heaviest local run queue being a local run queue with a highest load average and the lightest local run queue being a local run queue with a lowest load average;
means for calculating a difference in load average between the heaviest local run queue and the lightest local run queue; and
means for performing load balancing if the difference exceeds a threshold amount.

### Claim 19 (depends on 18)

The apparatus of claim 18, wherein the means for performing load balancing includes:
means for identifying an unbound thread assigned to the heaviest local run queue; and
means for reassigning the unbound thread to the lightest local run queue.

### Claim 20 (depends on 19)

The apparatus of claim 19, wherein the means for reassigning the unbound thread includes:
means for obtaining a lock for the unbound thread; and
means for changing a run queue pointer of the thread to identify the lightest local run queue.

### Claim 21 (depends on 19)

The apparatus of claim 19, wherein the means for identifying an unbound thread includes:
means for obtaining a lock for the heaviest local run queue; and
means for scanning the heaviest local run queue for an unbound thread, wherein the scanning of the heaviest local run queue starts with threads having a medium priority.

### Claim 22 (depends on 18)

The apparatus of claim 18, wherein the means for performing load balancing is inactive if the lightest local run queue has benefited from idle load balancing within a determine period of time.

### Claim 23 (depends on 20)

The apparatus of claim 20, wherein the means for changing the run queue pointer of the thread to identify the lightest local run queue includes means for holding the thread in a temporary queue prior to changing the run queue pointer of the thread to identify the lightest local run queue.

### Claim 24 (depends on 18)

The apparatus of claim 18, wherein the threshold amount is 1.5.

### Claim 25 (depends on 23)

The apparatus of claim 23, wherein the means for idle load balancing includes:
means for identifying an idle local run queue;
means for scanning the plurality of local run queues for a run queue that satisfies idle load balancing criteria; and
means for stealing a thread, if a local run queue is found that satisfies the idle load balancing criteria, from the local run queue satisfying the idle load balancing criteria.

### Claim 26 (depends on 26)

The apparatus of claim 26, wherein the means for scanning the plurality of local run queues for a run queue that satisfies idle load balancing criteria includes means for identifying a local run queue that has a largest number of threads, contains more threads than a selected threshold, and contains at least one unbound thread.

### Claim 27 (depends on 26)

The apparatus of claim 26, wherein the selected threshold is a function of a smoothed average load factor of the plurality of local run queues.

### Claim 28

A method of balancing workload among a plurality of processors, comprising:
identifying an idle processor from the plurality of processors;
scanning the plurality of processors for a processor meeting idle load balancing criteria; and
if a processor meeting the idle load balancing criteria is found, performing idle load balancing.

### Claim 29 (depends on 28)

The method of claim 28, wherein scanning the plurality of processors for a processor that satisfies idle load balancing criteria includes identifying a processor having a local run queue that has a largest number of threads, contains more threads than a selected threshold, and contains at least one unbound thread.

### Claim 30 (depends on 29)

The method of claim 29, wherein the selected threshold is a function of a smoothed average load factor of the plurality of processors.

### Claim 31

A multiple processor system, comprising:
a plurality of processors; and
a dispatcher, wherein each of the plurality of processors has an associated local run queue and wherein the dispatcher identifies a heaviest local run queue and a lightest local run queue, the heaviest local run queue being a local run queue with a highest load average and the lightest local run queue being a local run queue with a lowest load average, calculates a difference in load average between the heaviest local run queue and the lightest local run queue, and performs load balancing if the difference exceeds a threshold amount.

### Claim 32 (depends on 31)

The system of claim 31, wherein the dispatcher performs load balancing by:
identifying an unbound thread assigned to the heaviest local run queue; and
reassigning the unbound thread to the lightest local run queue.

### Claim 33 (depends on 32)

The system of claim 32, wherein the dispatcher reassigns the unbound thread by:
obtaining a lock for the unbound thread; and
changing a run queue pointer of the thread to identify the lightest local run queue.

### Claim 34 (depends on 32)

The system of claim 32, wherein the dispatcher identifies an unbound thread by:
obtaining a lock for the heaviest local run queue; and
scanning the heaviest local run queue for an unbound thread, wherein the scanning of the heaviest local run queue starts with threads having a medium priority.

### Claim 35 (depends on 31)

The system of claim 31, wherein if the lightest local run queue has benefited from idle load balancing within a determine period of time, the dispatcher does not perform load balancing.

### Claim 36 (depends on 33)

The system of claim 33, wherein the dispatcher holds the thread in a temporary queue prior to changing the run queue pointer of the thread to identify the lightest local run queue.

### Claim 37 (depends on 31)

The system of claim 31, wherein the threshold amount is 1.5.

### Claim 38 (depends on 35)

The system of claim 35, wherein the dispatcher performs idle load balancing by:
identifying an idle local run queue;
scanning the plurality of local run queues for a run queue that satisfies idle load balancing criteria; and
if a local run queue is found that satisfies the idle load balancing criteria, stealing a thread from the local run queue satisfying the idle load balancing criteria.

### Claim 39 (depends on 38)

The system of claim 38, wherein the dispatcher scans the plurality of local run queues for a run queue that satisfies idle load balancing criteria by identifying a local run queue that has a largest number of threads, contains more threads than a selected threshold, and contains at least one unbound thread.

### Claim 40 (depends on 39)

The system of claim 39, wherein the selected threshold is a function of a smoothed average load factor of the plurality of local run queues.
