@@ -4489,6 +4489,126 @@ inputs:
4489
4489
4490
4490
Set the maximum value of hash table entries for thread/coroutine tracking sessions.
4491
4491
4492
+ # ## CPU Balancer {#inputs.ebpf.cpu_balancer}
4493
+
4494
+ **Tags**:
4495
+
4496
+ <mark>agent_restart</mark>
4497
+
4498
+ **FQCN**:
4499
+
4500
+ ` inputs.ebpf.cpu_balancer`
4501
+
4502
+
4503
+ **Default value**:
4504
+ ` ` ` yaml
4505
+ inputs:
4506
+ ebpf:
4507
+ cpu_balancer:
4508
+ - nic_name: ""
4509
+ ring_size: 4096
4510
+ nic_rx_cpus: []
4511
+ xdp_cpus: []
4512
+ mode: 0
4513
+ ` ` `
4514
+
4515
+ **Schema**:
4516
+ | Key | Value |
4517
+ | ---- | ---------------------------- |
4518
+ | Type | dict |
4519
+
4520
+ **Description**:
4521
+
4522
+ Through the combination of RSS and XDP technologies, network traffic can be distributed
4523
+ across different CPU cores to achieve more efficient network packet processing. The entire
4524
+ path from the network interface card (NIC) to final processing is as follows :
4525
+
4526
+ ` [NIC] --(interrupt)--> [RSS receive CPU] --(XDP CPUMAP)--> [Softirq CPU1, CPU2 ...]`
4527
+
4528
+ When the network interface card (NIC) receives a network packet, it triggers an interrupt
4529
+ signal. This is a hardware-level interrupt used to notify the system that a packet has arrived.
4530
+ Then, XDP CPUMAP is used to distribute the packet to other CPU cores for further processing.
4531
+ XDP CPUMAP is a mechanism that maps network packets from the receiving CPU and distributes them
4532
+ to multiple processing CPUs for more efficient soft interrupt handling.
4533
+ When the network interface receives encapsulated packets such as GRE, Double VLAN (QinQ), or VXLAN,
4534
+ which cannot be evenly distributed across CPUs using the network card's RSS (Receive Side Scaling),
4535
+ XDP CPUMAP can effectively alleviate this issue. We can use the `top` command to check the soft
4536
+ interrupt usage of each CPU and the `rxtxcpu` command to view the data collection counts for each CPU,
4537
+ helping to determine whether there is an imbalance in CPU data processing.
4538
+
4539
+ ` rxtxcpu` command:
4540
+ ```
4541
+ # rxtxcpu -d rx <nic-name >
4542
+ 110 packets captured on cpu0.
4543
+ 93 packets captured on cpu1.
4544
+ 112 packets captured on cpu2.
4545
+ 77 packets captured on cpu3.
4546
+ 853 packets captured on cpu4.
4547
+ 53 packets captured on cpu5.
4548
+ ...
4549
+ ```
4550
+ You can view the statistics of received packets for each CPU. If the count for a specific CPU is
4551
+ significantly higher than others, it indicates an imbalance in CPU processing.
4552
+
4553
+ Configuration Item:
4554
+ - nic_name: Network interface name. default value is ""
4555
+ - ring_size: Receive (RX) ring buffer size, default value is 4096
4556
+ - nic_rx_cpus: The list of CPUs that handle the network data received by the network interface
4557
+ card (NIC), triggered by a physical interrupt. Since the network interface card (NIC) contains
4558
+ multiple physical cores, and each physical core has multiple logical cores, we select the
4559
+ physical core on the NUMA node where the NIC is located. This can be done as follows:
4560
+
4561
+ ```
4562
+ # deepflow-ebpfctl nicinfo --interface=p1p1
4563
+ Device: p1p1
4564
+ Address: 0000:41:00.0
4565
+ Driver: i40e
4566
+ Rx-Channels: 64
4567
+ Tx-Channels: 64
4568
+ RX-Ring-Size: 512
4569
+ TX-Ring-Size: 512
4570
+ PROMISC: 0
4571
+ NumaNode: 1
4572
+
4573
+ # deepflow-ebpfctl cpu_layout show
4574
+ cores = [ 0, 1, 2, 3, 4, 5]
4575
+ sockets = [ 0, 1]
4576
+ #
4577
+ Socket 0 Socket 1
4578
+ ------------ ------------
4579
+ Core 0 [ 0, 12] [ 1, 13]
4580
+ Core 1 [ 2, 14] [ 3, 15]
4581
+ Core 2 [ 4, 16] [ 5, 17]
4582
+ Core 3 [ 6, 18] [ 7, 19]
4583
+ Core 4 [ 8, 20] [ 9, 21]
4584
+ Core 5 [ 10, 22] [ 11, 23]
4585
+ ```
4586
+ From the above information, we know that the NIC p1p1 is located on NUMA node 1. We need to
4587
+ select cores from Socket 1, for example: selecting Core 0, Core 1. From Core 0, we can choose
4588
+ logical cores 1 or 13, and from Core 1, we can choose logical cores 3 or 15. The configuration
4589
+ can be set as [13,15].
4590
+ Default value is []
4591
+ - xdp_cpus: XDP CPU distribution list, ensuring that the distributed CPUs do not overlap with nic_rx_cpus.
4592
+ Default value is []
4593
+ - mode: CPU Balance Mode, default value is 0.
4594
+
4595
+ Example:
4596
+ ```yaml
4597
+ inputs:
4598
+ ebpf:
4599
+ cpu_balancer:
4600
+ - nic_name: eth0
4601
+ ring_size: 4096
4602
+ nic_rx_cpus: [1,3]
4603
+ xdp_cpus: [5,7,9,11]
4604
+ mode: 0
4605
+ - nic_name: eth1
4606
+ ring_size: 4096
4607
+ nic_rx_cpus: [13,15]
4608
+ xdp_cpus: [17,18,19,21]
4609
+ mode: 0
4610
+ ```
4611
+
4492
4612
## Resources {#inputs.resources}
4493
4613
4494
4614
### Push Interval {#inputs.resources.push_interval}
0 commit comments