From mboxrd@z Thu Jan 1 00:00:00 1970 From: Keir Fraser Subject: Re: [PATCH 1/3] x86/HPET: obtain proper lock for changing IRQ affinity Date: Tue, 16 Oct 2012 22:49:49 +0100 Message-ID: References: <507DA35102000078000A1C26@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <507DA35102000078000A1C26@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel List-Id: xen-devel@lists.xenproject.org On 16/10/2012 17:11, "Jan Beulich" wrote: >>>> On 16.10.12 at 17:41, Keir Fraser wrote: >> On 16/10/2012 16:09, "Jan Beulich" wrote: >> >>> The IRQ descriptor lock should be held while adjusting the affinity of >>> any IRQ; the HPET channel lock isn't sufficient to protect namely >>> against races with moving the IRQ to a different CPU. >>> >>> Signed-off-by: Jan Beulich >> >> Would be more usual for the underscore-prefixed name to be the one that >> doesn't take locks? > > Will make the patch bigger, but I can certainly do that. I specifically > picked only a single underscore to distinguish this a little from the > "usual" case. It doesn't make the patch much bigger, and it would be preferable. > Jan > >>> --- a/xen/arch/x86/hpet.c >>> +++ b/xen/arch/x86/hpet.c >>> @@ -436,6 +436,16 @@ static struct hpet_event_channel *hpet_g >>> return ch; >>> } >>> >>> +static void _hpet_msi_set_affinity(const struct hpet_event_channel *ch) >>> +{ >>> + struct irq_desc *desc = irq_to_desc(ch->irq); >>> + >>> + ASSERT(!local_irq_is_enabled()); >>> + spin_lock(&desc->lock); >>> + hpet_msi_set_affinity(desc, cpumask_of(ch->cpu)); >>> + spin_unlock(&desc->lock); >>> +} >>> + >>> static void hpet_attach_channel(unsigned int cpu, >>> struct hpet_event_channel *ch) >>> { >>> @@ -450,7 +460,7 @@ static void hpet_attach_channel(unsigned >>> if ( ch->cpu != cpu ) >>> return; >>> >>> - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); >>> + _hpet_msi_set_affinity(ch); >>> } >>> >>> static void hpet_detach_channel(unsigned int cpu, >>> @@ -472,7 +482,7 @@ static void hpet_detach_channel(unsigned >>> } >>> >>> ch->cpu = cpumask_first(ch->cpumask); >>> - hpet_msi_set_affinity(irq_to_desc(ch->irq), cpumask_of(ch->cpu)); >>> + _hpet_msi_set_affinity(ch); >>> } >>> >>> #include >>> >>> >>> >>> _______________________________________________ >>> Xen-devel mailing list >>> Xen-devel@lists.xen.org >>> http://lists.xen.org/xen-devel > > >