linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Yongxin Liu <yongxin.liu@windriver.com>
Cc: tglx@linutronix.de, evgreen@chromium.org, rajatja@google.com,
	bhelgaas@google.com, stable@vger.kernel.org,
	linux-pci@vger.kernel.org, x86@kernel.org, maz@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/apic/msi: check interupt context before reporting warning
Date: Tue, 13 Jul 2021 08:59:55 +0200	[thread overview]
Message-ID: <YO056/qui/vCvCcV@kroah.com> (raw)
In-Reply-To: <20210713064609.25429-1-yongxin.liu@windriver.com>

On Tue, Jul 13, 2021 at 02:46:09PM +0800, Yongxin Liu wrote:
> Affinity change can happen in both interrupt context and non-interrupt
> context. The paranoia check for interrupt target cpu is not always true
> in non-interrupt context.
> 
> For example:
>   Set affinity for irq to CPU#7
>   $ echo 80 > /proc/irq/default_smp_affinity
> 
>   Open serial port on different CPU.
>   $taskset -c 4 agetty -L 115200 ttyS1
> 
> Will triger the following warning.
> 
>   WARNING: CPU: 4 PID: 765 at arch/x86/kernel/apic/msi.c:75 msi_set_affinity+0x16f/0x190
>   Call Trace:
>    irq_do_set_affinity+0x57/0x1b0
>    irq_setup_affinity+0x136/0x190
>    irq_startup+0xaf/0xf0
>    __setup_irq+0x745/0x7e0
>    ? kmem_cache_alloc_trace+0x2b5/0x450
>    request_threaded_irq+0x110/0x180
>    univ8250_setup_irq+0x1e2/0x220
>    serial8250_do_startup+0x481/0x760
>    serial8250_startup+0x1e/0x20
>    uart_startup.part.22+0xf8/0x260
>    uart_port_activate+0x41/0x60
>    tty_port_open+0x82/0xd0
>    ? _raw_spin_unlock+0x16/0x30
>    uart_open+0x1e/0x30
>    tty_open+0x100/0x4d0
>    ? cdev_purge+0x60/0x60
>    chrdev_open+0xa3/0x1c0
>    ? cdev_put.part.3+0x20/0x20
>    do_dentry_open+0x21f/0x380
>    vfs_open+0x2f/0x40
>    path_openat+0xd67/0xf60
>    ? page_add_file_rmap+0xad/0x140
>    ? do_set_pte+0xd7/0x210
>    do_filp_open+0xc5/0x140
>    do_sys_openat2+0x239/0x300
>    ? do_sys_openat2+0x239/0x300
>    do_sys_open+0x59/0x80
>    __x64_sys_openat+0x20/0x30
>    do_syscall_64+0x3f/0x90
>    entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> With this patch, the warning is only reported in interrupt context and when
> the target CPU is not local CPU.
> 
> Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
> ---
>  arch/x86/kernel/apic/msi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
> index 44ebe25e7703..c4c73f227eeb 100644
> --- a/arch/x86/kernel/apic/msi.c
> +++ b/arch/x86/kernel/apic/msi.c
> @@ -72,7 +72,7 @@ msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force)
>  	 * Paranoia: Validate that the interrupt target is the local
>  	 * CPU.
>  	 */
> -	if (WARN_ON_ONCE(cpu != smp_processor_id())) {
> +	if (in_interrupt() && WARN_ON_ONCE(cpu != smp_processor_id())) {
>  		irq_msi_update_msg(irqd, cfg);
>  		return ret;
>  	}
> -- 
> 2.14.5
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

  reply	other threads:[~2021-07-13  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  6:46 [PATCH] x86/apic/msi: check interupt context before reporting warning Yongxin Liu
2021-07-13  6:59 ` Greg KH [this message]
2021-07-13 16:10 ` Thomas Gleixner

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=YO056/qui/vCvCcV@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bhelgaas@google.com \
    --cc=evgreen@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=rajatja@google.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yongxin.liu@windriver.com \
    /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).