From 2728a2b35da348c3d604522bdc130e444e9691cf Mon Sep 17 00:00:00 2001 From: KalepuAMD Date: Thu, 9 Jan 2025 13:45:53 +0000 Subject: [PATCH] ON-10531: Make sfcaffinity_config script pin the ptp interrupt --- scripts/sfcaffinity_config | 52 ++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/scripts/sfcaffinity_config b/scripts/sfcaffinity_config index 20510cc17..77632f522 100755 --- a/scripts/sfcaffinity_config +++ b/scripts/sfcaffinity_config @@ -467,10 +467,9 @@ def rxq_get_irq(ethx, rxq): def rxq_set_affinity(ethx, rxq, cpumask): assert type(ethx) is EthInterface - assert isint(rxq) assert isint(cpumask) irq = rxq_get_irq(ethx, rxq) - info("%s: bind rxq %d (irq %d) to core %s" % \ + info("%s: bind rxq %s (irq %d) to core %s" % \ (ethx, rxq, irq, mask.to_comma_sep_list(cpumask))); affinity.irq_set_affinity(irq, cpumask) return @@ -538,34 +537,67 @@ def rxq_check_affinity(ethx, rxq): def rxq_show(ethx, rxq): - irq = rxq_get_irq(ethx, rxq) + try: + irq = rxq_get_irq(ethx, rxq) + except: + return None irq_m = irq_get_cpumask(irq) irq_cscm = mask.int_to_comma_sep_hex(irq_m, minlen=True) irq_pid = affinity.irq_get_pid(irq) if irq_pid > 0: irq_pid_m = pid_get_cpumask(irq_pid) irq_pid_cscm = mask.int_to_comma_sep_hex(irq_pid_m, minlen=True) - out("%s rxq%d irq=%d irqaffinity=%s pid=%d pidaffinity=%s" % + out("%s rxq%s irq=%d irqaffinity=%s pid=%d pidaffinity=%s" % (ethx, rxq, irq, irq_cscm, irq_pid, irq_pid_cscm)) else: - out("%s rxq%d irq=%d irqaffinity=%s" % + out("%s rxq%s irq=%d irqaffinity=%s" % (ethx, rxq, irq, irq_cscm)) def interface_bind_rxqs(ethx, q_to_cpu): assert type(q_to_cpu) is list + used_cpus = [] for (rxq, cpu) in enumerate(q_to_cpu): if rxq >= ethx.n_rxqs(): break rxq_set_affinity(ethx, rxq, 1 << cpu) + used_cpus.append(cpu) + try: + if global_options.ptp == "use": + core_ids = numa_core_ids(ethx, q_to_cpu) + # find the remaining cores left and pin the PTP interrupt to the next availble core + # check if the core is already used or not + if global_options.cores is not None: + cores_mask = affinity.mask.to_int(global_options.cores) + cores_list = affinity.mask.to_int_list(cores_mask) + # # In topology file, the script changes the given cores list from cores option + remaining_ids = [x for x in cores_list if x not in used_cpus] + else: + # check if any cores left in the all cores available in the system. + remaining_ids = [x for x in core_ids if x not in used_cpus] + #if there are no cores left then pin the PTP core to the rxq0 core + if len(remaining_ids)==0: + irq = rxq_get_irq(ethx, 0) + irq_m = irq_get_cpumask(irq) + ptp_core_m = irq_m + else: + ptp_core_m = 1<