I believe we do need to take affinity into consideration even if the
chance that it is non-default is small.
I am not opposed to having bind_last_selected_cpu percpu, I just wanted
to understand the reason better. Additional locking would be a downside
with a global so if you feel that percpu is worth it then I won't object.
Yes, you are correct. .irq_set_affinity pretty much does the same thing.(BTW, I just noticed --- you don't need to initialize desc)
The code will now looks like this.
raw_spin_lock_irqsave(lock, flags);
percpu read
select_cpu
percpu write
xen_rebind_evtchn_to_cpu(evtchn, selected_cpu)
raw_spin_unlock_irqsave(lock, flags);