[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 6/7] x86/irq: handle moving interrupts in _assign_irq_vector()
On 10.06.2024 16:20, Roger Pau Monne wrote: > Currently there's logic in fixup_irqs() that attempts to prevent > _assign_irq_vector() from failing, as fixup_irqs() is required to evacuate all > interrupts from the CPUs not present in the input mask. The current logic in > fixup_irqs() is incomplete, as it doesn't deal with interrupts that have > move_cleanup_count > 0 and a non-empty ->arch.old_cpu_mask field. > > Instead of attempting to fixup the interrupt descriptor in fixup_irqs() so > that > _assign_irq_vector() cannot fail, introduce logic in _assign_irq_vector() > to deal with interrupts that have either move_{in_progress,cleanup_count} set > and no remaining online CPUs in ->arch.cpu_mask. > > If _assign_irq_vector() is requested to move an interrupt in the state > described above, first attempt to see if ->arch.old_cpu_mask contains any > valid > CPUs that could be used as fallback, and if that's the case do move the > interrupt back to the previous destination. Note this is easier because the > vector hasn't been released yet, so there's no need to allocate and setup a > new > vector on the destination. > > Due to the logic in fixup_irqs() that clears offline CPUs from > ->arch.old_cpu_mask (and releases the old vector if the mask becomes empty) it > shouldn't be possible to get into _assign_irq_vector() with > ->arch.move_{in_progress,cleanup_count} set but no online CPUs in > ->arch.old_cpu_mask. > > However if ->arch.move_{in_progress,cleanup_count} is set and the interrupt > has > also changed affinity, it's possible the members of ->arch.old_cpu_mask are no > longer part of the affinity set, I'm having trouble relating this (->arch.old_cpu_mask related) to ... > move the interrupt to a different CPU part of > the provided mask ... this (->arch.cpu_mask related). > and keep the current ->arch.old_{cpu_mask,vector} for the > pending interrupt movement to be completed. Right, that's to clean up state from before the initial move. What isn't clear to me is what's to happen with the state of the intermediate placement. Description and code changes leave me with the impression that it's okay to simply abandon, without any cleanup, yet I can't quite figure why that would be an okay thing to do. > --- a/xen/arch/x86/irq.c > +++ b/xen/arch/x86/irq.c > @@ -544,7 +544,53 @@ static int _assign_irq_vector(struct irq_desc *desc, > const cpumask_t *mask) > } > > if ( desc->arch.move_in_progress || desc->arch.move_cleanup_count ) > - return -EAGAIN; > + { > + /* > + * If the current destination is online refuse to shuffle. Retry > after > + * the in-progress movement has finished. > + */ > + if ( cpumask_intersects(desc->arch.cpu_mask, &cpu_online_map) ) > + return -EAGAIN; > + > + /* > + * Due to the logic in fixup_irqs() that clears offlined CPUs from > + * ->arch.old_cpu_mask it shouldn't be possible to get here with > + * ->arch.move_{in_progress,cleanup_count} set and no online CPUs in > + * ->arch.old_cpu_mask. > + */ > + ASSERT(valid_irq_vector(desc->arch.old_vector)); > + ASSERT(cpumask_intersects(desc->arch.old_cpu_mask, &cpu_online_map)); > + > + if ( cpumask_intersects(desc->arch.old_cpu_mask, mask) ) > + { > + /* > + * Fallback to the old destination if moving is in progress and > the > + * current destination is to be offlined. This is only possible > if > + * the CPUs in old_cpu_mask intersect with the affinity mask > passed > + * in the 'mask' parameter. > + */ > + desc->arch.vector = desc->arch.old_vector; > + cpumask_and(desc->arch.cpu_mask, desc->arch.old_cpu_mask, mask); > + > + /* Undo any possibly done cleanup. */ > + for_each_cpu(cpu, desc->arch.cpu_mask) > + per_cpu(vector_irq, cpu)[desc->arch.vector] = irq; > + > + /* Cancel the pending move. */ > + desc->arch.old_vector = IRQ_VECTOR_UNASSIGNED; > + cpumask_clear(desc->arch.old_cpu_mask); > + desc->arch.move_in_progress = 0; > + desc->arch.move_cleanup_count = 0; > + > + return 0; > + } In how far is this guaranteed to respect the (new) affinity that was set, presumably having led to the movement in the first place? > @@ -600,7 +646,17 @@ next: > current_vector = vector; > current_offset = offset; > > - if ( valid_irq_vector(old_vector) ) > + if ( desc->arch.move_in_progress || desc->arch.move_cleanup_count ) > + { > + ASSERT(!cpumask_intersects(desc->arch.cpu_mask, > &cpu_online_map)); > + /* > + * Special case when evacuating an interrupt from a CPU to be > + * offlined and the interrupt was already in the process of being > + * moved. Leave ->arch.old_{vector,cpu_mask} as-is and just > + * replace ->arch.{cpu_mask,vector} with the new destination. > + */ And where's the cleaning up of ->arch.old_* going to be taken care of then? Jan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |