From: Jan Beulich <jbeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wl@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [Xen-devel] [PATCH 3/3] x86: add accessors for scratch cpu mask
Date: Thu, 13 Feb 2020 11:12:12 +0100 [thread overview]
Message-ID: <9fc88888-a670-a68e-f1b6-c0d258ab7b6e@suse.com> (raw)
In-Reply-To: <20200212164949.56434-4-roger.pau@citrix.com>
On 12.02.2020 17:49, Roger Pau Monne wrote:
> @@ -223,7 +223,10 @@ static void _clear_irq_vector(struct irq_desc *desc)
> trace_irq_mask(TRC_HW_IRQ_CLEAR_VECTOR, irq, vector, tmp_mask);
>
> if ( likely(!desc->arch.move_in_progress) )
> + {
> + put_scratch_cpumask();
> return;
> + }
I'm not overly happy to see a need introduced to do cleanup like
this one, but at least missing a path is a debug-build problem
only.
> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -57,6 +57,30 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_mask);
> DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, scratch_cpumask);
> static cpumask_t scratch_cpu0mask;
>
> +#ifndef NDEBUG
> +cpumask_t *scratch_cpumask(const char *fn)
Please don't pass an argument that you can deduce, and then
provide even more meaningful data:
> +{
> + static DEFINE_PER_CPU(const char *, scratch_cpumask_use);
> +
> + /*
> + * Scratch cpumask cannot be used in IRQ context, or else we would have to
> + * make sure all users have interrupts disabled while using the scratch
> + * mask.
> + */
> + BUG_ON(in_irq());
> +
> + if ( fn && unlikely(this_cpu(scratch_cpumask_use)) )
> + {
> + printk("%s: scratch CPU mask already in use by %s\n",
> + fn, this_cpu(scratch_cpumask_use));
Use __builtin_return_address(0) here, which will allow
identifying which of perhaps multiple uses in a function is
the offending one.
Also, why in smpboot.c instead of in smp.c? This isn't a
boot or CPU-hot-online related function afaict.
Finally, it would seem nice if multiple uses by the same caller
could be permitted:
for ( ... )
{
if ( ... )
{
mask = get_scratch_cpumask();
...
}
else
{
/* no use of get_scratch_cpumask() */
...
}
}
put_scratch_cpumask();
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-02-13 10:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 16:49 [Xen-devel] [PATCH 0/3] x86: fixes/improvements for scratch cpumask Roger Pau Monne
2020-02-12 16:49 ` [Xen-devel] [PATCH 1/3] x86/smp: unify header includes in smp.h Roger Pau Monne
2020-02-12 23:05 ` Wei Liu
2020-02-13 9:54 ` Jan Beulich
2020-02-12 16:49 ` [Xen-devel] [PATCH 2/3] x86/smp: use a dedicated scratch cpumask in send_IPI_mask Roger Pau Monne
2020-02-13 9:59 ` Jan Beulich
2020-02-13 10:03 ` Roger Pau Monné
2020-02-13 10:19 ` Jan Beulich
2020-02-13 11:41 ` Roger Pau Monné
2020-02-13 13:35 ` Jan Beulich
2020-02-12 16:49 ` [Xen-devel] [PATCH 3/3] x86: add accessors for scratch cpu mask Roger Pau Monne
2020-02-13 10:12 ` Jan Beulich [this message]
2020-02-13 15:15 ` Roger Pau Monné
2020-02-13 15:43 ` Jan Beulich
2020-02-12 16:53 ` [Xen-devel] [PATCH 0/3] x86: fixes/improvements for scratch cpumask Sander Eikelenboom
2020-02-12 17:01 ` Roger Pau Monné
2020-02-12 17:13 ` Sander Eikelenboom
2020-02-13 9:31 ` Sander Eikelenboom
2020-02-12 21:05 ` Julien Grall
2020-02-13 9:53 ` Jan Beulich
2020-02-13 10:05 ` Roger Pau Monné
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=9fc88888-a670-a68e-f1b6-c0d258ab7b6e@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).