IP Library › Granted Patent US 12,452,176
Granted Patent B2
US 12,452,176 · App. 18/533,886 · Granted Oct 21, 2025

Load balancing method for multi-thread forwarding and related apparatus

Inventors: Xiangjun Meng (Shenzhen, CN); Yunjian Wang (Hangzhou, CN); Lijun Li (Hangzhou, CN); Chunhe Li (Hangzhou, CN); Dingke Xu (Hangzhou, CN)
Assignee: HUAWEI TECHNOLOGIES CO., LTD.
H04L47/125H04L47/626H04L49/70H04L49/9068
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,452,176
App. No.
18/533,886
Granted
Oct 21, 2025
Kind
B2
Abstract

A load balancing method for multi-thread forwarding includes determining a first thread and a second thread from a plurality of threads, where the plurality of threads are all used to process data packets in virtual network interface card queues, wherein a load of the first thread is greater than a first threshold, wherein a load of the second thread is less than a second threshold, and wherein the first threshold is greater than the second threshold; determining a first queue from a plurality of virtual network interface card queues corresponding to the first thread, where the first thread is used to process data packets in the plurality of virtual network interface card queues; and switching the first queue to the second thread, so that the second thread processes a data packet in the first queue.

Claims (74)

1. A method comprising:

determining a first thread and a second thread from a plurality of threads, wherein the plurality of threads is for processing data packets in virtual network interface card queues, wherein the first thread processes a first load of the data packets, wherein the second thread processes a second load of the data packets;

determining a first queue from a plurality of virtual network interface card queues corresponding to the first thread;

switching the first queue from the first thread to the second thread in response to the first load being greater than a first threshold and the second load being less than a second threshold, and wherein the first threshold is greater than the second threshold; and

processing, by the second thread, a first data packet in the first queue.

2. The method of claim 1 , wherein switching the first queue from the first thread to the second thread comprises:

marking the first queue as a scheduling mode, wherein the scheduling mode indicates that the first queue is of a to-be-switched thread; and

marking the first queue as a polling packet receiving mode, wherein the polling packet receiving mode indicates to the second thread to process the first data packet in a polling manner.

3. The method of claim 1 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, from the plurality of virtual network interface card queues corresponding to the first thread, one or more virtual network interface card queues marked as a polling packet receiving mode; and

determining the first queue from the one or more virtual network interface card queues.

4. The method of claim 1 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, based on the first load and the second threshold, a first maximum load amount that can be transferred by the first thread;

determining, based on the second load and the first threshold, a second maximum load amount that can be received by the second thread; and

determining the first queue based on the first maximum load amount and the second maximum load amount, wherein both the first maximum load amount and the second maximum load amount are greater than or equal to a load amount corresponding to the first queue.

5. The method of claim 1 , further comprising

polling, by the first thread, a second queue marked as a polling packet receiving mode;

marking, when a quantity of times that the first thread continuously polls the second queue marked as the polling packet receiving mode is greater than a third threshold and when no data packet is received during a period that the first thread continuously polls the second queue, the second queue as an interrupt packet receiving mode, wherein the plurality of virtual network interface card queues comprises the second queue; and

obtaining, by the first thread, an interrupt signal from the second queue, wherein the interrupt packet receiving mode indicates to the first thread to trigger processing of a second data packet in the second queue after obtaining the interrupt signal from the second queue.

6. The method of claim 1 , further comprising:

obtaining, by the first thread, an interrupt signal from a third queue marked as an interrupt packet receiving mode, wherein the interrupt packet receiving mode indicates to the first thread to trigger processing of a data packet in the third queue after obtaining the interrupt signal; and

marking the third queue as a polling packet receiving mode in response to obtaining the interrupt signal, wherein the polling packet receiving mode indicates to the first thread to process the data packet in the third queue in a polling manner.

7. The method of claim 1 , further comprising:

obtaining a third load of the plurality of threads in a first time period;

predicting a fourth load of the plurality of threads in a second time period based on the third load, wherein the second time period is after the first time period; and

creating, when the fourth load is greater than a fourth threshold, a new thread for processing the data packets in the virtual network interface card queues, or deleting, when the fourth load is less than a fifth threshold, a part of threads from the plurality of threads.

8. The method of claim 7 , wherein deleting the part of threads from the plurality of threads comprises:

determining a to-be-deleted thread and a to-be-reserved thread from the plurality of threads;

switching a virtual network interface card queue corresponding to the to-be-deleted thread to the to-be-reserved thread; and

deleting the to-be-deleted thread.

9. The method of claim 1 , wherein the first load comprises processor resource utilization corresponding to the first thread.

10. A device comprising:

a memory configured to store instructions; and

one or more processors coupled to the memory and configured to execute the instructions to cause the device to:

determine a first thread and a second thread from a plurality of threads, wherein the plurality of threads is for processing data packets in virtual network interface card queues, wherein the first thread processes a first load of the data packets, wherein the second thread processes a second load of the data packets;

determine a first queue from a plurality of virtual network interface card queues corresponding to the first thread;

switch the first queue to the second thread in response to the first load being greater than a first threshold and the second load being less than a second threshold, and wherein the first threshold is greater than the second threshold; and

process, by the second thread, a first data packet in the first queue.

11. The device of claim 10 , wherein switching the first queue to the second thread comprises:

marking the first queue as a scheduling mode, wherein the scheduling mode indicates that the first queue is a queue of a to-be-switched thread;

switching the first queue from the first thread to the second thread; and

marking the first queue as a polling packet receiving mode, wherein the polling packet receiving mode indicates to the second thread to process the first data packet in the first queue in a polling manner.

12. The device of claim 10 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, from the plurality of virtual network interface card queues corresponding to the first thread, one or more virtual network interface card queues marked as a polling packet receiving mode; and

determining the first queue from the one or more virtual network interface card queues.

13. The device of claim 10 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, based on the first load and the second threshold, a first maximum load amount that can be transferred by the first thread;

determining, based on the second load and the first threshold, a second maximum load amount that can be received by the second thread; and

determining the first queue based on the first maximum load amount and the second maximum load amount, wherein both the first maximum load amount and the second maximum load amount are greater than or equal to a load amount corresponding to the first queue.

14. The device of claim 10 , wherein the one or more processors are further configured to execute the instructions to cause the device to:

poll, by the first thread, a second queue marked as a polling packet receiving mode;

mark, when a quantity of times that the first thread continuously polls the second queue marked as the polling packet receiving mode is greater than a third threshold, and when no data packet is received during a period that the first thread continuously polls the second queue, the second queue as an interrupt packet receiving mode, wherein the plurality of virtual network interface card queues comprises the second queue; and

obtain, by the first thread, an interrupt signal from the second queue, wherein the interrupt packet receiving mode indicates to the first thread to trigger processing of a second data packet in the second queue after obtaining the interrupt signal from the second queue.

15. A computer program product comprising computer-executable instructions stored on a non-transitory computer-readable storage medium, the computer-executable instructions when executed by one or more processors of an apparatus, cause the apparatus to:

determine a first thread and a second thread from a plurality of threads, wherein the plurality of threads is for processing data packets in virtual network interface card queues, wherein the first thread processes a first load of the data packets, wherein the second thread processes a second load of the data packets;

determine a first queue from a plurality of virtual network interface card queues corresponding to the first thread;

switch the first queue to the second thread in response to the first load being greater than a first threshold and the second load being less than a second threshold, and wherein the first threshold is greater than the second threshold; and

process, by the second thread, a first data packet in the first queue.

16. The computer program product of claim 15 , wherein switching the first queue to the second thread comprises:

marking the first queue as a scheduling mode, wherein the scheduling mode indicates that the first queue is a queue of a to-be-switched thread;

switching the first queue from the first thread to the second thread; and

marking the first queue as a polling packet receiving mode, wherein the polling packet receiving mode indicates to the second thread to process the first data packet in the first queue in a polling manner.

17. The computer program product of claim 15 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, from the plurality of virtual network interface card queues corresponding to the first thread, one or more virtual network interface card queues marked as a polling packet receiving mode; and

determining the first queue from the one or more virtual network interface card queues.

18. The computer program product of claim 15 , wherein determining the first queue from the plurality of virtual network interface card queues corresponding to the first thread comprises:

determining, based on the first load and the second threshold, a first maximum load amount that can be transferred by the first thread;

determining, based on the second load and the first threshold, a second maximum load amount that can be received by the second thread; and

determining the first queue based on the first maximum load amount and the second maximum load amount, wherein both the first maximum load amount and the second maximum load amount are greater than or equal to a load amount corresponding to the first queue.

19. The computer program product of claim 15 , wherein the computer-executable instructions when executed by the one or more processors further cause the apparatus to:

poll, by the first thread, a second queue marked as a polling packet receiving mode;

mark, when a quantity of times that the first thread continuously polls the second queue marked as the polling packet receiving mode is greater than a third threshold, and when no data packet is received during a period that the first thread continuously polls the second queue, the second queue as an interrupt packet receiving mode, wherein the plurality of virtual network interface card queues comprises the second queue; and

obtain, by the first thread, an interrupt signal from the second queue, wherein the interrupt packet receiving mode indicates to the first thread to trigger processing of a second data packet in the second queue after obtaining the interrupt signal from the second queue.

20. The computer program product of claim 15 , wherein the first load comprises processor resource utilization corresponding to the first thread.

Assignments (3)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 4, 2025
From: WANG, YUNJIAN; LI, LIJUN; LI, CHUNHE; XU, DINGKE
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 071919/0496 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 4, 2025
From: HANGZHOU HUAWEI ENTERPRISES TELECOMMUNICATION TECHNOLOGIES CO., LTD.
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 071919/0616 →
EMPLOYMENT AGREEMENT Recorded Aug 4, 2025
From: MENG, XIANGJUN
To: HANGZHOU HUAWEI ENTERPRISES TELECOMMUNICATION TECHNOLOGIES CO., LTD.
Reel/Frame 072338/0555 →
Priority Claims (1)
CN 202110651243.1 · Jun 10, 2021 · national
Continuity (2)
Continuation PCTCN2022095899 · May 30, 2022
Related Publication 20240106754A1 · Mar 28, 2024
References Cited (15)
US 10560394B2 · Murugesan et al. · 2020 [cited by applicant]
US 11880726B1 · Ahmadizadeh · 2024 [cited by examiner]
US 20150055456A1 · Agarwal · 2015 [cited by examiner]
US 20190052530A1 · Awal · 2019 [cited by examiner]
US 20230283578A1 · Lin · 2023 [cited by examiner]
US 20240220446A1 · Kirubakaran · 2024 [cited by examiner]
US 20240248740A1 · Sharma · 2024 [cited by examiner]
US 20240291761A1 · K N · 2024 [cited by examiner]
CN 101968748A · 2011 [cited by applicant]
CN 107005531A · 2017 [cited by applicant]
CN 107368178A · 2017 [cited by applicant]
CN 108345502A · 2018 [cited by applicant]
CN 108632165A · 2018 [cited by applicant]
CN 110286743A · 2019 [cited by applicant]
WO 2016101099A1 · 2016 [cited by applicant]