summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-08-27 13:26:05 +0200
committerJens Axboe <jens.axboe@oracle.com>2009-08-27 13:55:29 +0200
commitf2a2bac1a09d89f2ae7bc73a6ad54ed5006d0006 (patch)
tree8af2df1288ca83d99068937e68f790f102b51d24
parent70784d657687d0aea36d18e296be081847d6308f (diff)
libata: switch pio task from workqueue to slow-worklibata-pio
A workqueue isn't a good fit for the pio task: - It does not require per-CPU support, thus wasting many threads. - The pio task would like to have more than one thread per CPU in some cases, for the single CPU case of having more than one pio device active. So convert to slow-work instead, this is now possible with support for delayed slow work and cancellation. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/libata-core.c29
-rw-r--r--drivers/ata/libata-sff.c2
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--include/linux/libata.h3
5 files changed, 21 insertions, 16 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index b17c57f85032..9369e6dc331c 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -8,6 +8,7 @@ menuconfig ATA
depends on BLOCK
depends on !(M32R || M68K) || BROKEN
select SCSI
+ select SLOW_WORK
---help---
If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or
any other ATA device under Linux, say Y and make sure that you know
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 072ba5ea138f..285fc52025df 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -95,7 +95,6 @@ static void ata_dev_xfermask(struct ata_device *dev);
static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
unsigned int ata_print_id = 1;
-static struct workqueue_struct *ata_wq;
struct workqueue_struct *ata_aux_wq;
@@ -1700,7 +1699,7 @@ void ata_pio_queue_task(struct ata_port *ap, void *data, unsigned long delay)
ap->port_task_data = data;
/* may fail if ata_port_flush_task() in progress */
- queue_delayed_work(ata_wq, &ap->port_task, msecs_to_jiffies(delay));
+ delayed_slow_work_enqueue(&ap->port_task, msecs_to_jiffies(delay));
}
/**
@@ -1717,7 +1716,7 @@ void ata_port_flush_task(struct ata_port *ap)
{
DPRINTK("ENTER\n");
- cancel_rearming_delayed_work(&ap->port_task);
+ cancel_delayed_slow_work(&ap->port_task);
if (ata_msg_ctl(ap))
ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __func__);
@@ -5600,6 +5599,14 @@ int sata_link_init_spd(struct ata_link *link)
return 0;
}
+static const struct slow_work_ops ata_work_ops_sff = {
+ .execute = ata_pio_task,
+};
+
+static const struct slow_work_ops ata_work_ops = {
+ .execute = NULL, /* what's the point of this?! */
+};
+
/**
* ata_port_alloc - allocate and initialize basic ATA port resources
* @host: ATA host this allocated port belongs to
@@ -5641,9 +5648,9 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
#endif
#ifdef CONFIG_ATA_SFF
- INIT_DELAYED_WORK(&ap->port_task, ata_pio_task);
+ delayed_slow_work_init(&ap->port_task, &ata_work_ops_sff);
#else
- INIT_DELAYED_WORK(&ap->port_task, NULL);
+ delayed_slow_work_init(&ap->port_task, &ata_work_ops);
#endif
INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
@@ -6580,19 +6587,15 @@ static int __init ata_init(void)
{
ata_parse_force_param();
- ata_wq = create_workqueue("ata");
- if (!ata_wq)
- goto free_force_tbl;
-
ata_aux_wq = create_singlethread_workqueue("ata_aux");
if (!ata_aux_wq)
- goto free_wq;
+ goto free_force_tbl;
+
+ slow_work_register_user(THIS_MODULE);
printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
return 0;
-free_wq:
- destroy_workqueue(ata_wq);
free_force_tbl:
kfree(ata_force_tbl);
return -ENOMEM;
@@ -6601,8 +6604,8 @@ free_force_tbl:
static void __exit ata_exit(void)
{
kfree(ata_force_tbl);
- destroy_workqueue(ata_wq);
destroy_workqueue(ata_aux_wq);
+ slow_work_unregister_user(THIS_MODULE);
}
subsys_initcall(ata_init);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index bbbb1fab1755..f795ab716f75 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1454,7 +1454,7 @@ fsm_start:
}
EXPORT_SYMBOL_GPL(ata_sff_hsm_move);
-void ata_pio_task(struct work_struct *work)
+void ata_pio_task(struct slow_work *work)
{
struct ata_port *ap =
container_of(work, struct ata_port, port_task.work);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 89a1e0018e71..d48d14da6e18 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -202,7 +202,7 @@ static inline int sata_pmp_attach(struct ata_device *dev)
extern void ata_dev_select(struct ata_port *ap, unsigned int device,
unsigned int wait, unsigned int can_sleep);
extern u8 ata_irq_on(struct ata_port *ap);
-extern void ata_pio_task(struct work_struct *work);
+extern void ata_pio_task(struct slow_work *work);
#endif /* CONFIG_ATA_SFF */
#endif /* __LIBATA_H__ */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index e5b6e33c6571..6830c82f5c03 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -34,6 +34,7 @@
#include <linux/io.h>
#include <linux/ata.h>
#include <linux/workqueue.h>
+#include <linux/slow-work.h>
#include <scsi/scsi_host.h>
#include <linux/acpi.h>
#include <linux/cdrom.h>
@@ -734,7 +735,7 @@ struct ata_port {
struct device *dev;
void *port_task_data;
- struct delayed_work port_task;
+ struct delayed_slow_work port_task;
struct delayed_work hotplug_task;
struct work_struct scsi_rescan_task;