From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: boris.ostrovsky@oracle.com, yu.c.chen@intel.com, hch@lst.de,
peterz@infradead.org, tony.luck@intel.com, lenb@kernel.org,
marc.zyngier@arm.com, petri.latvala@intel.com, joro@8bytes.org,
tglx@linutronix.de, hpa@zytor.com, rui.zhang@intel.com,
rjw@rjwysocki.net, pbonzini@redhat.com, akataria@vmware.com,
bp@alien8.de, mingo@kernel.org, kys@microsoft.com,
jgross@suse.com, linux-kernel@vger.kernel.org,
arjan@linux.intel.com, dan.j.williams@intel.com,
rostedt@goodmis.org
Subject: [tip:x86/apic] x86/vector: Use correct per cpu variable in free_moved_vector()
Date: Tue, 17 Oct 2017 07:49:28 -0700 [thread overview]
Message-ID: <tip-0696d059f23c05f2dbc3b19ef50e5bdd175b782b@git.kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1710161614430.1973@nanos>
Commit-ID: 0696d059f23c05f2dbc3b19ef50e5bdd175b782b
Gitweb: https://git.kernel.org/tip/0696d059f23c05f2dbc3b19ef50e5bdd175b782b
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Mon, 16 Oct 2017 16:16:19 +0200
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 17 Oct 2017 16:45:09 +0200
x86/vector: Use correct per cpu variable in free_moved_vector()
free_moved_vector() accesses the per cpu vector array with this_cpu_write()
to clear the vector. The function has two call sites:
1) The vector cleanup IPI
2) The force_complete_move() code path
For #1 this_cpu_write() is correct as it runs on the CPU on which the
vector needs to be freed.
For #2 this_cpu_write() is wrong because the function is called from an
outgoing CPU which is not necessarily the CPU on which the previous vector
needs to be freed. As a result it sets the vector on the outgoing CPU to
NULL, which is pointless as that CPU does not handle interrupts
anymore. What's worse is that it leaves the vector on the previous target
CPU in place which later on triggers the BUG_ON(vector) in the vector
allocation code when the vector gets reused. That's possible because the
bitmap allocator entry of that CPU is freed correctly.
Always use the CPU to which the vector was associated and clear the vector
entry on that CPU. Fixup the tracepoint as well so it tracks on which CPU
the vector gets removed.
Fixes: 69cde0004a4b ("x86/vector: Use matrix allocator for vector assignment")
Reported-by: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Yu Chen <yu.c.chen@intel.com>
Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1710161614430.1973@nanos
---
arch/x86/include/asm/trace/irq_vectors.h | 12 ++++++++----
arch/x86/kernel/apic/vector.c | 4 ++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/trace/irq_vectors.h b/arch/x86/include/asm/trace/irq_vectors.h
index bc09c5c..bfd480b 100644
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -360,24 +360,28 @@ TRACE_EVENT(vector_setup,
TRACE_EVENT(vector_free_moved,
- TP_PROTO(unsigned int irq, unsigned int vector, bool is_managed),
+ TP_PROTO(unsigned int irq, unsigned int cpu, unsigned int vector,
+ bool is_managed),
- TP_ARGS(irq, vector, is_managed),
+ TP_ARGS(irq, cpu, vector, is_managed),
TP_STRUCT__entry(
__field( unsigned int, irq )
+ __field( unsigned int, cpu )
__field( unsigned int, vector )
__field( bool, is_managed )
),
TP_fast_assign(
__entry->irq = irq;
+ __entry->cpu = cpu;
__entry->vector = vector;
__entry->is_managed = is_managed;
),
- TP_printk("irq=%u vector=%u is_managed=%d",
- __entry->irq, __entry->vector, __entry->is_managed)
+ TP_printk("irq=%u cpu=%u vector=%u is_managed=%d",
+ __entry->irq, __entry->cpu, __entry->vector,
+ __entry->is_managed)
);
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 573538e..05c85e6 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -797,9 +797,9 @@ static void free_moved_vector(struct apic_chip_data *apicd)
*/
WARN_ON_ONCE(managed);
- trace_vector_free_moved(apicd->irq, vector, managed);
+ trace_vector_free_moved(apicd->irq, cpu, vector, managed);
irq_matrix_free(vector_matrix, cpu, vector, managed);
- __this_cpu_write(vector_irq[vector], VECTOR_UNUSED);
+ per_cpu(vector_irq, cpu)[vector] = VECTOR_UNUSED;
hlist_del_init(&apicd->clist);
apicd->prev_vector = 0;
apicd->move_in_progress = 0;
prev parent reply other threads:[~2017-10-17 14:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <c3f2d5df-2fd9-5e7f-b744-144e0575f61b@intel.com>
[not found] ` <20171013110850.GA5303@yu-chen.sh.intel.com>
[not found] ` <149ec6e8-4189-040c-a53c-12b0a51a855e@intel.com>
[not found] ` <c1f48dee-bf92-4076-eb15-6e306786bf50@intel.com>
[not found] ` <e1689005-7e4e-a3c9-5f81-57d337a57a2f@intel.com>
[not found] ` <cd667019-c16e-60db-7c5d-f2f1cf8d7351@intel.com>
2017-10-16 11:04 ` Regression in linux-next Thomas Gleixner
2017-10-16 11:38 ` Petri Latvala
2017-10-16 12:34 ` Thomas Gleixner
2017-10-16 12:54 ` Thomas Gleixner
2017-10-16 13:10 ` Petri Latvala
2017-10-16 14:16 ` Thomas Gleixner
2017-10-17 14:49 ` tip-bot for Thomas Gleixner [this message]
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=tip-0696d059f23c05f2dbc3b19ef50e5bdd175b782b@git.kernel.org \
--to=tipbot@zytor.com \
--cc=akataria@vmware.com \
--cc=arjan@linux.intel.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=hch@lst.de \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=joro@8bytes.org \
--cc=kys@microsoft.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=petri.latvala@intel.com \
--cc=rjw@rjwysocki.net \
--cc=rostedt@goodmis.org \
--cc=rui.zhang@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=yu.c.chen@intel.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
Powered by JetHome