All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Davidwang <Davidwang@zhaoxin.com>
Cc: Juergen Gross <jgross@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	"Fiona Li(BJ-RD)" <FionaLi@zhaoxin.com>
Subject: Re: [PATCH v3] x86: Fix possible ASSERT(cpu < nr_cpu_ids)
Date: Thu, 19 Apr 2018 06:10:11 -0600	[thread overview]
Message-ID: <5AD8872302000078001BCA98@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <1524133246-3196-1-git-send-email-Davidwang@zhaoxin.com>

>>> On 19.04.18 at 12:20, <Davidwang@zhaoxin.com> wrote:
> From: David Wang <davidwang@zhaoxin.com>
> 
> CPUs may share an in-use channel. Hence clearing of a bit from
> the cpumask (in hpet_broadcast_exit()) as well as setting one
> (in hpet_broadcast_enter()) must not race evaluation of that same
> cpumask. Therefore avoid evaluating the cpumask twice in
> hpet_detach_channel(). Otherwise cpumask_empty() may e.g.return
> false while the subsequent cpumask_first() could return nr_cpu_ids,
> which then triggers the assertion in cpumask_of() reached through
> set_channel_irq_affinity().
> 
> Sign-off-by: David Wang <davidwang@zhaoxin.com>

Signed-off-by

> --- a/xen/arch/x86/hpet.c
> +++ b/xen/arch/x86/hpet.c
> @@ -509,15 +509,18 @@ static void hpet_attach_channel(unsigned int cpu,
>  static void hpet_detach_channel(unsigned int cpu,
>                                  struct hpet_event_channel *ch)
>  {
> +    unsigned int next;
> +
>      spin_lock_irq(&ch->lock);
>  
>      ASSERT(ch == per_cpu(cpu_bc_channel, cpu));
>  
>      per_cpu(cpu_bc_channel, cpu) = NULL;
> +    next = cpumask_first(ch->cpumask);
>  
>      if ( cpu != ch->cpu )
>          spin_unlock_irq(&ch->lock);
> -    else if ( cpumask_empty(ch->cpumask) )
> +    else if ( next == nr_cpu_ids )

This should be >= .

Also I'd prefer if the cpumask_first() was avoided in the cpu != ch->cpu
case.

With these
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(and the changes are easy enough to make while committing)

Also Cc Jürgen.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-04-19 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 10:20 [PATCH v3] x86: Fix possible ASSERT(cpu < nr_cpu_ids) Davidwang
2018-04-19 12:10 ` Jan Beulich [this message]
     [not found] ` <5AD8872302000078001BCA98@suse.com>
2018-04-19 13:24   ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5AD8872302000078001BCA98@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=Davidwang@zhaoxin.com \
    --cc=FionaLi@zhaoxin.com \
    --cc=jgross@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.