USB network card performance tuning method based on interrupt binding
By determining the anchor core in the USB network card, dynamically binding interrupts, and switching processing modes, the problems of low latency, high throughput, and low CPU usage of USB network cards in high-frequency interrupt scenarios are solved, realizing systematic optimization and intelligent resource scheduling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-04-03
AI Technical Summary
The existing static interrupt binding method of USB network cards cannot perceive data flow semantics and load dynamics, making it difficult to balance low latency, high throughput and low CPU usage in high-frequency interrupt scenarios, and unable to intelligently schedule processing resources.
By identifying a high-performance CPU core as the anchor core, disabling automatic load balancing of interrupts, assigning semantic tags to data packets at the USB driver layer, dynamically deciding on interrupt triggering strategies, dynamically binding interrupts to the anchor core or other CPU cores based on semantic tags and system load, and switching to controlled polling mode when the load exceeds a threshold, a closed-loop self-optimizing system is established.
It achieves systematic optimization of USB network card interrupt handling, intelligently distinguishes between high-priority control flow and batch data flow, reduces interrupt frequency, ensures low-latency response of critical services, reduces cross-core migration and cache invalidation overhead, and improves the determinism and energy efficiency of the overall system I/O performance.
Smart Images

Figure CN121785784A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer system performance optimization technology, and in particular to a USB network card performance tuning method based on interrupt binding. Background Technology
[0002] With the widespread adoption of high-speed interfaces such as USB 3.0 and USB 4, USB network adapters have become crucial network adaptation devices for high-bandwidth, low-latency scenarios such as virtual reality streaming and industrial data acquisition. Their commonly used xHCI controller architecture is based on an event loop and transfer descriptor (TRB) mechanism, requiring a hardware interrupt to be triggered after each data transfer. In today's era of multi-core processors, especially with the dominance of big.LITTLE heterogeneous computing architectures, efficiently managing the high-frequency interrupts generated by USB network adapters to reduce processing latency, increase throughput, and decrease CPU usage has become a core challenge for improving overall system I / O performance.
[0003] Existing technical solutions primarily focus on binding the affinity of USB controller interrupts to specific high-performance CPU cores through static configuration and attempting to reduce frequency through interrupt aggregation. However, such static binding strategies lack the ability to perceive dynamic load and data flow semantics, and cannot intelligently distinguish between real-time control flow and batch data flow, making it difficult to balance interrupt response and throughput. At the same time, the fixed processing mode cannot adaptively switch between interrupt storms and idle states, failing to fundamentally solve the deterministic latency and jitter problems caused by cross-core scheduling, cache invalidation, and interrupt context switching overhead. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides a USB network card performance optimization method based on interrupt binding to solve the systemic problem that the existing static interrupt binding method for USB network cards cannot perceive data flow semantics and load dynamics, making it difficult to intelligently schedule processing resources, and thus cannot simultaneously achieve low latency, high throughput and low CPU usage in high-frequency interrupt scenarios.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a USB network card performance tuning method based on interrupt binding, characterized by comprising the following steps: Identify the high-performance CPU core of the system as the anchor core and disable automatic load balancing for interrupts; The incoming data packets are analyzed in real time at the USB driver layer, and semantic tags are assigned to the data packets based on preset rules; Based on the semantic tag dynamic decision-making interruption triggering strategy, the video data stream is aggregated and waited, and an interruption is triggered immediately when a high-priority data packet is identified; Based on semantic tags and system load, the triggered interrupts are dynamically bound to the anchor core or other CPU cores and associated with the corresponding network queues; Monitor the interrupt load of the anchor core, and when the load exceeds the threshold, switch the specified data stream from interrupt mode to controlled polling mode for processing; Collect performance metrics during the processing and adjust the interrupt triggering strategy and mode switching conditions based on the metric feedback.
[0007] As a preferred embodiment of the interrupt-binding-based USB network card performance tuning method described in this invention, the specific steps of determining the high-performance CPU core of the system as the anchor core and disabling automatic load balancing of interrupts are as follows: Read the system CPU topology information and identify the numbers of all high-performance cores; Query the status of the system interrupted load balancing service; if the service is running, send a stop command to it. From the identified high-performance core numbers, select the core with the lowest current system load and record its number as the anchor core identifier; The anchor core identifier is passed to the interrupt affinity setting interface as the default target for subsequent interrupt binding.
[0008] As a preferred embodiment of the interrupt-binding-based USB network card performance tuning method of the present invention, the specific steps of performing real-time analysis of incoming data packets at the USB driver layer and assigning semantic tags to the data packets based on preset rules are as follows: On the path of receiving data packets in the USB network driver, the length, arrival time interval, and corresponding USB endpoint address information of each data packet are intercepted; A temporary analysis window is formed by combining consecutively arriving data packets, and the length distribution and interval pattern of the data packets within the window are calculated. The length distribution and interval pattern are matched with predefined flow feature templates in the rule base, the templates including high-frequency small packet templates and burst large packet templates; Based on the matching results, corresponding semantic tags are assigned to the current analysis window and subsequent data packets from the same source. These tags include high-priority control tags and video data block tags.
[0009] As a preferred embodiment of the USB network card performance tuning method based on interrupt binding described in this invention, the steps of dynamically deciding the interrupt triggering strategy according to semantic tags, aggregating and waiting for the video data stream, and immediately triggering an interrupt when a high-priority data packet is identified are as follows: Check the semantic tags carried by the data packets currently awaiting processing. If they are video data block tags, proceed to the aggregation waiting process. During the aggregation waiting process, a microsecond-level timer is started and data packet completion events belonging to the same video frame are accumulated. During the waiting period, continuously check the tags of newly completed data packets. If a high-priority control tag appears, immediately terminate the waiting and generate an interrupt trigger command. If the timer times out or the accumulated data volume reaches the estimated frame size, an interrupt trigger instruction is generated and the waiting state is reset.
[0010] As a preferred embodiment of the interrupt-based USB network card performance tuning method described in this invention, the step of dynamically binding triggered interrupts to anchor cores or other CPU cores based on semantic tags and system load, and associating them with corresponding network queues, specifically includes the following steps: Receive interrupt trigger commands and associated data stream semantic tags; Read the current interrupt count and CPU utilization of the anchor core to determine whether they exceed the light load threshold; If the semantic tag is a high-priority control tag, or the anchor core is in a light-load state, then the affinity of this interruption is set to the anchor core. Set the flow routing policy of the network receive queue associated with the USB endpoint where the interrupt occurred to point to the same anchor core to complete the path binding.
[0011] As a preferred embodiment of the interrupt-binding-based USB network card performance tuning method of the present invention, wherein: the interrupt load of the monitoring anchor core is adjusted so that when the load exceeds a threshold, a specified data stream is switched from interrupt mode to controlled polling mode for processing. The specific steps are as follows: On the anchor core, frequency statistics are performed on the interruption of the specific video data stream bound to the core, the number of interruptions I per unit time is calculated, and the CPU utilization U of the current anchor core and the processing time sample of the most recent N interruptions of the data stream are collected simultaneously. The interrupt processing latency fluctuation coefficient W is calculated based on the interrupt processing time sample. The number of interrupts I, CPU utilization U and fluctuation coefficient W are substituted into the state evaluation function F for calculation. The expression of the state evaluation function F is: F = (I×(1+W)) / U. When the function value F exceeds the preset system stability threshold S, it is determined that the data stream has entered a high throughput and unstable state. Send a command to the USB controller to disable the interrupt reporting function of the endpoint corresponding to this data stream; A dedicated kernel thread is started and bound to the anchor core to poll the data completion status of the endpoint at fixed microsecond intervals and process it.
[0012] As a preferred embodiment of the interrupt-binding-based USB network card performance tuning method of the present invention, the specific steps of collecting performance indicators during the processing and adjusting the interrupt triggering strategy and mode switching conditions based on indicator feedback are as follows: Continuously measure and record the total latency of data packets with high-priority control tags from interrupt triggering to being read by the user layer; The total latency is compared with the target latency threshold. If the average latency exceeds the threshold, an instruction to tighten the aggregation strategy is generated. The instructions to tighten the aggregation strategy are translated into parameter adjustment actions, including shortening the aggregation wait timer duration; The adjusted parameters are updated into the decision logic and switching judgment logic to form a closed-loop control.
[0013] Secondly, the present invention provides a USB network card performance tuning system based on interrupt binding, comprising, The core management module identifies the system's high-performance CPU core as the anchor core and disables automatic load balancing for interrupts. The stream identification module performs real-time analysis of incoming data packets at the USB driver layer and assigns semantic tags to the data packets based on preset rules. The interruption decision module dynamically determines the interruption triggering strategy based on semantic tags, aggregates and waits for the video data stream, and immediately triggers an interruption when a high-priority data packet is identified. The binding execution module dynamically binds triggered interrupts to anchor cores or other CPU cores based on semantic tags and system load, and associates them with corresponding network queues; The mode switching module monitors the interrupt load of the anchor core. When the load exceeds the threshold, it switches the specified data stream from interrupt mode to controlled polling mode for processing. The optimization module collects performance metrics during the processing and adjusts the interrupt triggering strategy and mode switching conditions based on the metric feedback.
[0014] Thirdly, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the interrupt-binding-based USB network card performance tuning method described in the first aspect of the present invention.
[0015] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the interrupt-binding-based USB network card performance tuning method described in the first aspect of the present invention.
[0016] The beneficial effects of this invention are as follows: By introducing a data flow semantic awareness and dynamic intelligent scheduling mechanism, a systematic optimization of the USB network card interrupt handling process is achieved. It can intelligently distinguish between high-priority control flow and batch data flow at the driver layer, and dynamically decide on interrupt aggregation strategies and triggering timing based on these semantic tags, thereby reducing interrupt frequency while ensuring low-latency response for critical services. By treating interrupt binding, queue association, and processing mode (interrupt / polling) as linked resource scheduling units that can be dynamically adjusted according to system load, interrupt storms are effectively suppressed, and unnecessary cross-core migration and cache invalidation overhead are reduced. Ultimately, this method constructs a tuning system with closed-loop self-optimization capabilities, enabling the USB network card to maintain stable low latency and low CPU usage even under high throughput loads, improving the determinism and energy efficiency of the overall system I / O performance. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of the USB network card performance tuning method based on interrupt binding in Example 1. Detailed Implementation
[0019] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0020] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0021] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0022] Example 1, referring to Figure 1 This is the first embodiment of the present invention, which provides a USB network card performance tuning method based on interrupt binding, characterized by including the following steps: Identify the high-performance CPU core of the system as the anchor core and disable automatic load balancing for interrupts; The incoming data packets are analyzed in real time at the USB driver layer, and semantic tags are assigned to the data packets based on preset rules; Based on the semantic tag dynamic decision-making interruption triggering strategy, the video data stream is aggregated and waited, and an interruption is triggered immediately when a high-priority data packet is identified; Based on semantic tags and system load, the triggered interrupts are dynamically bound to the anchor core or other CPU cores and associated with the corresponding network queues; Monitor the interrupt load of the anchor core, and when the load exceeds the threshold, switch the specified data stream from interrupt mode to controlled polling mode for processing; Collect performance metrics during the processing and adjust the interrupt triggering strategy and mode switching conditions based on the metric feedback.
[0023] It should be noted that, firstly, by parsing the system CPU topology file, all logical numbers marked as high-performance cores are filtered out. Then, system interrupt load balancing services such as irqbalance are queried and stopped to prevent them from dynamically adjusting interrupt allocation later. From the filtered high-performance cores, the system load metrics of each core are read in real time, and the core with the lowest current load is selected and its number is officially recorded as the anchor core identifier for this optimization. This establishes a stable, controllable, and high-performance execution anchor point for all subsequent interrupt and task scheduling, fundamentally eliminating unexpected interference from system background services on interrupt affinity, and providing a reliable hardware resource foundation for the transition from static binding to dynamic intelligent scheduling.
[0024] Hook functions are embedded in the data reception path of the USB network driver to capture the length, arrival time interval, and hardware endpoint address of each raw data packet in real time. Multiple consecutively arriving data packets are temporarily stored in a sliding analysis window, and the variance of packet length and periodicity of arrival intervals within the window are quickly calculated. Then, the calculated distribution pattern is compared with feature templates pre-set in the rule base. For example, the pattern of "small packet length, high frequency, fixed interval" is matched as interactive control flow, and the pattern of "large packet length, burstiness, continuous arrival" is matched as video data block flow. Based on the matching results, the system assigns semantic labels such as "high priority control" or "video data block" to current and subsequent data packets from the same endpoint. This gives the abstract USB bus data a clear business semantic, enabling the subsequent scheduling mechanism to "understand" the meaning of the data flow, and is the primary information input for achieving intelligent decision-making.
[0025] Before the USB controller prepares to report an interrupt, it checks the semantic tags carried by the data packets that triggered the interrupt. If the tag is "video data block," a hardware interrupt is not triggered immediately. Instead, a microsecond-level timer is started, and the completion events of multiple data packets belonging to the same logical frame are accumulated in memory. During the waiting process, newly completed data packets are continuously monitored. Once a packet with the "high-priority control" tag is found, the waiting is immediately terminated, and an interrupt trigger command is submitted immediately. If no high-priority packet appears, the interrupt command is submitted only after the timer expires or the accumulated data volume reaches the estimated frame size. By utilizing semantic information, differentiated interrupt triggering is achieved, batch data is aggregated to reduce the number of interrupts, and immediate response to critical control signals is maintained, achieving an effective trade-off between high throughput and low latency at the system level.
[0026] After the interrupt trigger instruction is generated, the semantic tag of the data stream associated with the instruction is read synchronously. Simultaneously, the real-time interrupt count and CPU utilization snapshot of the anchor core are obtained through the system interface to determine if it is in a light-load state. A rule-based decision is made: if the semantic tag is "high-priority control," or the anchor core is lightly loaded, the interrupt is forcibly bound to the anchor core by writing to the interrupt affinity file; otherwise, it can be allocated to other available cores. Subsequently, the flow routing settings (such as RPS) of the network receive queue corresponding to the USB endpoint where this interrupt occurs are also pointed to the same target core. Upgrading interrupt binding from a fixed configuration to a conditional policy ensures the processing performance of critical traffic, while avoiding single-core overload through distributed binding under high load, achieving dynamic and elastic allocation of system resources.
[0027] On the anchor core, the specific high-throughput video data stream bound to it is monitored, and the number of interrupts per unit time is counted. Simultaneously, the CPU utilization of the core and the processing time of the stream's most recent interrupts are collected. Using these parameters, a comprehensive status evaluation function is calculated. When the function value exceeds a preset threshold, it is determined that the current interrupt mode is insufficient to efficiently process the stream. Subsequently, the driver sends a command to the USB controller to temporarily disable the interrupt reporting function of the endpoint corresponding to the data stream. Simultaneously, a dedicated kernel thread is woken up on the anchor core, its scheduling policy is set to run permanently on this core, and it actively polls the data completion status of the endpoint at precise microsecond intervals, replacing interrupts for data processing. This provides the ultimate means to cope with extreme "interrupt storms," completely eliminating the context switching overhead caused by high-frequency interrupts through mode switching, ensuring the determinism and stability of the system under extreme loads.
[0028] During system operation, the total latency experienced by data packets marked as "high-priority control" from interrupt triggering to being read by user-space applications is continuously measured. The system periodically compares the statistical mean of this latency (such as a rolling average) with a preset target latency threshold. If the average latency consistently exceeds the threshold, a policy adjustment instruction is generated, which is translated into specific parameter adjustment actions, such as shortening the timeout duration of the video data stream aggregation waiting timer in step three. The adjusted new parameters are updated in real time to the interrupt decision logic and mode switching judgment logic. A negative feedback closed loop is established from system output performance to front-end scheduling parameters, enabling the tuning system to perceive the long-term effects of its own strategy and adaptively fine-tune its behavior, thereby continuously maintaining optimal performance when facing changing network traffic patterns.
[0029] Specifically, the steps for determining the high-performance CPU core of the system as the anchor core and disabling automatic load balancing of interrupts are as follows: Read the system CPU topology information and identify the numbers of all high-performance cores; Query the status of the system interrupted load balancing service; if the service is running, send a stop command to it. From the identified high-performance core numbers, select the core with the lowest current system load and record its number as the anchor core identifier; The anchor core identifier is passed to the interrupt affinity setting interface as the default target for subsequent interrupt binding.
[0030] It should be noted that the process involves reading the system's CPU topology information and identifying the IDs of all high-performance cores. Specifically, this is done by programmatically accessing specific system file interfaces provided by the operating system kernel to obtain data describing the physical CPU core topology. This data includes attribute identifiers for each logical core. The program then parses and filters these identifiers to identify all cores marked as "high-performance," recording their unique logical IDs from the system's global scheduling perspective. This completes a precise mapping of the system's computing resources, providing an accurate hardware target pool for the subsequent targeted allocation of critical interrupt tasks and preventing the misallocation of critical tasks to low-performance cores in a big.LITTLE architecture.
[0031] The system queries the status of the interrupt load balancing service. If the service is running, a stop command is sent to it. Specifically, the system service management interface is invoked to query the running status of an interrupt automatic load balancing daemon named "irqbalance" or with similar functionality. If the service is confirmed to be active, standard control commands or signals are sent to it, requiring it to immediately stop running and exit, thereby depriving it of its ability to dynamically adjust the mapping relationship between interrupts and CPU cores. This proactively removes the interference of the system's background automation strategy on interrupt scheduling, clearing environmental interference for implementing the precise and deterministic binding strategy designed in this invention, and ensuring the effectiveness and stability of all subsequent manual or dynamic binding operations.
[0032] After obtaining the list of high-performance core IDs, the program reads the real-time load metrics file for each core provided by the system to obtain the current load data for each core in the list. The program compares these load values, selects the high-performance core with the lowest load reading, extracts its logical ID, and writes it into a dedicated memory variable or configuration file, officially designating it as the "anchor core" for this tuning process. Optimization was performed among the available high-performance resources to provide an execution location with the lightest initial load and the greatest response potential for interrupt handling, laying an efficient foundation for the entire tuning process.
[0033] The logical number of the "anchor core," determined and stored in the previous step, is passed as a parameter to the interrupt affinity setting interface exposed by the operating system kernel. This interface typically exists as a system file. By writing the bitmask or number of the anchor core into this interface file, a pre-setting is completed, declaring that USB interrupts meeting specific conditions should be directed to this core for processing by default. The selected core identifier is then translated into scheduling instructions recognizable by the system kernel, establishing a bridge from resource selection to actual scheduling behavior, ensuring that subsequent dynamic binding logic can make decisions and adjustments based on a clear default foundation.
[0034] Specifically, the process of performing real-time analysis of incoming data packets at the USB driver layer and assigning semantic tags to the data packets based on preset rules involves the following steps: On the path of receiving data packets in the USB network driver, the length, arrival time interval, and corresponding USB endpoint address information of each data packet are intercepted; A temporary analysis window is formed by combining consecutively arriving data packets, and the length distribution and interval pattern of the data packets within the window are calculated. The length distribution and interval pattern are matched with predefined flow feature templates in the rule base, the templates including high-frequency small packet templates and burst large packet templates; Based on the matching results, corresponding semantic tags are assigned to the current analysis window and subsequent data packets from the same source. These tags include high-priority control tags and video data block tags.
[0035] It should be noted that by modifying or extending the packet receiving function in the USB network device driver (such as the usbnet or cdc_ncm driver), a piece of monitoring code is inserted when the function processes raw data from the USB controller. This code synchronously records the payload length of the packet, the time interval difference since the arrival of the last packet from the same endpoint (obtained by reading a high-precision timer), and the address of the USB endpoint that generated the packet before the packet is passed to the network protocol stack. This information is encapsulated into a metadata unit and immediately sent to a dedicated analysis queue. This provides the most basic and necessary raw observation data for subsequent semantic analysis, enabling the driver layer to capture the micro-temporal and structural characteristics of the data stream for the first time.
[0036] A first-in, first-out (FIFO) buffer is maintained to temporarily store metadata of the continuous data packets generated in step one. This buffer forms a sliding analysis window. When the accumulated metadata within the window reaches a preset sample size or the time window expires, the system performs a batch statistical calculation on all samples within the window. The calculation includes the average, variance, or histogram distribution of all data packet lengths, as well as the average and standard deviation of the data packet arrival time intervals. After the calculation is complete, the window slides forward, incorporating new data and discarding old data. Aggregating and sublimating the features of discrete, individual data packets into macroscopic features that can describe the overall statistical regularity of the data stream over a period of time is a key processing step for discovering stable patterns and filtering out random noise.
[0037] The macroscopic feature vector calculated in step two is compared with a predefined rule base loaded into memory. The rule base contains various feature templates; for example, the "small packet high-frequency template" defines a feature range where packet length is less than a specific threshold and intervals are short and stable; the "large packet burst template" defines a feature range where packet length is large and intervals are bursty (large variance). The matching process is completed by calculating the multidimensional distance or similarity between the current feature vector and each template, and the template with the highest similarity is selected as the matching result. By associating real-time traffic features with known business models, the mapping and recognition from raw statistical features to preset business types is achieved.
[0038] After template matching is completed, the semantic identifier corresponding to the matched template (such as "high priority control" or "video data block") is used as a tag and first assigned to the data stream (identified by the USB endpoint address) that generated the current analysis window. The system then updates or establishes the association between the USB endpoint address and the semantic tag in a global stream tag mapping table. Subsequently, when the driver processes new data packets from the same endpoint, it can directly query this mapping table and attach this semantic tag to it without repeating window analysis and template matching, until a significant change in stream characteristics triggers a hot update. This completes the conversion from data to semantics, providing a clear and readable decision basis for all subsequent scheduling and processing logic in the driver layer.
[0039] Specifically, the step of dynamically deciding the interruption triggering strategy based on semantic tags, aggregating and waiting the video data stream, and immediately triggering an interruption upon identifying a high-priority data packet, involves the following steps: Check the semantic tags carried by the data packets currently awaiting processing. If they are video data block tags, proceed to the aggregation waiting process. During the aggregation waiting process, a microsecond-level timer is started and data packet completion events belonging to the same video frame are accumulated. During the waiting period, continuously check the tags of newly completed data packets. If a high-priority control tag appears, immediately terminate the waiting and generate an interrupt trigger command. If the timer times out or the accumulated data volume reaches the estimated frame size, an interrupt trigger instruction is generated and the waiting state is reset.
[0040] It should be noted that an interrupt request is intercepted by the interrupt preprocessing routine in the driver just before the USB controller hardware is about to generate an interrupt request signal. This routine first queries the packet semantic tags associated with this interrupt request, which are pre-stored in the driver's data structure. If the found tag is "video data block," the program control flow jumps to the aggregation wait processing branch designed specifically for batch data; if it is another tag (such as "high priority control"), the wait process is bypassed, and the standard interrupt reporting path continues directly. As the master switch for the entire dynamic decision-making process, the semantic tags are used for the initial routing of the data flow, achieving differentiation of the processing path.
[0041] Upon entering the aggregation wait branch, the driver immediately invokes the kernel's high-precision timer interface to request and start a timer measured in microseconds, while simultaneously initializing a dedicated counter and buffer located in kernel memory. Subsequently, the metadata (such as data pointer and length) of subsequent data packet completion events from the same USB endpoint and identified as belonging to the same logical video frame is temporarily stored in this buffer, and the counter increments, while hardware interrupt reporting is temporarily suppressed. By introducing a time-constrained wait window and event accumulation mechanism, multiple discrete data packet events that would otherwise immediately trigger multiple interrupts are temporarily stored and aggregated over time, creating conditions for batch processing.
[0042] During the microsecond-level timer operation, the driver does not idle but continuously polls or checks for newly completed data packet transactions from the same USB controller via a callback mechanism. For each newly completed transaction, the driver immediately obtains its data packet semantic tag. Once any new data packet is detected with the tag "high-priority control," the timer is immediately canceled, the accumulated video event buffer is cleared, and an interrupt trigger request is immediately submitted to the operating system kernel, regardless of whether the current timer has expired or how much video data has accumulated. While pursuing throughput (aggregation), a high-priority preemptive response mechanism is implemented to ensure that the low-latency critical control flow is not blocked by batch data streams, thus guaranteeing the system's real-time performance.
[0043] The aggregation wait process terminates under two conditions: first, a preset microsecond-level timer expires; second, the total size of accumulated data packets reaches a frame size threshold estimated based on the video streaming protocol or historical data. When either condition is met, the wait process ends. The driver then processes all video data packet events accumulated during this aggregation wait as a batch, submitting an interrupt trigger command to the kernel. Subsequently, the driver resets the timer, clears the event counter, and the buffer, restoring the entire aggregation wait state machine to its initial ready state to prepare for processing the next batch of data. This defines the termination boundary of the aggregation, providing a deterministic and predictable balance between "waiting longer to aggregate more data (increasing throughput)" and "delivering promptly to reduce processing latency (reducing latency)."
[0044] Specifically, based on semantic tags and system load, the triggered interrupts are dynamically bound to the anchor core or other CPU cores and associated with the corresponding network queues. The specific steps are as follows: Receive interrupt trigger commands and associated data stream semantic tags; Read the current interrupt count and CPU utilization of the anchor core to determine whether they exceed the light load threshold; If the semantic tag is a high-priority control tag, or the anchor core is in a light-load state, then the affinity of this interruption is set to the anchor core. Set the flow routing policy of the network receive queue associated with the USB endpoint where the interrupt occurred to point to the same anchor core to complete the path binding.
[0045] It should be noted that when the interrupt decision logic generates an interrupt trigger instruction, this instruction is passed to the bound execution module as a data structure. This data structure not only contains the hardware event identifier that triggered the interrupt, but also necessarily includes the corresponding data stream semantic tag (such as "high priority control" or "video data block"), which was determined and stored in the previous semantic analysis phase. The bound execution module first parses this received data structure, establishing a solid association between the interrupt trigger event and its semantic tag, preparing complete input information for subsequent differentiated scheduling. This ensures that subsequent binding decisions are not blind, but possess a clear business type awareness capability, laying the information foundation for dynamic scheduling.
[0046] After acquiring the semantic tags, the binding execution module immediately queries two key real-time metrics of the pre-selected "anchor core" by reading a specific status file exposed by the operating system kernel: the number of interrupt requests processed by the core in the most recent statistical period and its current CPU utilization percentage. The module has a pre-defined "light load threshold" parameter, which is typically an empirical value. The system compares the read CPU utilization value with this threshold; if the utilization is below the threshold, the anchor core is determined to be in a "light load state"; otherwise, it is determined to be under high load. This introduction of awareness of the target core's real-time load status allows binding decisions to respond to dynamic changes in system load, avoiding mechanically adding load when the core is already busy, thus demonstrating scheduling flexibility.
[0047] Based on the information obtained in the first two steps (semantic tags and anchor core load status), the binding execution module applies a simple decision rule: as long as the data flow is marked as "high-priority control," or the anchor core is currently determined to be in a "lightly loaded state," then regardless of the other condition, it makes the decision to bind the current interrupt to the anchor core. After the decision, the module completes the affinity binding of the hardware interrupt request to the specific CPU core by writing a bitmask representing the anchor core to the operating system or a similar interface file. This implements policy-based conditional binding, prioritizing the service quality of high-real-time services, making full use of high-performance cores when system resources are idle, and reserving decision space for possible subsequent load distribution when the core load is high (neither lightly loaded nor high-priority).
[0048] To establish a complete same-core processing path, after configuring hardware interrupt affinity, it's necessary to further ensure that the corresponding network packets are also processed by the same core during the protocol stack processing stage. The binding execution module locates the associated Linux network device receive queue based on the USB endpoint number corresponding to the interrupt source. Then, by writing the same CPU bitmask as the anchor core into the flow routing configuration file of this receive queue, subsequent network soft interrupts and protocol stack processing tasks are also directed to the anchor core. This expands interrupt binding from a single hardware event response to a collaborative binding across the entire data processing chain of "hard interrupt-soft interrupt-protocol stack," minimizing cross-core data migration and context switching, and achieving end-to-end performance optimization.
[0049] Specifically, regarding the interrupt load of the monitoring anchor core, when the load exceeds a threshold, the specified data stream will be switched from interrupt mode to controlled polling mode for processing. The specific steps are as follows: On the anchor core, frequency statistics are performed on the interruption of the specific video data stream bound to the core, the number of interruptions I per unit time is calculated, and the CPU utilization U of the current anchor core and the processing time sample of the most recent N interruptions of the data stream are collected simultaneously. The interrupt processing latency fluctuation coefficient W is calculated based on the interrupt processing time sample. The number of interrupts I, CPU utilization U and fluctuation coefficient W are substituted into the state evaluation function F for calculation. The expression of the state evaluation function F is: F = (I×(1+W)) / U. When the function value F exceeds the preset system stability threshold S, it is determined that the data stream has entered a high throughput and unstable state. Send a command to the USB controller to disable the interrupt reporting function of the endpoint corresponding to this data stream; A dedicated kernel thread is started and bound to the anchor core to poll the data completion status of the endpoint at fixed microsecond intervals and process it.
[0050] It should be noted that, on the anchor core, frequency statistics are performed on interrupts of specific video data streams bound to that core, calculating the number of interrupts I per unit time, and simultaneously collecting the CPU utilization U of the current anchor core and the processing time samples of the most recent N interrupts of that data stream. The specific operation is executed periodically by a monitoring thread in the kernel. This thread first reads the anchor core's statistics file, filters and accumulates the trigger count of a specified USB interrupt number in the previous sampling period to obtain the interrupt frequency I. Simultaneously, it reads the system file to obtain the instantaneous CPU utilization U of the core, and extracts the processing time of the most recent N interrupts of that data stream from trigger to completion from the driver's internal performance counters, forming a sample set. This establishes a multi-dimensional real-time monitoring data acquisition mechanism, providing an accurate raw data foundation for objectively evaluating the system's processing load and stability.
[0051] The interrupt processing latency fluctuation coefficient W is calculated based on the interrupt processing time samples. The number of interrupts I, CPU utilization U, and fluctuation coefficient W are then substituted into the state evaluation function F for calculation. The expression for the state evaluation function F is: F = (I × (1 + W)) / U. When the function value F exceeds a preset system stability threshold S, the data stream is determined to enter a high-throughput and unstable state. The monitoring thread performs statistical analysis on the collected N interrupt processing time samples, calculating the ratio of its standard deviation to its mean, which is used as the latency fluctuation coefficient W. This coefficient quantifies the degree of processing latency jitter. Subsequently, the three parameters I, U, and W are substituted into the formula F = (I × (1 + W)) / U for comprehensive calculation. This formula is designed so that high interrupt frequency (I) and large latency jitter (W) will both increase the F value, while high CPU utilization (U) acts as the denominator to suppress the F value. Finally, the calculated F value is compared with a system stability threshold S pre-calibrated through experiments. By using a comprehensive mathematical model that integrates multiple factors such as frequency, load, and jitter, a quantitative diagnosis of "interruption storms" and their negative impacts is achieved, which is more accurate and robust than a single interruption frequency threshold.
[0052] A command is sent to the USB controller to disable interrupt reporting for the endpoint corresponding to the data stream. Once a mode switch is determined to be necessary, the mode switching logic in the driver constructs a specific xHCI command descriptor designed to modify the event notification settings of the target USB endpoint. This command descriptor is then submitted to the command ring of the USB host controller (xHCI) via memory-mapped I / O or port I / O. After the controller executes the command, it stops generating hardware interrupt signals for the transmission completion event of the specified endpoint. Actively cutting off the source of high-frequency interrupts at the hardware level is a crucial pre-operation for mode switching, creating the necessary conditions for subsequent switching to polling mode and completely eliminating the inherent overhead of interrupt context switching.
[0053] The driver dynamically creates a high-priority kernel thread and immediately forces CPU affinity to the anchor core. This thread is programmed as a compact loop. In each loop, it first performs a fixed microsecond delay using a high-precision timer, then directly reads the status register or completion event loop of the corresponding endpoint on the USB controller to check for new data arrival. Once data is detected, it directly calls the data processing function that would normally be executed by the interrupt handler. This controlled, periodic active polling replaces passive, random interrupt responses, achieving deterministic, low-overhead processing of the data stream under extremely high loads and ensuring system throughput and response stability in extreme cases.
[0054] Specifically, the process of collecting and processing performance metrics, and adjusting the interrupt triggering strategy and mode switching conditions based on metric feedback, involves the following steps: Continuously measure and record the total latency of data packets with high-priority control tags from interrupt triggering to being read by the user layer; The total latency is compared with the target latency threshold. If the average latency exceeds the threshold, an instruction to tighten the aggregation strategy is generated. The instructions to tighten the aggregation strategy are translated into parameter adjustment actions, including shortening the aggregation wait timer duration; The adjusted parameters are updated into the decision logic and switching judgment logic to form a closed-loop control.
[0055] It should be noted that high-precision timestamp recording points are embedded in the interrupt handling entry point of the driver layer and the user-mode socket read function, respectively. When a data packet marked as "high-priority control" triggers an interrupt, the first timestamp is recorded immediately; when the application layer successfully reads this data packet through system calls such as recv, the second timestamp is recorded. The difference between the two timestamps is the end-to-end latency of a single processing operation. The system maintains a fixed-length queue to continuously record and save these latency samples. This achieves accurate and continuous quantitative monitoring of the core performance indicator—the latency of high-priority services—providing objective and direct data for evaluating the actual effect of the current scheduling strategy, replacing the previous rough judgment based solely on experience or a single load indicator.
[0056] The system periodically (e.g., every 100 milliseconds) calculates the moving average of latency samples of high-priority data packets collected over a recent period. This average is compared to a preset target latency threshold determined based on service quality requirements. If the calculated average latency remains above this threshold for several consecutive periods, it is determined that the current system's service quality for high-priority services has deteriorated. At this point, the feedback control logic generates a clear decision instruction to "tighten the aggregation strategy." Transforming vague performance perceptions into clear, threshold-based logical judgments enables automatic triggering from performance monitoring to strategy adjustment decisions, serving as the "brain" decision-making link in closed-loop control.
[0057] The received "tighten aggregation strategy" instruction is passed to a parameter mapper. This mapper predefines the correspondence between different adjustment instructions and specific adjustable drive parameters. For the "tighten aggregation" instruction, the core mapping action is to reduce the timeout setting of the microsecond-level timer used in the "aggregation waiting process" of the video data stream. For example, the original waiting time parameter is reduced from 100 microseconds to 70 microseconds. This translates the upper-level, abstract strategy instructions into specific parameter modification operations that the lower-level driver can recognize and execute, completing the command transformation from decision to execution and ensuring that strategy adjustments are effectively implemented.
[0058] After the parameter mapper generates new timer timeout parameters, it updates the global configuration variables used by the interrupt decision module (responsible for aggregation waiting) through thread-safe write operations. Simultaneously, the mode switching judgment logic associated with this parameter (such as relevant thresholds in the state evaluation function) may also be fine-tuned. Afterward, all newly arriving data streams will immediately be scheduled with the updated parameters applied. This completes the full feedback loop of "monitoring (latency) -> decision (threshold exceeding) -> execution (parameter tuning) -> effectiveness (system update)," enabling the system to dynamically optimize itself based on actual business performance, ensuring the continuous adaptability and long-term effectiveness of the tuning strategy.
[0059] This embodiment also provides a USB network card performance tuning system based on interrupt binding, including: The core management module identifies the system's high-performance CPU core as the anchor core and disables automatic load balancing for interrupts. The stream identification module performs real-time analysis of incoming data packets at the USB driver layer and assigns semantic tags to the data packets based on preset rules. The interruption decision module dynamically determines the interruption triggering strategy based on semantic tags, aggregates and waits for the video data stream, and immediately triggers an interruption when a high-priority data packet is identified. The binding execution module dynamically binds triggered interrupts to anchor cores or other CPU cores based on semantic tags and system load, and associates them with corresponding network queues; The mode switching module monitors the interrupt load of the anchor core. When the load exceeds the threshold, it switches the specified data stream from interrupt mode to controlled polling mode for processing. The optimization module collects performance metrics during the processing and adjusts the interrupt triggering strategy and mode switching conditions based on the metric feedback.
[0060] This embodiment also provides a computer device applicable to the interrupt-binding-based USB network card performance tuning method, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the interrupt-binding-based USB network card performance tuning method proposed in the above embodiment.
[0061] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0062] This embodiment also provides a storage medium storing a computer program. When executed by a processor, the program implements the interrupt-binding-based USB network card performance tuning method proposed in the above embodiments. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0063] In summary, this invention achieves systematic optimization of the USB network card interrupt handling process by introducing a data flow semantic awareness and dynamic intelligent scheduling mechanism. It can intelligently distinguish between high-priority control flow and batch data flow at the driver layer, and dynamically decide on interrupt aggregation strategies and triggering timing based on these semantic tags, thereby reducing interrupt frequency while ensuring low-latency response for critical services. By treating interrupt binding, queue association, and processing mode (interrupt / polling) as linked resource scheduling units that can be dynamically adjusted according to system load, it effectively suppresses interrupt storms and reduces unnecessary cross-core migration and cache invalidation overhead. Finally, this method constructs a tuning system with closed-loop self-optimization capabilities, enabling the USB network card to maintain stable low latency and low CPU usage under high throughput loads, improving the determinism and energy efficiency of the overall system I / O performance.
[0064] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for performance tuning of a USB network card based on interrupt binding, characterized in that, Includes the following steps: Identify the high-performance CPU core of the system as the anchor core and disable automatic load balancing for interrupts; The incoming data packets are analyzed in real time at the USB driver layer, and semantic tags are assigned to the data packets based on preset rules; Based on the semantic tag dynamic decision-making interruption triggering strategy, the video data stream is aggregated and waited, and an interruption is triggered immediately when a high-priority data packet is identified; Based on semantic tags and system load, the triggered interrupts are dynamically bound to the anchor core or other CPU cores and associated with the corresponding network queues; Monitor the interrupt load of the anchor core, and when the load exceeds the threshold, switch the specified data stream from interrupt mode to controlled polling mode for processing; Collect performance metrics during the processing and adjust the interrupt triggering strategy and mode switching conditions based on the metric feedback.
2. The USB network card performance tuning method based on interrupt binding as described in claim 1, characterized in that: The specific steps for determining the high-performance CPU core of the system as the anchor core and disabling automatic load balancing of interrupts are as follows: Read the system CPU topology information and identify the numbers of all high-performance cores; Query the status of the system interrupted load balancing service; if the service is running, send a stop command to it. From the identified high-performance core numbers, select the core with the lowest current system load and record its number as the anchor core identifier; The anchor core identifier is passed to the interrupt affinity setting interface as the default target for subsequent interrupt binding.
3. The USB network card performance tuning method based on interrupt binding as described in claim 2, characterized in that: The steps for performing real-time analysis of incoming data packets at the USB driver layer and assigning semantic tags to the data packets based on preset rules are as follows: On the path of receiving data packets in the USB network driver, the length, arrival time interval, and corresponding USB endpoint address information of each data packet are intercepted; A temporary analysis window is formed by combining consecutively arriving data packets, and the length distribution and interval pattern of the data packets within the window are calculated. The length distribution and interval pattern are matched with predefined flow feature templates in the rule base, the templates including high-frequency small packet templates and burst large packet templates; Based on the matching results, corresponding semantic tags are assigned to the current analysis window and subsequent data packets from the same source. These tags include high-priority control tags and video data block tags.
4. The USB network card performance tuning method based on interrupt binding as described in claim 3, characterized in that: The triggering strategy for dynamic decision-making based on semantic tags involves aggregating and waiting the video data stream, and immediately triggering an interruption upon identification of a high-priority data packet. The specific steps are as follows: Check the semantic tags carried by the data packets currently awaiting processing. If they are video data block tags, proceed to the aggregation waiting process. During the aggregation waiting process, a microsecond-level timer is started and data packet completion events belonging to the same video frame are accumulated. During the waiting period, continuously check the tags of newly completed data packets. If a high-priority control tag appears, immediately terminate the waiting and generate an interrupt trigger command. If the timer times out or the accumulated data volume reaches the estimated frame size, an interrupt trigger instruction is generated and the waiting state is reset.
5. The USB network card performance tuning method based on interrupt binding as described in claim 4, characterized in that: Based on semantic tags and system load, the triggered interrupts are dynamically bound to the anchor core or other CPU cores and associated with the corresponding network queues. The specific steps are as follows: Receive interrupt trigger commands and associated data stream semantic tags; Read the current interrupt count and CPU utilization of the anchor core to determine whether they exceed the light load threshold; If the semantic tag is a high-priority control tag, or the anchor core is in a light-load state, then the affinity of this interruption is set to the anchor core. Set the flow routing policy of the network receive queue associated with the USB endpoint where the interrupt occurred to point to the same anchor core to complete the path binding.
6. The USB network card performance tuning method based on interrupt binding as described in claim 5, characterized in that: The monitoring anchor core's interrupt load, when the load exceeds a threshold, will switch the specified data stream from interrupt mode to controlled polling mode for processing. The specific steps are as follows: On the anchor core, frequency statistics are performed on the interruption of the specific video data stream bound to the core, the number of interruptions I per unit time is calculated, and the CPU utilization U of the current anchor core and the processing time sample of the most recent N interruptions of the data stream are collected simultaneously. The interrupt processing latency fluctuation coefficient W is calculated based on the interrupt processing time sample. The interrupt number I, CPU utilization U and fluctuation coefficient W are substituted into the state evaluation function F for calculation. The expression of the state evaluation function F is: F = (I ×(1 + W)) / U. When the function value F exceeds the preset system stability threshold S, it is determined that the data stream has entered a high throughput and unstable state. Send a command to the USB controller to disable the interrupt reporting function of the endpoint corresponding to this data stream; A dedicated kernel thread is started and bound to the anchor core to poll the data completion status of the endpoint at fixed microsecond intervals and process it.
7. The USB network card performance tuning method based on interrupt binding as described in claim 6, characterized in that: The specific steps for collecting and processing performance metrics and adjusting interrupt triggering strategies and mode switching conditions based on metric feedback are as follows: Continuously measure and record the total latency of data packets with high-priority control tags from interrupt triggering to being read by the user layer; The total latency is compared with the target latency threshold. If the average latency exceeds the threshold, an instruction to tighten the aggregation strategy is generated. The instructions to tighten the aggregation strategy are translated into parameter adjustment actions, including shortening the aggregation wait timer duration; The adjusted parameters are updated into the decision logic and switching judgment logic to form a closed-loop control.
8. A USB network card performance tuning system based on interrupt binding, based on the USB network card performance tuning method based on interrupt binding according to any one of claims 1 to 7, characterized in that: include, The core management module identifies the system's high-performance CPU core as the anchor core and disables automatic load balancing for interrupts. The stream identification module performs real-time analysis of incoming data packets at the USB driver layer and assigns semantic tags to the data packets based on preset rules. The interruption decision module dynamically determines the interruption triggering strategy based on semantic tags, aggregates and waits for the video data stream, and immediately triggers an interruption when a high-priority data packet is identified. The binding execution module dynamically binds triggered interrupts to anchor cores or other CPU cores based on semantic tags and system load, and associates them with corresponding network queues; The mode switching module monitors the interrupt load of the anchor core. When the load exceeds the threshold, it switches the specified data stream from interrupt mode to controlled polling mode for processing. The optimization module collects performance metrics during the processing and adjusts the interrupt triggering strategy and mode switching conditions based on the metric feedback.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the interrupt-binding-based USB network card performance tuning method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the interrupt-binding-based USB network card performance tuning method according to any one of claims 1 to 7.