Revision 16ec54ad1502a095a35b4ae3bf6ec129111a44c5 authored by Linus Torvalds on 19 January 2014, 21:06:51 UTC, committed by Linus Torvalds on 19 January 2014, 21:06:51 UTC
Pull perf fixes from Ingo Molnar: - an s2ram related fix on AMD systems - a perf fault handling bug that is relatively old but which has become much easier to trigger in v3.13 after commit e00b12e64be9 ("perf/x86: Further optimize copy_from_user_nmi()") * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h x86, mm, perf: Allow recursive faults from interrupts
kick.c
/*
* Copyright (C) 2009 Imagination Technologies
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*
* The Meta KICK interrupt mechanism is generally a useful feature, so
* we provide an interface for registering multiple interrupt
* handlers. All the registered interrupt handlers are "chained". When
* a KICK interrupt is received the first function in the list is
* called. If that interrupt handler cannot handle the KICK the next
* one is called, then the next until someone handles it (or we run
* out of functions). As soon as one function handles the interrupt no
* other handlers are called.
*
* The only downside of chaining interrupt handlers is that each
* handler must be able to detect whether the KICK was intended for it
* or not. For example, when the IPI handler runs and it sees that
* there are no IPI messages it must not signal that the KICK was
* handled, thereby giving the other handlers a chance to run.
*
* The reason that we provide our own interface for calling KICK
* handlers instead of using the generic kernel infrastructure is that
* the KICK handlers require access to a CPU's pTBI structure. So we
* pass it as an argument.
*/
#include <linux/export.h>
#include <linux/hardirq.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <asm/traps.h>
/*
* All accesses/manipulations of kick_handlers_list should be
* performed while holding kick_handlers_lock.
*/
static DEFINE_SPINLOCK(kick_handlers_lock);
static LIST_HEAD(kick_handlers_list);
void kick_register_func(struct kick_irq_handler *kh)
{
unsigned long flags;
spin_lock_irqsave(&kick_handlers_lock, flags);
list_add_tail(&kh->list, &kick_handlers_list);
spin_unlock_irqrestore(&kick_handlers_lock, flags);
}
EXPORT_SYMBOL(kick_register_func);
void kick_unregister_func(struct kick_irq_handler *kh)
{
unsigned long flags;
spin_lock_irqsave(&kick_handlers_lock, flags);
list_del(&kh->list);
spin_unlock_irqrestore(&kick_handlers_lock, flags);
}
EXPORT_SYMBOL(kick_unregister_func);
TBIRES
kick_handler(TBIRES State, int SigNum, int Triggers, int Inst, PTBI pTBI)
{
struct pt_regs *old_regs;
struct kick_irq_handler *kh;
struct list_head *lh;
int handled = 0;
TBIRES ret;
head_end(State, ~INTS_OFF_MASK);
/* If we interrupted user code handle any critical sections. */
if (State.Sig.SaveMask & TBICTX_PRIV_BIT)
restart_critical_section(State);
trace_hardirqs_off();
old_regs = set_irq_regs((struct pt_regs *)State.Sig.pCtx);
irq_enter();
/*
* There is no need to disable interrupts here because we
* can't nest KICK interrupts in a KICK interrupt handler.
*/
spin_lock(&kick_handlers_lock);
list_for_each(lh, &kick_handlers_list) {
kh = list_entry(lh, struct kick_irq_handler, list);
ret = kh->func(State, SigNum, Triggers, Inst, pTBI, &handled);
if (handled)
break;
}
spin_unlock(&kick_handlers_lock);
WARN_ON(!handled);
irq_exit();
set_irq_regs(old_regs);
return tail_end(ret);
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...