Created
April 24, 2025 07:45
-
-
Save foamdino/4f241447c51ba9c2d707bdc49bedd951 to your computer and use it in GitHub Desktop.
split affinity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Assign the packet parsing threads to the top half of the CPUs supplied in the | |
| * config. The bottom half of the CPUs will be used for the channel threads. | |
| * | |
| * @param teb Pointer to our TEB. | |
| * | |
| * @retval BL_OK. | |
| */ | |
| __BL_STATIC int | |
| drone_sysmgr_aff_core_split(bl_teb_t *teb) | |
| { | |
| if (DRONE_CTX.num_desired_channels > 1) | |
| DRONE_CTX.num_desired_channels /= 2; | |
| if (DRONE_CTX.num_desired_irq_cores > 1) | |
| DRONE_CTX.num_desired_irq_cores /= 2; | |
| bl_assert(DRONE_CTX.num_desired_channels | |
| <= bl_arraysz(DRONE_CTX.aff_packet_cores)); | |
| bl_assert(DRONE_CTX.num_desired_channels | |
| <= bl_arraysz(GlobalDroneConfig.channel_affinities)); | |
| bl_assert(DRONE_CTX.num_desired_irq_cores <= bl_arraysz(DRONE_CTX.aff_irq_cores)); | |
| bl_assert(DRONE_CTX.num_desired_irq_cores | |
| <= bl_arraysz(GlobalDroneConfig.irq_affinities)); | |
| /* Assign the packet threads to the upper half of the cores. | |
| * Offset the CPU index by the number of channels as the lower half will | |
| * be used for the XDP program. */ | |
| for (int aff = 0; aff < DRONE_CTX.num_desired_channels; aff++) | |
| { | |
| DRONE_CTX.aff_packet_cores[aff] = | |
| GlobalDroneConfig | |
| .channel_affinities[aff + DRONE_CTX.num_desired_channels]; | |
| /* | |
| Assign lower half of cores to IRQ handling | |
| ie. do not offset by the number of channels | |
| */ | |
| DRONE_CTX.aff_irq_cores[aff] = GlobalDroneConfig.irq_affinities[aff]; | |
| } | |
| /* Turn on the cores affinity flag for the drone. */ | |
| DRONE_CTX.aff_packet_flags = BL_EX_AFF_CORES; | |
| return BL_OK; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment