mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Christoph Hellwig](/assets/img/avatar_default.png)
__smp_call_function_single already avoids multiple IPIs by internally queing up the items, and now also is available for non-SMP builds as a trivially correct stub, so there is no need to wrap it. If the additional lock roundtrip cause problems my patch to convert the generic IPI code to llists is waiting to get merged will fix it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/list.h>
|
|
#include <linux/llist.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/blk-mq.h>
|
|
#include "blk-mq.h"
|
|
|
|
static LIST_HEAD(blk_mq_cpu_notify_list);
|
|
static DEFINE_SPINLOCK(blk_mq_cpu_notify_lock);
|
|
|
|
static int blk_mq_main_cpu_notify(struct notifier_block *self,
|
|
unsigned long action, void *hcpu)
|
|
{
|
|
unsigned int cpu = (unsigned long) hcpu;
|
|
struct blk_mq_cpu_notifier *notify;
|
|
|
|
spin_lock(&blk_mq_cpu_notify_lock);
|
|
|
|
list_for_each_entry(notify, &blk_mq_cpu_notify_list, list)
|
|
notify->notify(notify->data, action, cpu);
|
|
|
|
spin_unlock(&blk_mq_cpu_notify_lock);
|
|
return NOTIFY_OK;
|
|
}
|
|
|
|
static struct notifier_block __cpuinitdata blk_mq_main_cpu_notifier = {
|
|
.notifier_call = blk_mq_main_cpu_notify,
|
|
};
|
|
|
|
void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
|
|
{
|
|
BUG_ON(!notifier->notify);
|
|
|
|
spin_lock(&blk_mq_cpu_notify_lock);
|
|
list_add_tail(¬ifier->list, &blk_mq_cpu_notify_list);
|
|
spin_unlock(&blk_mq_cpu_notify_lock);
|
|
}
|
|
|
|
void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
|
|
{
|
|
spin_lock(&blk_mq_cpu_notify_lock);
|
|
list_del(¬ifier->list);
|
|
spin_unlock(&blk_mq_cpu_notify_lock);
|
|
}
|
|
|
|
void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
|
|
void (*fn)(void *, unsigned long, unsigned int),
|
|
void *data)
|
|
{
|
|
notifier->notify = fn;
|
|
notifier->data = data;
|
|
}
|
|
|
|
void __init blk_mq_cpu_init(void)
|
|
{
|
|
register_hotcpu_notifier(&blk_mq_main_cpu_notifier);
|
|
}
|