]> xenbits.xensource.com Git - xen.git/commitdiff
Move tasklet implementation into its own source files.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Apr 2010 09:06:42 +0000 (10:06 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Apr 2010 09:06:42 +0000 (10:06 +0100)
This is preparation for implementing tasklets in vcpu context rather
than softirq context. There is no change to the implementation of
tasklets in this patch.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
20 files changed:
xen/arch/ia64/xen/xensetup.c
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/common/Makefile
xen/common/domain.c
xen/common/keyhandler.c
xen/common/softirq.c
xen/common/tasklet.c [new file with mode: 0644]
xen/common/trace.c
xen/drivers/char/console.c
xen/drivers/passthrough/io.c
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/vtd/iommu.c
xen/include/asm-x86/hvm/vcpu.h
xen/include/asm-x86/hvm/vlapic.h
xen/include/xen/hvm/irq.h
xen/include/xen/sched.h
xen/include/xen/softirq.h
xen/include/xen/tasklet.h [new file with mode: 0644]

index da8de417c26657e5d0fcdd37395300ffcdf591c6..82b758b7884e61c4750e940f1a17d7de5b04b0ba 100644 (file)
@@ -562,6 +562,7 @@ skip_move:
     end_boot_allocator();
 
     softirq_init();
+    tasklet_subsys_init();
 
     late_setup_arch(&cmdline);
 
index bd4d68a14d3a3b6f8c91fdee55d746b1975567e5..7c75f04f3ff82f71240af65163fdfd664a70f885 100644 (file)
@@ -47,6 +47,7 @@
 #include <asm/hpet.h>
 #include <asm/processor.h>
 #include <xen/pmstat.h>
+#include <xen/softirq.h>
 #include <public/platform.h>
 #include <public/sysctl.h>
 #include <acpi/cpufreq/cpufreq.h>
index 68be297eecb31c6923431d94e063d502b077d356..855cb4ad54e01584ec91cae1e57925ee2c926f43 100644 (file)
@@ -972,6 +972,7 @@ void __init __start_xen(unsigned long mbi_p)
 #endif
 
     softirq_init();
+    tasklet_subsys_init();
 
     early_cpu_init();
 
index 5f8a96100b8ee669c0be29db9b3993b22031ae0e..4b2f64d5fffeb44df315f43cba04e7eca453c328 100644 (file)
@@ -42,6 +42,7 @@
 #include <xen/irq.h>
 #include <xen/delay.h>
 #include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <xen/serial.h>
 #include <xen/numa.h>
 #include <xen/event.h>
index baa6b5872bc36de7c3e52da23154031bd2f8d43e..c36d0f351d4244ec695c6592fb0efb22b6a5216f 100644 (file)
@@ -23,6 +23,7 @@ obj-y += stop_machine.o
 obj-y += string.o
 obj-y += symbols.o
 obj-y += sysctl.o
+obj-y += tasklet.o
 obj-y += time.o
 obj-y += timer.o
 obj-y += trace.o
index 808d2509308053370860c7358c8131f8edc7169c..f67445c77e5fa6b5cafa5e6e933fa99ce6a6480c 100644 (file)
@@ -17,6 +17,7 @@
 #include <xen/time.h>
 #include <xen/console.h>
 #include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <xen/domain_page.h>
 #include <xen/rangeset.h>
 #include <xen/guest_access.h>
index e3e64a19535a9eddc1b72b3d5b253d7bf114547a..611724a645d0dbe8bfe2d1a5b2dce92dba5d29d7 100644 (file)
@@ -9,7 +9,7 @@
 #include <xen/console.h>
 #include <xen/serial.h>
 #include <xen/sched.h>
-#include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <xen/domain.h>
 #include <xen/rangeset.h>
 #include <xen/compat.h>
index e90b71ed2babd9abb287d85207d82d4864004957..fac59818ac965f1b8851b7d617f3ee1a864423a2 100644 (file)
@@ -88,146 +88,8 @@ void raise_softirq(unsigned int nr)
     set_bit(nr, &softirq_pending(smp_processor_id()));
 }
 
-static bool_t tasklets_initialised;
-static DEFINE_PER_CPU(struct list_head, tasklet_list);
-static DEFINE_SPINLOCK(tasklet_lock);
-
-void tasklet_schedule_on_cpu(struct tasklet *t, unsigned int cpu)
-{
-    unsigned long flags;
-
-    spin_lock_irqsave(&tasklet_lock, flags);
-
-    if ( tasklets_initialised && !t->is_dead )
-    {
-        t->scheduled_on = cpu;
-        if ( !t->is_running )
-        {
-            list_del(&t->list);
-            list_add_tail(&t->list, &per_cpu(tasklet_list, cpu));
-            cpu_raise_softirq(cpu, TASKLET_SOFTIRQ);
-        }
-    }
-
-    spin_unlock_irqrestore(&tasklet_lock, flags);
-}
-
-void tasklet_schedule(struct tasklet *t)
-{
-    tasklet_schedule_on_cpu(t, smp_processor_id());
-}
-
-static void tasklet_action(void)
-{
-    unsigned int cpu = smp_processor_id();
-    struct list_head *list = &per_cpu(tasklet_list, cpu);
-    struct tasklet *t;
-
-    spin_lock_irq(&tasklet_lock);
-
-    if ( list_empty(list) )
-    {
-        spin_unlock_irq(&tasklet_lock);
-        return;
-    }
-
-    t = list_entry(list->next, struct tasklet, list);
-    list_del_init(&t->list);
-
-    BUG_ON(t->is_dead || t->is_running || (t->scheduled_on != cpu));
-    t->scheduled_on = -1;
-    t->is_running = 1;
-
-    spin_unlock_irq(&tasklet_lock);
-    t->func(t->data);
-    spin_lock_irq(&tasklet_lock);
-
-    t->is_running = 0;
-
-    if ( t->scheduled_on >= 0 )
-    {
-        BUG_ON(t->is_dead || !list_empty(&t->list));
-        list_add_tail(&t->list, &per_cpu(tasklet_list, t->scheduled_on));
-        if ( t->scheduled_on != cpu )
-            cpu_raise_softirq(t->scheduled_on, TASKLET_SOFTIRQ);
-    }
-
-    /*
-     * If there is more work to do then reschedule. We don't grab more work
-     * immediately as we want to allow other softirq work to happen first.
-     */
-    if ( !list_empty(list) )
-        raise_softirq(TASKLET_SOFTIRQ);
-
-    spin_unlock_irq(&tasklet_lock);
-}
-
-void tasklet_kill(struct tasklet *t)
-{
-    unsigned long flags;
-
-    spin_lock_irqsave(&tasklet_lock, flags);
-
-    if ( !list_empty(&t->list) )
-    {
-        BUG_ON(t->is_dead || t->is_running || (t->scheduled_on < 0));
-        list_del_init(&t->list);
-    }
-    t->scheduled_on = -1;
-    t->is_dead = 1;
-
-    while ( t->is_running )
-    {
-        spin_unlock_irqrestore(&tasklet_lock, flags);
-        cpu_relax();
-        spin_lock_irqsave(&tasklet_lock, flags);
-    }
-
-    spin_unlock_irqrestore(&tasklet_lock, flags);
-}
-
-void migrate_tasklets_from_cpu(unsigned int cpu)
-{
-    struct list_head *list = &per_cpu(tasklet_list, cpu);
-    unsigned long flags;
-    struct tasklet *t;
-
-    spin_lock_irqsave(&tasklet_lock, flags);
-
-    while ( !list_empty(list) )
-    {
-        t = list_entry(list->next, struct tasklet, list);
-        BUG_ON(t->scheduled_on != cpu);
-        t->scheduled_on = smp_processor_id();
-        list_del(&t->list);
-        list_add_tail(&t->list, &this_cpu(tasklet_list));
-    }
-
-    raise_softirq(TASKLET_SOFTIRQ);
-
-    spin_unlock_irqrestore(&tasklet_lock, flags);
-}
-
-void tasklet_init(
-    struct tasklet *t, void (*func)(unsigned long), unsigned long data)
-{
-    memset(t, 0, sizeof(*t));
-    INIT_LIST_HEAD(&t->list);
-    t->scheduled_on = -1;
-    t->func = func;
-    t->data = data;
-}
-
 void __init softirq_init(void)
 {
-    unsigned int cpu;
-
-    for_each_possible_cpu ( cpu )
-        INIT_LIST_HEAD(&per_cpu(tasklet_list, cpu));
-
-    open_softirq(TASKLET_SOFTIRQ, tasklet_action);
-
-    tasklets_initialised = 1;
 }
 
 /*
diff --git a/xen/common/tasklet.c b/xen/common/tasklet.c
new file mode 100644 (file)
index 0000000..c7d692b
--- /dev/null
@@ -0,0 +1,170 @@
+/******************************************************************************
+ * tasklet.c
+ * 
+ * Dynamically-allocatable tasks run in softirq context on at most one CPU at
+ * a time.
+ * 
+ * Copyright (c) 2010, Citrix Systems, Inc.
+ * Copyright (c) 1992, Linus Torvalds
+ * 
+ * Authors:
+ *    Keir Fraser <keir.fraser@citrix.com>
+ */
+
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/sched.h>
+#include <xen/softirq.h>
+#include <xen/tasklet.h>
+
+static bool_t tasklets_initialised;
+static DEFINE_PER_CPU(struct list_head, tasklet_list);
+static DEFINE_SPINLOCK(tasklet_lock);
+
+void tasklet_schedule_on_cpu(struct tasklet *t, unsigned int cpu)
+{
+    unsigned long flags;
+
+    spin_lock_irqsave(&tasklet_lock, flags);
+
+    if ( tasklets_initialised && !t->is_dead )
+    {
+        t->scheduled_on = cpu;
+        if ( !t->is_running )
+        {
+            list_del(&t->list);
+            list_add_tail(&t->list, &per_cpu(tasklet_list, cpu));
+            cpu_raise_softirq(cpu, TASKLET_SOFTIRQ);
+        }
+    }
+
+    spin_unlock_irqrestore(&tasklet_lock, flags);
+}
+
+void tasklet_schedule(struct tasklet *t)
+{
+    tasklet_schedule_on_cpu(t, smp_processor_id());
+}
+
+static void tasklet_action(void)
+{
+    unsigned int cpu = smp_processor_id();
+    struct list_head *list = &per_cpu(tasklet_list, cpu);
+    struct tasklet *t;
+
+    spin_lock_irq(&tasklet_lock);
+
+    if ( list_empty(list) )
+    {
+        spin_unlock_irq(&tasklet_lock);
+        return;
+    }
+
+    t = list_entry(list->next, struct tasklet, list);
+    list_del_init(&t->list);
+
+    BUG_ON(t->is_dead || t->is_running || (t->scheduled_on != cpu));
+    t->scheduled_on = -1;
+    t->is_running = 1;
+
+    spin_unlock_irq(&tasklet_lock);
+    t->func(t->data);
+    spin_lock_irq(&tasklet_lock);
+
+    t->is_running = 0;
+
+    if ( t->scheduled_on >= 0 )
+    {
+        BUG_ON(t->is_dead || !list_empty(&t->list));
+        list_add_tail(&t->list, &per_cpu(tasklet_list, t->scheduled_on));
+        if ( t->scheduled_on != cpu )
+            cpu_raise_softirq(t->scheduled_on, TASKLET_SOFTIRQ);
+    }
+
+    /*
+     * If there is more work to do then reschedule. We don't grab more work
+     * immediately as we want to allow other softirq work to happen first.
+     */
+    if ( !list_empty(list) )
+        raise_softirq(TASKLET_SOFTIRQ);
+
+    spin_unlock_irq(&tasklet_lock);
+}
+
+void tasklet_kill(struct tasklet *t)
+{
+    unsigned long flags;
+
+    spin_lock_irqsave(&tasklet_lock, flags);
+
+    if ( !list_empty(&t->list) )
+    {
+        BUG_ON(t->is_dead || t->is_running || (t->scheduled_on < 0));
+        list_del_init(&t->list);
+    }
+    t->scheduled_on = -1;
+    t->is_dead = 1;
+
+    while ( t->is_running )
+    {
+        spin_unlock_irqrestore(&tasklet_lock, flags);
+        cpu_relax();
+        spin_lock_irqsave(&tasklet_lock, flags);
+    }
+
+    spin_unlock_irqrestore(&tasklet_lock, flags);
+}
+
+void migrate_tasklets_from_cpu(unsigned int cpu)
+{
+    struct list_head *list = &per_cpu(tasklet_list, cpu);
+    unsigned long flags;
+    struct tasklet *t;
+
+    spin_lock_irqsave(&tasklet_lock, flags);
+
+    while ( !list_empty(list) )
+    {
+        t = list_entry(list->next, struct tasklet, list);
+        BUG_ON(t->scheduled_on != cpu);
+        t->scheduled_on = smp_processor_id();
+        list_del(&t->list);
+        list_add_tail(&t->list, &this_cpu(tasklet_list));
+    }
+
+    raise_softirq(TASKLET_SOFTIRQ);
+
+    spin_unlock_irqrestore(&tasklet_lock, flags);
+}
+
+void tasklet_init(
+    struct tasklet *t, void (*func)(unsigned long), unsigned long data)
+{
+    memset(t, 0, sizeof(*t));
+    INIT_LIST_HEAD(&t->list);
+    t->scheduled_on = -1;
+    t->func = func;
+    t->data = data;
+}
+
+void __init tasklet_subsys_init(void)
+{
+    unsigned int cpu;
+
+    for_each_possible_cpu ( cpu )
+        INIT_LIST_HEAD(&per_cpu(tasklet_list, cpu));
+
+    open_softirq(TASKLET_SOFTIRQ, tasklet_action);
+
+    tasklets_initialised = 1;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index cd1f0fb7f62b52076525787ae7079f51b797bcf4..110f3b8c7d697abde6373389286ab9e477764a5e 100644 (file)
@@ -25,7 +25,7 @@
 #include <xen/trace.h>
 #include <xen/errno.h>
 #include <xen/event.h>
-#include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <xen/init.h>
 #include <xen/mm.h>
 #include <xen/percpu.h>
index 56500ad681049c22b213b1ed5579684fb9cd0f72..354ff86b730f39abc8f5f81017b90aa36c7f64fb 100644 (file)
@@ -21,6 +21,7 @@
 #include <xen/console.h>
 #include <xen/serial.h>
 #include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <xen/keyhandler.h>
 #include <xen/mm.h>
 #include <xen/delay.h>
index cac004505483dd4ac2a65dad56760a7bf6bf7f4b..8e14af75a2a29adf1b6c0d2ce71790f13dbd26af 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/hvm/iommu.h>
 #include <asm/hvm/support.h>
 #include <xen/hvm/irq.h>
+#include <xen/tasklet.h>
 
 static void hvm_dirq_assist(unsigned long _d);
 
index bc6974c12281dd2a8563cc07b21d43c1803fe4b9..23dc95ca4e62cdfd85570dc73207c750cd53a292 100644 (file)
@@ -25,7 +25,7 @@
 #include <asm/hvm/irq.h>
 #include <xen/delay.h>
 #include <xen/keyhandler.h>
-
+#include <xen/tasklet.h>
 
 LIST_HEAD(alldevs_list);
 spinlock_t pcidevs_lock = SPIN_LOCK_UNLOCKED;
index 1c47d5c6c866105f336faecab7dd189745faf9bc..f217dfc978604e71d38585f7fe8ffe0185450de5 100644 (file)
@@ -26,6 +26,7 @@
 #include <xen/iommu.h>
 #include <asm/hvm/iommu.h>
 #include <xen/numa.h>
+#include <xen/softirq.h>
 #include <xen/time.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
index 840625040f1e64773e01de7244ef77d694051315..ed6b250ff942a2663dca0aa617bf3f5e09bef25b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __ASM_X86_HVM_VCPU_H__
 #define __ASM_X86_HVM_VCPU_H__
 
+#include <xen/tasklet.h>
 #include <asm/hvm/io.h>
 #include <asm/hvm/vlapic.h>
 #include <asm/hvm/vmx/vmcs.h>
index 880754d2abeae78b8d28a767dca6b32ebe33b6b8..05bd719da1a7857cdcb52a1906d671a53371573e 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef __ASM_X86_HVM_VLAPIC_H__
 #define __ASM_X86_HVM_VLAPIC_H__
 
-#include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <asm/msr.h>
 #include <public/hvm/ioreq.h>
 #include <asm/hvm/vpt.h>
index c1747ed73c6172891a5090c274a7b0b755e7be06..f21b02ceebb600edfcaa774766baaf15337124f6 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <xen/types.h>
 #include <xen/spinlock.h>
-#include <xen/softirq.h>
+#include <xen/tasklet.h>
 #include <asm/irq.h>
 #include <public/hvm/save.h>
 
index a1baa78e6984daee2c1f1628aca49a3e70f9b393..f0adc55284c9dda888bbfe0e93bff09e37daa3d3 100644 (file)
@@ -20,6 +20,7 @@
 #include <xen/rcupdate.h>
 #include <xen/irq.h>
 #include <xen/mm.h>
+#include <xen/tasklet.h>
 #include <public/mem_event.h>
 
 #ifdef CONFIG_COMPAT
index 0e3c4ea5f23c3e4b99fe431a5f45f551dcd7024a..cadf15a0102c602b8bfc3052fab8868a246c53ec 100644 (file)
@@ -40,28 +40,4 @@ void raise_softirq(unsigned int nr);
  */
 void process_pending_softirqs(void);
 
-/*
- * TASKLETS -- dynamically-allocatable tasks run in softirq context
- * on at most one CPU at a time.
- */
-struct tasklet
-{
-    struct list_head list;
-    int scheduled_on;
-    bool_t is_running;
-    bool_t is_dead;
-    void (*func)(unsigned long);
-    unsigned long data;
-};
-
-#define DECLARE_TASKLET(name, func, data) \
-    struct tasklet name = { LIST_HEAD_INIT(name.list), -1, 0, 0, func, data }
-
-void tasklet_schedule_on_cpu(struct tasklet *t, unsigned int cpu);
-void tasklet_schedule(struct tasklet *t);
-void tasklet_kill(struct tasklet *t);
-void migrate_tasklets_from_cpu(unsigned int cpu);
-void tasklet_init(
-    struct tasklet *t, void (*func)(unsigned long), unsigned long data);
-
 #endif /* __XEN_SOFTIRQ_H__ */
diff --git a/xen/include/xen/tasklet.h b/xen/include/xen/tasklet.h
new file mode 100644 (file)
index 0000000..9187462
--- /dev/null
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * tasklet.h
+ * 
+ * Dynamically-allocatable tasks run in softirq context on at most one CPU at
+ * a time.
+ */
+
+#ifndef __XEN_TASKLET_H__
+#define __XEN_TASKLET_H__
+
+#include <xen/types.h>
+#include <xen/list.h>
+
+struct tasklet
+{
+    struct list_head list;
+    int scheduled_on;
+    bool_t is_running;
+    bool_t is_dead;
+    void (*func)(unsigned long);
+    unsigned long data;
+};
+
+#define DECLARE_TASKLET(name, func, data) \
+    struct tasklet name = { LIST_HEAD_INIT(name.list), -1, 0, 0, func, data }
+
+void tasklet_schedule_on_cpu(struct tasklet *t, unsigned int cpu);
+void tasklet_schedule(struct tasklet *t);
+void tasklet_kill(struct tasklet *t);
+void migrate_tasklets_from_cpu(unsigned int cpu);
+void tasklet_init(
+    struct tasklet *t, void (*func)(unsigned long), unsigned long data);
+void tasklet_subsys_init(void);
+
+#endif /* __XEN_TASKLET_H__ */