[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Move tasklet implementation into its own source files.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1271668002 -3600
# Node ID fd142087a8f6a71375a7da47ee373530fd27ab2a
# Parent  e5376ececd8b614d7006d413137563e241a70e6d
Move tasklet implementation into its own source files.

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@xxxxxxxxxx>
---
 xen/arch/ia64/xen/xensetup.c        |    1 
 xen/arch/x86/acpi/cpu_idle.c        |    1 
 xen/arch/x86/setup.c                |    1 
 xen/arch/x86/smpboot.c              |    1 
 xen/common/Makefile                 |    1 
 xen/common/domain.c                 |    1 
 xen/common/keyhandler.c             |    2 
 xen/common/softirq.c                |  138 -----------------------------
 xen/common/tasklet.c                |  170 ++++++++++++++++++++++++++++++++++++
 xen/common/trace.c                  |    2 
 xen/drivers/char/console.c          |    1 
 xen/drivers/passthrough/io.c        |    1 
 xen/drivers/passthrough/pci.c       |    2 
 xen/drivers/passthrough/vtd/iommu.c |    1 
 xen/include/asm-x86/hvm/vcpu.h      |    1 
 xen/include/asm-x86/hvm/vlapic.h    |    2 
 xen/include/xen/hvm/irq.h           |    2 
 xen/include/xen/sched.h             |    1 
 xen/include/xen/softirq.h           |   24 -----
 xen/include/xen/tasklet.h           |   35 +++++++
 20 files changed, 221 insertions(+), 167 deletions(-)

diff -r e5376ececd8b -r fd142087a8f6 xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/arch/ia64/xen/xensetup.c      Mon Apr 19 10:06:42 2010 +0100
@@ -562,6 +562,7 @@ skip_move:
     end_boot_allocator();
 
     softirq_init();
+    tasklet_subsys_init();
 
     late_setup_arch(&cmdline);
 
diff -r e5376ececd8b -r fd142087a8f6 xen/arch/x86/acpi/cpu_idle.c
--- a/xen/arch/x86/acpi/cpu_idle.c      Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/arch/x86/acpi/cpu_idle.c      Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/arch/x86/setup.c      Mon Apr 19 10:06:42 2010 +0100
@@ -972,6 +972,7 @@ void __init __start_xen(unsigned long mb
 #endif
 
     softirq_init();
+    tasklet_subsys_init();
 
     early_cpu_init();
 
diff -r e5376ececd8b -r fd142087a8f6 xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c    Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/arch/x86/smpboot.c    Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/common/Makefile
--- a/xen/common/Makefile       Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/common/Makefile       Mon Apr 19 10:06:42 2010 +0100
@@ -23,6 +23,7 @@ obj-y += string.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
diff -r e5376ececd8b -r fd142087a8f6 xen/common/domain.c
--- a/xen/common/domain.c       Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/common/domain.c       Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/common/keyhandler.c
--- a/xen/common/keyhandler.c   Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/common/keyhandler.c   Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/common/softirq.c
--- a/xen/common/softirq.c      Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/common/softirq.c      Mon Apr 19 10:06:42 2010 +0100
@@ -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 -r e5376ececd8b -r fd142087a8f6 xen/common/tasklet.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/common/tasklet.c      Mon Apr 19 10:06:42 2010 +0100
@@ -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@xxxxxxxxxx>
+ */
+
+#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:
+ */
diff -r e5376ececd8b -r fd142087a8f6 xen/common/trace.c
--- a/xen/common/trace.c        Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/common/trace.c        Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/drivers/char/console.c        Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/drivers/passthrough/io.c
--- a/xen/drivers/passthrough/io.c      Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/drivers/passthrough/io.c      Mon Apr 19 10:06:42 2010 +0100
@@ -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);
 
diff -r e5376ececd8b -r fd142087a8f6 xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c     Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/drivers/passthrough/pci.c     Mon Apr 19 10:06:42 2010 +0100
@@ -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;
diff -r e5376ececd8b -r fd142087a8f6 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/include/asm-x86/hvm/vcpu.h
--- a/xen/include/asm-x86/hvm/vcpu.h    Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/include/asm-x86/hvm/vcpu.h    Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/include/asm-x86/hvm/vlapic.h
--- a/xen/include/asm-x86/hvm/vlapic.h  Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/include/asm-x86/hvm/vlapic.h  Mon Apr 19 10:06:42 2010 +0100
@@ -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>
diff -r e5376ececd8b -r fd142087a8f6 xen/include/xen/hvm/irq.h
--- a/xen/include/xen/hvm/irq.h Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/include/xen/hvm/irq.h Mon Apr 19 10:06:42 2010 +0100
@@ -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>
 
diff -r e5376ececd8b -r fd142087a8f6 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/include/xen/sched.h   Mon Apr 19 10:06:42 2010 +0100
@@ -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
diff -r e5376ececd8b -r fd142087a8f6 xen/include/xen/softirq.h
--- a/xen/include/xen/softirq.h Mon Apr 19 09:00:30 2010 +0100
+++ b/xen/include/xen/softirq.h Mon Apr 19 10:06:42 2010 +0100
@@ -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 -r e5376ececd8b -r fd142087a8f6 xen/include/xen/tasklet.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/include/xen/tasklet.h Mon Apr 19 10:06:42 2010 +0100
@@ -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__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.