From: Yongxin Liu <yongxin.liu@windriver.com>
To: tglx@linutronix.de
Cc: 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: [PATCH] x86/apic/msi: check interupt context before reporting warning
Date: Tue, 13 Jul 2021 14:46:09 +0800 [thread overview]
Message-ID: <20210713064609.25429-1-yongxin.liu@windriver.com> (raw)
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
next reply other threads:[~2021-07-13 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 6:46 Yongxin Liu [this message]
2021-07-13 6:59 ` [PATCH] x86/apic/msi: check interupt context before reporting warning Greg KH
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=20210713064609.25429-1-yongxin.liu@windriver.com \
--to=yongxin.liu@windriver.com \
--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 \
/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).