Skip to contentSkip to conversation

workqueue: update workqueue users - replace create_workqueue()

PATCH In review Tejun Heo 28 participants 105 messages Jan 3, 2011 – Feb 4, 2011

Subsystems (38)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 workqueue: update workqueue users - replace create_workqueue()

Hello,

This patchset examines each user of create_workqueue() and update them to better fit the new workqueue implementation. For backward compatibility, create_workqueue() is mapped to

alloc_workqueue(@name, WQ_MEM_RECLAIM, 1)

but for a lot of its users, WQ_MEM_RECLAIM is not required, @max_active of 1 is unnecessarily strict, or the dedicated workqueue simply isn't needed.

* As the system workqueues can now host higher concurrency, a lot of users can drop dedicated workqueues and use the system ones.

* There are cases where keeping dedicated workqueues are necessary. e.g. They are depended upon during memory reclaim, need to be highpri or CPU intensive, serve work items which free themselves (and thus work items can't be explicitly queued), or need to limit max concurrency level from workqueue. In these cases, alloc_workqueue() calls with better fitting parameters are used.

* This patchset mostly concentrates on converting create_workqueue() users but it also updates general workqueue usages when it makes sense to update them together. Please read description of each patch for deatils.

This simplifies code, removes unnecessary rescuer kernel thread and makes workqueue utilized more efficiently.

This patchset contains the following 32 patches.

0001-arm-omap-use-system_wq-in-mailbox.patch 0002-powerpc-cell-use-system_wq-in-cpufreq_spudemand.patch 0003-block-make-kblockd_workqueue-smarter.patch 0004-bio-integrity-mark-kintegrityd_wq-highpri-and-CPU-in.patch 0005-crypto-mark-crypto-workqueues-CPU_INTENSIVE.patch 0006-acpi-kacpi-_wq-don-t-need-WQ_MEM_RECLAIM.patch 0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch 0008-drm-nouveau-use-system_wq-instead-of-dev_priv-wq.patch 0009-drm-radeon-use-system_wq-instead-of-dev_priv-wq.patch 0010-input-tps6507x-ts-use-system_wq-instead-of-dedicated.patch 0011-v4l-cx18-update-workqueue-usage.patch 0012-i2o-use-alloc_workqueue-instead-of-create_workqueue.patch 0013-misc-iwmc3200top-use-system_wq-instead-of-dedicated-.patch 0014-wireless-ipw2x00-use-system_wq-instead-of-dedicated-.patch 0015-wireless-libertas-_tf-use-system_wq-instead-of-dedic.patch 0016-scsi-be2iscsi-qla2xxx-convert-to-alloc_workqueue.patch 0017-scsi-ibmvstgt-use-system_wq-instead-of-vtgtd-workque.patch 0018-scsi-scsi_tgt_lib-scsi_tgtd-isn-t-used-in-memory-rec.patch 0019-usb-ueagle-atm-use-system_wq-instead-of-dedicated-wo.patch 0020-video-msm_fb-use-system_wq-instead-of-dedicated-work.patch 0021-fs-aio-aio_wq-isn-t-used-in-memory-reclaim-path.patch 0022-ceph-fsc-_wq-s-aren-t-used-in-memory-reclaim-path.patch 0023-net-ceph-make-ceph_msgr_wq-non-reentrant.patch 0024-dlm-dlm-workqueues-aren-t-used-in-memory-reclaim-pat.patch 0025-ext4-convert-to-alloc_workqueue.patch 0026-ocfs2-use-system_wq-instead-of-ocfs2_quota_wq.patch 0027-reiserfs-make-commit_wq-use-the-default-concurrency-.patch 0028-xfs-convert-to-alloc_workqueue.patch 0029-net-9p-use-system_wq-instead-of-p9_mux_wq.patch 0030-net-9p-replace-p9_poll_task-with-a-work.patch 0031-rds-ib-use-system_wq-instead-of-rds_ib_fmr_wq.patch 0032-rxrpc-rxrpc_workqueue-isn-t-used-during-memory-recla.patch

The patches are based on 2.6.37-rc8 (b518a649) and available in the following git branch.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.g replace-create_workqueue

 arch/arm/plat-omap/mailbox.c                    |   10 -
 arch/powerpc/platforms/cell/cpufreq_spudemand.c |   20 --
 block/blk-core.c                                |    4
 crypto/crypto_wq.c                              |    3
 crypto/pcrypt.c                                 |    3
 drivers/acpi/osl.c                              |    6
 drivers/cpufreq/cpufreq_conservative.c          |   22 --
 drivers/cpufreq/cpufreq_ondemand.c              |   20 --
 drivers/gpu/drm/nouveau/nouveau_drv.h           |    1
 drivers/gpu/drm/nouveau/nouveau_irq.c           |    9 -
 drivers/gpu/drm/nouveau/nouveau_state.c         |   19 +-
 drivers/gpu/drm/nouveau/nv50_display.c          |    4
 drivers/gpu/drm/radeon/evergreen.c              |    2
 drivers/gpu/drm/radeon/r100.c                   |    2
 drivers/gpu/drm/radeon/r600.c                   |    2
 drivers/gpu/drm/radeon/radeon.h                 |    1
 drivers/gpu/drm/radeon/radeon_device.c          |    6
 drivers/gpu/drm/radeon/radeon_irq_kms.c         |    5
 drivers/gpu/drm/radeon/radeon_pm.c              |   47 +----
 drivers/gpu/drm/radeon/rs600.c                  |    2
 drivers/input/touchscreen/tps6507x-ts.c         |   12 -
 drivers/media/video/cx18/cx18-driver.c          |   24 --
 drivers/media/video/cx18/cx18-driver.h          |    3
 drivers/media/video/cx18/cx18-streams.h         |    3
 drivers/message/i2o/driver.c                    |    3
 drivers/misc/iwmc3200top/iwmc3200top.h          |    4
 drivers/misc/iwmc3200top/main.c                 |   14 -
 drivers/net/wireless/ipw2x00/ipw2100.c          |   70 +++-----
 drivers/net/wireless/ipw2x00/ipw2100.h          |    1
 drivers/net/wireless/ipw2x00/ipw2200.c          |  196 ++++++++++--------------
 drivers/net/wireless/ipw2x00/ipw2200.h          |    2
 drivers/net/wireless/libertas/if_sdio.c         |   10 -
 drivers/net/wireless/libertas_tf/cmd.c          |    6
 drivers/net/wireless/libertas_tf/libertas_tf.h  |    2
 drivers/net/wireless/libertas_tf/main.c         |   16 -
 drivers/scsi/be2iscsi/be_main.c                 |    2
 drivers/scsi/ibmvscsi/ibmvstgt.c                |   15 -
 drivers/scsi/qla2xxx/qla_os.c                   |    2
 drivers/scsi/scsi_tgt_lib.c                     |    2
 drivers/usb/atm/ueagle-atm.c                    |   19 --
 drivers/video/msm/msm_fb.c                      |   11 -
 fs/aio.c                                        |    4
 fs/bio-integrity.c                              |    7
 fs/ceph/super.c                                 |   10 -
 fs/dlm/lowcomms.c                               |   19 --
 fs/ext4/super.c                                 |    7
 fs/ocfs2/quota.h                                |    3
 fs/ocfs2/quota_global.c                         |   27 ---
 fs/ocfs2/super.c                                |    7
 fs/reiserfs/journal.c                           |    2
 fs/xfs/linux-2.6/xfs_buf.c                      |    5
 fs/xfs/xfs_mru_cache.c                          |    2
 include/linux/ceph/messenger.h                  |    5
 net/9p/trans_fd.c                               |   52 +-----
 net/ceph/messenger.c                            |   46 -----
 net/rds/ib.c                                    |    9 -
 net/rds/ib.h                                    |    2
 net/rds/ib_rdma.c                               |   27 ---
 net/rxrpc/af_rxrpc.c                            |    2
 59 files changed, 270 insertions(+), 571 deletions(-)

--
tejun

author
#1 lore raw

PATCH 1/32 arm/omap: use system_wq in mailbox

With cmwq, there's no reason to use a separate workqueue for mailbox. Use the system_wq instead. mbox->rxq->work is sync flushed in omap_mbox_fini() to make sure it's not running on any cpu, which makes sure that no mbox work is running when omap_mbox_exit() is entered.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 arch/arm/plat-omap/mailbox.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/plat-omap/mailbox.c +2 -8
index d2fafb8..5bc4d7b 100644
@@ -31,7 +31,6 @@
 
 #include <plat/mailbox.h>
 
-static struct workqueue_struct *mboxd;
 static struct omap_mbox **mboxes;
 static bool rq_full;
 
@@ -186,7 +185,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 	/* no more messages in the fifo. clear IRQ source. */
 	ack_mbox_irq(mbox, IRQ_RX);
 nomem:
-	queue_work(mboxd, &mbox->rxq->work);
+	schedule_work(&mbox->rxq->work);
 }
 
 static irqreturn_t mbox_interrupt(int irq, void *p)
@@ -291,7 +290,7 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
 {
 	free_irq(mbox->irq, mbox);
 	tasklet_kill(&mbox->txq->tasklet);
-	flush_work(&mbox->rxq->work);
+	flush_work_sync(&mbox->rxq->work);
 	mbox_queue_free(mbox->txq);
 	mbox_queue_free(mbox->rxq);
 
@@ -385,10 +384,6 @@ static int __init omap_mbox_init(void)
 	if (err)
 		return err;
 
-	mboxd = create_workqueue("mboxd");
-	if (!mboxd)
-		return -ENOMEM;
-
 	/* kfifo size sanity check: alignment and minimal size */
 	mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
 	mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t));
@@ -399,7 +394,6 @@ subsys_initcall(omap_mbox_init);
 
 static void __exit omap_mbox_exit(void)
 {
-	destroy_workqueue(mboxd);
 	class_unregister(&omap_mbox_class);
 }
 module_exit(omap_mbox_exit);
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 01/32] arm/omap: use system_wq in mailbox

Tejun,

Quoted 11 lines · Tejun Heo

With cmwq, there's no reason to use a separate workqueue for mailbox. Use the system_wq instead.  mbox->rxq->work is sync flushed in omap_mbox_fini() to make sure it's not running on any cpu, which makes sure that no mbox work is running when omap_mbox_exit() is entered.

---
Only compile tested.  Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

This was changed to dedicated work queue because of performance issues when there is heavy mailbox traffic between the cores.

Reference:
http://www.mail-archive.com/[email protected]/msg24240.html

Quoted 63 lines

Thanks.

 arch/arm/plat-omap/mailbox.c |   10 ++--------

 1 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/plat-omap/mailbox.c +0 -1
index d2fafb8..5bc4d7b 100644
@@ -31,7 +31,6 @@
 
  #include <plat/mailbox.h>
 
-static struct workqueue_struct *mboxd;
  static struct omap_mbox **mboxes;
  static bool rq_full;
 
@@ -186,7 +185,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
        /* no more messages in the fifo. clear IRQ source. */
        ack_mbox_irq(mbox, IRQ_RX);

 nomem:
-       queue_work(mboxd, &mbox->rxq->work);
+       schedule_work(&mbox->rxq->work);
 }

 static irqreturn_t mbox_interrupt(int irq, void *p)

arch/arm/plat-omap/mailbox.c +1 -7
@@ -291,7 +290,7 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
  {
        free_irq(mbox->irq, mbox);
        tasklet_kill(&mbox->txq->tasklet);
-       flush_work(&mbox->rxq->work);
+       flush_work_sync(&mbox->rxq->work);
        mbox_queue_free(mbox->txq);
        mbox_queue_free(mbox->rxq);
 
@@ -385,10 +384,6 @@ static int __init omap_mbox_init(void)
        if (err)
                return err;
 
-       mboxd = create_workqueue("mboxd");
-       if (!mboxd)
-               return -ENOMEM;
-
        /* kfifo size sanity check: alignment and minimal size */
        mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
        mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t));
@@ -399,7 +394,6 @@ subsys_initcall(omap_mbox_init);
 
  static void __exit omap_mbox_exit(void)
  {
-       destroy_workqueue(mboxd);
        class_unregister(&omap_mbox_class);
  }
  module_exit(omap_mbox_exit);
--

1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Thank you,
Best regards,
Hari Kanigeri
author
#3 lore raw

Re: [PATCH 01/32] arm/omap: use system_wq in mailbox

Hello,

Quoted 5 lines · Hari

This was changed to dedicated work queue because of performance issues when there is heavy mailbox traffic between the cores.

Reference:
http://www.mail-archive.com/[email protected]/msg24240.html

Using dedicated workqueue or system_wq doesn't make any difference in terms of execution latency anymore. Sleeping work items no longer delay execution of other work items. If mailbox is very latency sensitive, it might make sense to create a HIGHPRI workqueue but that usually isn't necessary.

Thank you.

--
tejun

author
#4 lore raw

Re: [PATCH 01/32] arm/omap: use system_wq in mailbox

Quoted 5 lines · Tejun Heo

Using dedicated workqueue or system_wq doesn't make any difference in terms of execution latency anymore. Sleeping work items no longer delay execution of other work items. If mailbox is very latency sensitive, it might make sense to create a HIGHPRI workqueue but that usually isn't necessary.

Ping. Shall I apply the patch?

Thanks.

Signature · 1 line
tejun
#5 lore raw

Re: [PATCH 01/32] arm/omap: use system_wq in mailbox

Tejun,

Quoted 9 lines · Tejun Heo
Quoted 5 lines · Tejun Heo

Using dedicated workqueue or system_wq doesn't make any difference in terms of execution latency anymore.  Sleeping work items no longer delay execution of other work items.  If mailbox is very latency sensitive, it might make sense to create a HIGHPRI workqueue but that usually isn't necessary.

Ping.  Shall I apply the patch?

I am sorry for the delay in acking your response. Your patch looks good to me.

thank you,
best regards,
Hari
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#6 lore raw

Re: [PATCH 01/32] arm/omap: use system_wq in mailbox

Quoted 10 lines · Hari Kanigeri

Tejun,

Quoted 7 lines · Tejun Heo
Quoted 5 lines · Tejun Heo

Using dedicated workqueue or system_wq doesn't make any difference in terms of execution latency anymore.  Sleeping work items no longer delay execution of other work items.  If mailbox is very latency sensitive, it might make sense to create a HIGHPRI workqueue but that usually isn't necessary.

Quoted 3 lines
Quoted 2 lines

Ping.  Shall I apply the patch?

I am sorry for the delay in acking your response. Your patch looks good to me.

Thanks. Acked-by added.

Signature · 1 line
tejun
author
#7 lore raw

PATCH 2/32 powerpc/cell: use system_wq in cpufreq_spudemand

In reply to Tejun Heo

With cmwq, there's no reason to use a separate workqueue in cpufreq_spudemand. Use system_wq instead. The work items are already sync canceled on stop, so it's already guaranteed that no work is running when spu_gov_exit() is entered.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 arch/powerpc/platforms/cell/cpufreq_spudemand.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)
arch/powerpc/platforms/cell/cpufreq_spudemand.c +3 -17
index 968c1c0..d809836 100644
@@ -39,8 +39,6 @@ struct spu_gov_info_struct {
 };
 static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
 
-static struct workqueue_struct *kspugov_wq;
-
 static int calc_freq(struct spu_gov_info_struct *info)
 {
 	int cpu;
@@ -71,14 +69,14 @@ static void spu_gov_work(struct work_struct *work)
 	__cpufreq_driver_target(info->policy, target_freq, CPUFREQ_RELATION_H);
 
 	delay = usecs_to_jiffies(info->poll_int);
-	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+	schedule_delayed_work_on(info->policy->cpu, &info->work, delay);
 }
 
 static void spu_gov_init_work(struct spu_gov_info_struct *info)
 {
 	int delay = usecs_to_jiffies(info->poll_int);
 	INIT_DELAYED_WORK_DEFERRABLE(&info->work, spu_gov_work);
-	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+	schedule_delayed_work_on(info->policy->cpu, &info->work, delay);
 }
 
 static void spu_gov_cancel_work(struct spu_gov_info_struct *info)
@@ -152,27 +150,15 @@ static int __init spu_gov_init(void)
 {
 	int ret;
 
-	kspugov_wq = create_workqueue("kspugov");
-	if (!kspugov_wq) {
-		printk(KERN_ERR "creation of kspugov failed\n");
-		ret = -EFAULT;
-		goto out;
-	}
-
 	ret = cpufreq_register_governor(&spu_governor);
-	if (ret) {
+	if (ret)
 		printk(KERN_ERR "registration of governor failed\n");
-		destroy_workqueue(kspugov_wq);
-		goto out;
-	}
-out:
 	return ret;
 }
 
 static void __exit spu_gov_exit(void)
 {
 	cpufreq_unregister_governor(&spu_governor);
-	destroy_workqueue(kspugov_wq);
 }
 
 
Signature · 1 line
1.7.1
author
#8 lore raw

PATCH 3/32 block: make kblockd_workqueue smarter

In reply to Tejun Heo

kblockd is used for unplugging and may affect IO latency and throughput and the max number of concurrent work items are bound by the number of block devices. Make it HIGHPRI workqueue w/ default max concurrency.

---
Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 block/blk-core.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
block/blk-core.c +3 -1
index 4ce953f..909b84a 100644
@@ -2606,7 +2606,9 @@ int __init blk_dev_init(void)
 	BUILD_BUG_ON(__REQ_NR_BITS > 8 *
 			sizeof(((struct request *)0)->cmd_flags));
 
-	kblockd_workqueue = create_workqueue("kblockd");
+	/* used for unplugging and affects IO latency/throughput - HIGHPRI */
+	kblockd_workqueue = alloc_workqueue("kblockd",
+					    WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
 	if (!kblockd_workqueue)
 		panic("Failed to create kblockd\n");
 
Signature · 1 line
1.7.1
maintainer
#9 lore raw

Re: [PATCH 03/32] block: make kblockd_workqueue smarter

Quoted 4 lines · Tejun Heo

kblockd is used for unplugging and may affect IO latency and throughput and the max number of concurrent work items are bound by the number of block devices. Make it HIGHPRI workqueue w/ default max concurrency.

Thanks Tejun, I've pulled the two into the 2.6.38 tree.

Signature · 1 line
Jens Axboe
author
#10 lore raw

PATCH 4/32 bio-integrity: mark kintegrityd_wq highpri and CPU intensive

In reply to Tejun Heo

Work items processed by kintegrityd_wq won't block much, may burn a lot of CPU cycles and affect IO latency. Use alloc_workqueue() to mark it highpri and CPU intensive with max concurrency of 1.

Cc Jens Axboe <[email protected]>
Cc Martin K. Petersen <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/bio-integrity.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
fs/bio-integrity.c +6 -1
index 4d0ff5e..e49cce2 100644
@@ -782,7 +782,12 @@ void __init bio_integrity_init(void)
 {
 	unsigned int i;
 
-	kintegrityd_wq = create_workqueue("kintegrityd");
+	/*
+	 * kintegrityd won't block much but may burn a lot of CPU cycles.
+	 * Make it highpri CPU intensive wq with max concurrency of 1.
+	 */
+	kintegrityd_wq = alloc_workqueue("kintegrityd", WQ_MEM_RECLAIM |
+					 WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1);
 	if (!kintegrityd_wq)
 		panic("Failed to create kintegrityd\n");
 
Signature · 1 line
1.7.1
author
#11 lore raw

PATCH 5/32 crypto: mark crypto workqueues CPU_INTENSIVE

In reply to Tejun Heo

kcrypto_wq and pcrypt->wq's are used to run ciphers and may consume considerable amount of CPU cycles. Mark both as CPU_INTENSIVE so that they don't block other work items.

As the workqueues are primarily used to burn CPU cycles, concurrency levels shouldn't matter much and are left at 1. A higher value may be beneficial and needs investigation.

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 crypto/crypto_wq.c |    3 ++-
 crypto/pcrypt.c    |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
crypto/crypto_wq.c +2 -1
index fdcf624..b980ee1 100644
@@ -20,7 +20,8 @@ EXPORT_SYMBOL_GPL(kcrypto_wq);
 
 static int __init crypto_wq_init(void)
 {
-	kcrypto_wq = create_workqueue("crypto");
+	kcrypto_wq = alloc_workqueue("crypto",
+				     WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
 	if (unlikely(!kcrypto_wq))
 		return -ENOMEM;
 	return 0;
crypto/pcrypt.c +2 -1
index 75586f1..29a89da 100644
@@ -455,7 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
 
 	get_online_cpus();
 
-	pcrypt->wq = create_workqueue(name);
+	pcrypt->wq = alloc_workqueue(name,
+				     WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
 	if (!pcrypt->wq)
 		goto err;
 
Signature · 1 line
1.7.1
#12 lore raw

Re: [PATCH 05/32] crypto: mark crypto workqueues CPU_INTENSIVE

Quoted 4 lines · Tejun Heo

kcrypto_wq and pcrypt->wq's are used to run ciphers and may consume considerable amount of CPU cycles. Mark both as CPU_INTENSIVE so that they don't block other work items.

Quoted 8 lines

As the workqueues are primarily used to burn CPU cycles, concurrency levels shouldn't matter much and are left at 1. A higher value may be beneficial and needs investigation.

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>

Patch applied. Thanks!

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author
#13 lore raw

PATCH 6/32 acpi: kacpi*_wq don't need WQ_MEM_RECLAIM

In reply to Tejun Heo

ACPI workqueues aren't used during memory reclaming. Use alloc_workqueue() to create workqueues w/o rescuers.

If the purpose of the separation between kacpid_wq and kacpi_notify_wq was to give notifications better response time, kacpi_notify_wq can be dropped and kacpi_wq can be created with higher @max_active.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/acpi/osl.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/osl.c +3 -3
index 055d7b7..c961e18 100644
@@ -1573,9 +1573,9 @@ acpi_status __init acpi_os_initialize(void)
 
 acpi_status __init acpi_os_initialize1(void)
 {
-	kacpid_wq = create_workqueue("kacpid");
-	kacpi_notify_wq = create_workqueue("kacpi_notify");
-	kacpi_hotplug_wq = create_workqueue("kacpi_hotplug");
+	kacpid_wq = alloc_workqueue("kacpid", 0, 1);
+	kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
+	kacpi_hotplug_wq = alloc_workqueue("kacpi_hotplug", 0, 1);
 	BUG_ON(!kacpid_wq);
 	BUG_ON(!kacpi_notify_wq);
 	BUG_ON(!kacpi_hotplug_wq);
Signature · 1 line
1.7.1
author
#14 lore raw

PATCH 7/32 cpufreq: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason for cpufreq drivers to use separate workqueues. Remove the dedicated workqueues from cpufreq_conservative and cpufreq_ondemand and use system_wq instead. The work items are already sync canceled on stop, so it's already guaranteed that no work is running on module exit.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/cpufreq/cpufreq_conservative.c |   22 +++-------------------
 drivers/cpufreq/cpufreq_ondemand.c     |   20 +++-----------------
 2 files changed, 6 insertions(+), 36 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +3 -19
index 526bfbf..94284c8 100644
@@ -81,8 +81,6 @@ static unsigned int dbs_enable;	/* number of CPUs using this policy */
  */
 static DEFINE_MUTEX(dbs_mutex);
 
-static struct workqueue_struct	*kconservative_wq;
-
 static struct dbs_tuners {
 	unsigned int sampling_rate;
 	unsigned int sampling_down_factor;
@@ -560,7 +558,7 @@ static void do_dbs_timer(struct work_struct *work)
 
 	dbs_check_cpu(dbs_info);
 
-	queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay);
+	schedule_delayed_work_on(cpu, &dbs_info->work, delay);
 	mutex_unlock(&dbs_info->timer_mutex);
 }
 
@@ -572,8 +570,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
 
 	dbs_info->enable = 1;
 	INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
-	queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
-				delay);
+	schedule_delayed_work_on(dbs_info->cpu, &dbs_info->work, delay);
 }
 
 static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
@@ -716,25 +713,12 @@ struct cpufreq_governor cpufreq_gov_conservative = {
 
 static int __init cpufreq_gov_dbs_init(void)
 {
-	int err;
-
-	kconservative_wq = create_workqueue("kconservative");
-	if (!kconservative_wq) {
-		printk(KERN_ERR "Creation of kconservative failed\n");
-		return -EFAULT;
-	}
-
-	err = cpufreq_register_governor(&cpufreq_gov_conservative);
-	if (err)
-		destroy_workqueue(kconservative_wq);
-
-	return err;
+	return cpufreq_register_governor(&cpufreq_gov_conservative);
 }
 
 static void __exit cpufreq_gov_dbs_exit(void)
 {
 	cpufreq_unregister_governor(&cpufreq_gov_conservative);
-	destroy_workqueue(kconservative_wq);
 }
 
 
drivers/cpufreq/cpufreq_ondemand.c +3 -17
index c631f27..58aa85e 100644
@@ -104,8 +104,6 @@ static unsigned int dbs_enable;	/* number of CPUs using this policy */
  */
 static DEFINE_MUTEX(dbs_mutex);
 
-static struct workqueue_struct	*kondemand_wq;
-
 static struct dbs_tuners {
 	unsigned int sampling_rate;
 	unsigned int up_threshold;
@@ -667,7 +665,7 @@ static void do_dbs_timer(struct work_struct *work)
 		__cpufreq_driver_target(dbs_info->cur_policy,
 			dbs_info->freq_lo, CPUFREQ_RELATION_H);
 	}
-	queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
+	schedule_delayed_work_on(cpu, &dbs_info->work, delay);
 	mutex_unlock(&dbs_info->timer_mutex);
 }
 
@@ -681,8 +679,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
 
 	dbs_info->sample_type = DBS_NORMAL_SAMPLE;
 	INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
-	queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work,
-		delay);
+	schedule_delayed_work_on(dbs_info->cpu, &dbs_info->work, delay);
 }
 
 static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
@@ -814,7 +811,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
 
 static int __init cpufreq_gov_dbs_init(void)
 {
-	int err;
 	cputime64_t wall;
 	u64 idle_time;
 	int cpu = get_cpu();
@@ -838,22 +834,12 @@ static int __init cpufreq_gov_dbs_init(void)
 			MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
 	}
 
-	kondemand_wq = create_workqueue("kondemand");
-	if (!kondemand_wq) {
-		printk(KERN_ERR "Creation of kondemand failed\n");
-		return -EFAULT;
-	}
-	err = cpufreq_register_governor(&cpufreq_gov_ondemand);
-	if (err)
-		destroy_workqueue(kondemand_wq);
-
-	return err;
+	return cpufreq_register_governor(&cpufreq_gov_ondemand);
 }
 
 static void __exit cpufreq_gov_dbs_exit(void)
 {
 	cpufreq_unregister_governor(&cpufreq_gov_ondemand);
-	destroy_workqueue(kondemand_wq);
 }
 
 
Signature · 1 line
1.7.1
author
#15 lore raw

PATCH 8/32 drm/nouveau: use system_wq instead of dev_priv->wq

In reply to Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because nouveau_irq_uninstall() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from nouveau_load/unload().

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/gpu/drm/nouveau/nouveau_drv.h   |    1 -
 drivers/gpu/drm/nouveau/nouveau_irq.c   |    9 ---------
 drivers/gpu/drm/nouveau/nouveau_state.c |   19 ++++++++++---------
 drivers/gpu/drm/nouveau/nv50_display.c  |    4 ++--
 4 files changed, 12 insertions(+), 21 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -1
index 1c7db64..2ecf875 100644
@@ -580,7 +580,6 @@ struct drm_nouveau_private {
 
 	struct nouveau_bo *vga_ram;
 
-	struct workqueue_struct *wq;
 	struct work_struct irq_work;
 	struct work_struct hpd_work;
 
drivers/gpu/drm/nouveau/nouveau_irq.c +0 -9
index 7bfd9e6..7d05a06 100644
@@ -52,17 +52,8 @@ static int nouveau_ratelimit(void)
 void
 nouveau_irq_preinstall(struct drm_device *dev)
 {
-	struct drm_nouveau_private *dev_priv = dev->dev_private;
-
 	/* Master disable */
 	nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
-
-	if (dev_priv->card_type >= NV_50) {
-		INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
-		INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
-		spin_lock_init(&dev_priv->hpd_state.lock);
-		INIT_LIST_HEAD(&dev_priv->vbl_waiting);
-	}
 }
 
 int
drivers/gpu/drm/nouveau/nouveau_state.c +10 -9
index 049f755..2eea6ea 100644
@@ -839,17 +839,17 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 	dev->dev_private = dev_priv;
 	dev_priv->dev = dev;
 
+	/* the followings are used only by >= NV_50 */
+	INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
+	INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
+	spin_lock_init(&dev_priv->hpd_state.lock);
+	INIT_LIST_HEAD(&dev_priv->vbl_waiting);
+
 	dev_priv->flags = flags & NOUVEAU_FLAGS;
 
 	NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
 		 dev->pci_vendor, dev->pci_device, dev->pdev->class);
 
-	dev_priv->wq = create_workqueue("nouveau");
-	if (!dev_priv->wq) {
-		ret = -EINVAL;
-		goto err_priv;
-	}
-
 	/* resource 0 is mmio regs */
 	/* resource 1 is linear FB */
 	/* resource 2 is RAMIN (mmio regs + 0x1000000) */
@@ -862,7 +862,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 		NV_ERROR(dev, "Unable to initialize the mmio mapping. "
 			 "Please report your setup to " DRIVER_EMAIL "\n");
 		ret = -EINVAL;
-		goto err_wq;
+		goto err_priv;
 	}
 	NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
 					(unsigned long long)mmio_start_offs);
@@ -969,8 +969,6 @@ err_ramin:
 	iounmap(dev_priv->ramin);
 err_mmio:
 	iounmap(dev_priv->mmio);
-err_wq:
-	destroy_workqueue(dev_priv->wq);
 err_priv:
 	kfree(dev_priv);
 	dev->dev_private = NULL;
@@ -992,6 +990,9 @@ int nouveau_unload(struct drm_device *dev)
 	engine->display.destroy(dev);
 	nouveau_card_takedown(dev);
 
+	flush_work_sync(&dev_priv->irq_work);
+	flush_work_sync(&dev_priv->hpd_work);
+
 	iounmap(dev_priv->mmio);
 	iounmap(dev_priv->ramin);
 
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index f624c61..3d569da 100644
@@ -1110,7 +1110,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		dev_priv->hpd_state.hpd1_bits |= hpd1_bits;
 		spin_unlock(&dev_priv->hpd_state.lock);
 
-		queue_work(dev_priv->wq, &dev_priv->hpd_work);
+		schedule_work(&dev_priv->hpd_work);
 	}
 
 	while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
@@ -1139,7 +1139,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		if (clock) {
 			nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
 			if (!work_pending(&dev_priv->irq_work))
-				queue_work(dev_priv->wq, &dev_priv->irq_work);
+				schedule_work(&dev_priv->irq_work);
 			delayed |= clock;
 			intr1 &= ~clock;
 		}
Signature · 1 line
1.7.1
#16 lore raw

Re: [PATCH 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Quoted 6 lines · Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because nouveau_irq_uninstall() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from nouveau_load/unload().

Ehh, ok, why not! I'll push this through the nouveau tree, and it'll get to Dave from there.

Thanks!
Ben.

Quoted 128 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/gpu/drm/nouveau/nouveau_drv.h   |    1 -
 drivers/gpu/drm/nouveau/nouveau_irq.c   |    9 ---------
 drivers/gpu/drm/nouveau/nouveau_state.c |   19 ++++++++++---------
 drivers/gpu/drm/nouveau/nv50_display.c  |    4 ++--
 4 files changed, 12 insertions(+), 21 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -1
index 1c7db64..2ecf875 100644
@@ -580,7 +580,6 @@ struct drm_nouveau_private {
 
 	struct nouveau_bo *vga_ram;
 
-	struct workqueue_struct *wq;
 	struct work_struct irq_work;
 	struct work_struct hpd_work;
 
drivers/gpu/drm/nouveau/nouveau_irq.c +0 -9
index 7bfd9e6..7d05a06 100644
@@ -52,17 +52,8 @@ static int nouveau_ratelimit(void)
 void
 nouveau_irq_preinstall(struct drm_device *dev)
 {
-	struct drm_nouveau_private *dev_priv = dev->dev_private;
-
 	/* Master disable */
 	nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
-
-	if (dev_priv->card_type >= NV_50) {
-		INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
-		INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
-		spin_lock_init(&dev_priv->hpd_state.lock);
-		INIT_LIST_HEAD(&dev_priv->vbl_waiting);
-	}
 }
 
 int
drivers/gpu/drm/nouveau/nouveau_state.c +10 -9
index 049f755..2eea6ea 100644
@@ -839,17 +839,17 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 	dev->dev_private = dev_priv;
 	dev_priv->dev = dev;
 
+	/* the followings are used only by >= NV_50 */
+	INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
+	INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
+	spin_lock_init(&dev_priv->hpd_state.lock);
+	INIT_LIST_HEAD(&dev_priv->vbl_waiting);
+
 	dev_priv->flags = flags & NOUVEAU_FLAGS;
 
 	NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
 		 dev->pci_vendor, dev->pci_device, dev->pdev->class);
 
-	dev_priv->wq = create_workqueue("nouveau");
-	if (!dev_priv->wq) {
-		ret = -EINVAL;
-		goto err_priv;
-	}
-
 	/* resource 0 is mmio regs */
 	/* resource 1 is linear FB */
 	/* resource 2 is RAMIN (mmio regs + 0x1000000) */
@@ -862,7 +862,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 		NV_ERROR(dev, "Unable to initialize the mmio mapping. "
 			 "Please report your setup to " DRIVER_EMAIL "\n");
 		ret = -EINVAL;
-		goto err_wq;
+		goto err_priv;
 	}
 	NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
 					(unsigned long long)mmio_start_offs);
@@ -969,8 +969,6 @@ err_ramin:
 	iounmap(dev_priv->ramin);
 err_mmio:
 	iounmap(dev_priv->mmio);
-err_wq:
-	destroy_workqueue(dev_priv->wq);
 err_priv:
 	kfree(dev_priv);
 	dev->dev_private = NULL;
@@ -992,6 +990,9 @@ int nouveau_unload(struct drm_device *dev)
 	engine->display.destroy(dev);
 	nouveau_card_takedown(dev);
 
+	flush_work_sync(&dev_priv->irq_work);
+	flush_work_sync(&dev_priv->hpd_work);
+
 	iounmap(dev_priv->mmio);
 	iounmap(dev_priv->ramin);
 
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index f624c61..3d569da 100644
@@ -1110,7 +1110,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		dev_priv->hpd_state.hpd1_bits |= hpd1_bits;
 		spin_unlock(&dev_priv->hpd_state.lock);
 
-		queue_work(dev_priv->wq, &dev_priv->hpd_work);
+		schedule_work(&dev_priv->hpd_work);
 	}
 
 	while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
@@ -1139,7 +1139,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		if (clock) {
 			nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
 			if (!work_pending(&dev_priv->irq_work))
-				queue_work(dev_priv->wq, &dev_priv->irq_work);
+				schedule_work(&dev_priv->irq_work);
 			delayed |= clock;
 			intr1 &= ~clock;
 		}
#17 lore raw

Re: [PATCH 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Quoted 9 lines · Ben Skeggs
Quoted 6 lines · Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because nouveau_irq_uninstall() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from nouveau_load/unload().

Ehh, ok, why not! I'll push this through the nouveau tree, and it'll get to Dave from there.

On second thoughts, this won't apply on top of current nouveau code that's queued for 2.6.38. Can you rebase on top of Dave's drm-next tree please.

Ben.

Quoted 133 lines

Thanks!
Ben.

Quoted 128 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/gpu/drm/nouveau/nouveau_drv.h   |    1 -
 drivers/gpu/drm/nouveau/nouveau_irq.c   |    9 ---------
 drivers/gpu/drm/nouveau/nouveau_state.c |   19 ++++++++++---------
 drivers/gpu/drm/nouveau/nv50_display.c  |    4 ++--
 4 files changed, 12 insertions(+), 21 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -1
index 1c7db64..2ecf875 100644
@@ -580,7 +580,6 @@ struct drm_nouveau_private {
 
 	struct nouveau_bo *vga_ram;
 
-	struct workqueue_struct *wq;
 	struct work_struct irq_work;
 	struct work_struct hpd_work;
 
drivers/gpu/drm/nouveau/nouveau_irq.c +0 -9
index 7bfd9e6..7d05a06 100644
@@ -52,17 +52,8 @@ static int nouveau_ratelimit(void)
 void
 nouveau_irq_preinstall(struct drm_device *dev)
 {
-	struct drm_nouveau_private *dev_priv = dev->dev_private;
-
 	/* Master disable */
 	nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
-
-	if (dev_priv->card_type >= NV_50) {
-		INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
-		INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
-		spin_lock_init(&dev_priv->hpd_state.lock);
-		INIT_LIST_HEAD(&dev_priv->vbl_waiting);
-	}
 }
 
 int
drivers/gpu/drm/nouveau/nouveau_state.c +10 -9
index 049f755..2eea6ea 100644
@@ -839,17 +839,17 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 	dev->dev_private = dev_priv;
 	dev_priv->dev = dev;
 
+	/* the followings are used only by >= NV_50 */
+	INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
+	INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
+	spin_lock_init(&dev_priv->hpd_state.lock);
+	INIT_LIST_HEAD(&dev_priv->vbl_waiting);
+
 	dev_priv->flags = flags & NOUVEAU_FLAGS;
 
 	NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
 		 dev->pci_vendor, dev->pci_device, dev->pdev->class);
 
-	dev_priv->wq = create_workqueue("nouveau");
-	if (!dev_priv->wq) {
-		ret = -EINVAL;
-		goto err_priv;
-	}
-
 	/* resource 0 is mmio regs */
 	/* resource 1 is linear FB */
 	/* resource 2 is RAMIN (mmio regs + 0x1000000) */
@@ -862,7 +862,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
 		NV_ERROR(dev, "Unable to initialize the mmio mapping. "
 			 "Please report your setup to " DRIVER_EMAIL "\n");
 		ret = -EINVAL;
-		goto err_wq;
+		goto err_priv;
 	}
 	NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
 					(unsigned long long)mmio_start_offs);
@@ -969,8 +969,6 @@ err_ramin:
 	iounmap(dev_priv->ramin);
 err_mmio:
 	iounmap(dev_priv->mmio);
-err_wq:
-	destroy_workqueue(dev_priv->wq);
 err_priv:
 	kfree(dev_priv);
 	dev->dev_private = NULL;
@@ -992,6 +990,9 @@ int nouveau_unload(struct drm_device *dev)
 	engine->display.destroy(dev);
 	nouveau_card_takedown(dev);
 
+	flush_work_sync(&dev_priv->irq_work);
+	flush_work_sync(&dev_priv->hpd_work);
+
 	iounmap(dev_priv->mmio);
 	iounmap(dev_priv->ramin);
 
drivers/gpu/drm/nouveau/nv50_display.c +2 -2
index f624c61..3d569da 100644
@@ -1110,7 +1110,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		dev_priv->hpd_state.hpd1_bits |= hpd1_bits;
 		spin_unlock(&dev_priv->hpd_state.lock);
 
-		queue_work(dev_priv->wq, &dev_priv->hpd_work);
+		schedule_work(&dev_priv->hpd_work);
 	}
 
 	while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
@@ -1139,7 +1139,7 @@ nv50_display_irq_handler(struct drm_device *dev)
 		if (clock) {
 			nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
 			if (!work_pending(&dev_priv->irq_work))
-				queue_work(dev_priv->wq, &dev_priv->irq_work);
+				schedule_work(&dev_priv->irq_work);
 			delayed |= clock;
 			intr1 &= ~clock;
 		}
author
#18 lore raw

Re: [PATCH 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Hello,

Quoted 8 lines · Ben Skeggs
Quoted 7 lines · Ben Skeggs
Quoted 6 lines · Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because nouveau_irq_uninstall() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from nouveau_load/unload().

Quoted 6 lines
Quoted 2 lines

Ehh, ok, why not! I'll push this through the nouveau tree, and it'll get to Dave from there.

On second thoughts, this won't apply on top of current nouveau code that's queued for 2.6.38. Can you rebase on top of Dave's drm-next tree please.

We already missed this merge window, so I'll refresh the patch once the window is closed and resend.

Thank you.

Signature · 1 line
tejun
author
#19 lore raw

PATCH 8/32 drm/nouveau: use system_wq instead of dev_priv->wq

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead. Each work item is sync flushed when the containing structure is unregistered/destroyed.

Note that this change also makes sure that nv50_gpio_handler is not freed while the contained work item is still running.

---
Here's a patch on top of the current linus#master. It's much simpler than before. The only concern is that it adds flush_work_sync() call which might sleep to unregistration paths. AFAICS, this seems safe, right? If this looks okay to you, please feel free to route it through the drm tree.

Thank you.

 drivers/gpu/drm/nouveau/nouveau_drv.h   |    1 -
 drivers/gpu/drm/nouveau/nouveau_state.c |   10 +---------
 drivers/gpu/drm/nouveau/nv50_display.c  |    5 ++++-
 drivers/gpu/drm/nouveau/nv50_gpio.c     |   11 ++++++++---
 4 files changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drv.h +0 -1
Index: work/drivers/gpu/drm/nouveau/nouveau_drv.h
===================================================================
@@ -652,7 +652,6 @@ struct drm_nouveau_private {
 	/* interrupt handling */
 	void (*irq_handler[32])(struct drm_device *);
 	bool msi_enabled;
-	struct workqueue_struct *wq;
 	struct work_struct irq_work;
 
 	struct list_head vbl_waiting;
drivers/gpu/drm/nouveau/nouveau_state.c +1 -9
Index: work/drivers/gpu/drm/nouveau/nouveau_state.c
===================================================================
@@ -929,12 +929,6 @@ int nouveau_load(struct drm_device *dev,
 	NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
 		 dev->pci_vendor, dev->pci_device, dev->pdev->class);
 
-	dev_priv->wq = create_workqueue("nouveau");
-	if (!dev_priv->wq) {
-		ret = -EINVAL;
-		goto err_priv;
-	}
-
 	/* resource 0 is mmio regs */
 	/* resource 1 is linear FB */
 	/* resource 2 is RAMIN (mmio regs + 0x1000000) */
@@ -947,7 +941,7 @@ int nouveau_load(struct drm_device *dev,
 		NV_ERROR(dev, "Unable to initialize the mmio mapping. "
 			 "Please report your setup to " DRIVER_EMAIL "\n");
 		ret = -EINVAL;
-		goto err_wq;
+		goto err_priv;
 	}
 	NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
 					(unsigned long long)mmio_start_offs);
@@ -1054,8 +1048,6 @@ err_ramin:
 	iounmap(dev_priv->ramin);
 err_mmio:
 	iounmap(dev_priv->mmio);
-err_wq:
-	destroy_workqueue(dev_priv->wq);
 err_priv:
 	kfree(dev_priv);
 	dev->dev_private = NULL;
drivers/gpu/drm/nouveau/nv50_display.c +4 -1
Index: work/drivers/gpu/drm/nouveau/nv50_display.c
===================================================================
@@ -345,12 +345,15 @@ int nv50_display_create(struct drm_devic
 void
 nv50_display_destroy(struct drm_device *dev)
 {
+	struct drm_nouveau_private *dev_priv = dev->dev_private;
+
 	NV_DEBUG_KMS(dev, "\n");
 
 	drm_mode_config_cleanup(dev);
 
 	nv50_display_disable(dev);
 	nouveau_irq_unregister(dev, 26);
+	flush_work_sync(&dev_priv->irq_work);
 }
 
 static u16
@@ -836,7 +839,7 @@ nv50_display_isr(struct drm_device *dev)
 		if (clock) {
 			nv_wr32(dev, NV03_PMC_INTR_EN_0, 0);
 			if (!work_pending(&dev_priv->irq_work))
-				queue_work(dev_priv->wq, &dev_priv->irq_work);
+				schedule_work(&dev_priv->irq_work);
 			delayed |= clock;
 			intr1 &= ~clock;
 		}
drivers/gpu/drm/nouveau/nv50_gpio.c +8 -3
Index: work/drivers/gpu/drm/nouveau/nv50_gpio.c
===================================================================
@@ -137,6 +137,7 @@ nv50_gpio_irq_unregister(struct drm_devi
 	struct nv50_gpio_priv *priv = pgpio->priv;
 	struct nv50_gpio_handler *gpioh, *tmp;
 	struct dcb_gpio_entry *gpio;
+	LIST_HEAD(tofree);
 	unsigned long flags;
 
 	gpio = nouveau_bios_gpio_entry(dev, tag);
@@ -149,10 +150,14 @@ nv50_gpio_irq_unregister(struct drm_devi
 		    gpioh->handler != handler ||
 		    gpioh->data != data)
 			continue;
-		list_del(&gpioh->head);
-		kfree(gpioh);
+		list_move(&gpioh->head, &tofree);
 	}
 	spin_unlock_irqrestore(&priv->lock, flags);
+
+	list_for_each_entry_safe(gpioh, tmp, &tofree, head) {
+		flush_work_sync(&gpioh->work);
+		kfree(gpioh);
+	}
 }
 
 bool
@@ -293,7 +298,7 @@ nv50_gpio_isr(struct drm_device *dev)
 			continue;
 		gpioh->inhibit = true;
 
-		queue_work(dev_priv->wq, &gpioh->work);
+		schedule_work(&gpioh->work);
 	}
 	spin_unlock(&priv->lock);
 }
author
#20 lore raw

Re: [PATCH UPDATED 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Quoted 10 lines · Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead. Each work item is sync flushed when the containing structure is unregistered/destroyed.

Note that this change also makes sure that nv50_gpio_handler is not freed while the contained work item is still running.

Ping. Can you please put this through the drm tree?

Thank you.

Signature · 1 line
tejun
#21 lore raw

Re: [PATCH UPDATED 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Quoted 5 lines · Tejun Heo
Quoted 4 lines · Tejun Heo

With cmwq, there's no reason for nouveau to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead. Each work item is sync flushed when the containing structure is unregistered/destroyed.

Quoted 8 lines
Quoted 6 lines

Note that this change also makes sure that nv50_gpio_handler is not freed while the contained work item is still running.

Ping. Can you please put this through the drm tree?

Hey Tejun,

Thanks for this again. I've just made some changes to the nv50 display bottom half handling that these will conflict with, they'll hit the nouveau tree next week.

I'll push the still-relevant bits of your nouveau patch through the nouveau tree for the 2.6.39-rc1 merge window. That ok?

Thanks,
Ben.

Quoted 3 lines

Thank you.

author
#22 lore raw

Re: [PATCH UPDATED 08/32] drm/nouveau: use system_wq instead of dev_priv->wq

Hello,

Quoted 3 lines · Ben Skeggs

Thanks for this again. I've just made some changes to the nv50 display bottom half handling that these will conflict with, they'll hit the nouveau tree next week.

Eh, so it doesn't apply again? :-)

Quoted 2 lines

I'll push the still-relevant bits of your nouveau patch through the nouveau tree for the 2.6.39-rc1 merge window. That ok?

Yeah, sure, but if you tell me against which tree I should generate patch, I can also just redo the patch.

Thanks.

Signature · 1 line
tejun
author
#23 lore raw

PATCH 9/32 drm/radeon: use system_wq instead of dev_priv->wq

In reply to Tejun Heo

With cmwq, there's no reason for radeon to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because radeon_driver_irq_uninstall_kms() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from radeon_irq_kms_init/fini().

While at it, simplify canceling/flushing of rdev->pm.dynpm_idle_work. Always initialize and sync cancel instead of being unnecessarily smart about it.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/gpu/drm/radeon/evergreen.c      |    2 +-
 drivers/gpu/drm/radeon/r100.c           |    2 +-
 drivers/gpu/drm/radeon/r600.c           |    2 +-
 drivers/gpu/drm/radeon/radeon.h         |    1 -
 drivers/gpu/drm/radeon/radeon_device.c  |    6 ----
 drivers/gpu/drm/radeon/radeon_irq_kms.c |    5 ++-
 drivers/gpu/drm/radeon/radeon_pm.c      |   47 ++++++++++--------------------
 drivers/gpu/drm/radeon/rs600.c          |    2 +-
 8 files changed, 23 insertions(+), 44 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +1 -1
index 7b337c3..6540adb 100644
@@ -2516,7 +2516,7 @@ restart_ih:
 	if (wptr != rdev->ih.wptr)
 		goto restart_ih;
 	if (queue_hotplug)
-		queue_work(rdev->wq, &rdev->hotplug_work);
+		schedule_work(&rdev->hotplug_work);
 	rdev->ih.rptr = rptr;
 	WREG32(IH_RB_RPTR, rdev->ih.rptr);
 	spin_unlock_irqrestore(&rdev->ih.lock, flags);
drivers/gpu/drm/radeon/r100.c +1 -1
index 8e10aa9..1d15748 100644
@@ -622,7 +622,7 @@ int r100_irq_process(struct radeon_device *rdev)
 	/* reset gui idle ack.  the status bit is broken */
 	rdev->irq.gui_idle_acked = false;
 	if (queue_hotplug)
-		queue_work(rdev->wq, &rdev->hotplug_work);
+		schedule_work(&rdev->hotplug_work);
 	if (rdev->msi_enabled) {
 		switch (rdev->family) {
 		case CHIP_RS400:
drivers/gpu/drm/radeon/r600.c +1 -1
index 9c92db7..f927cd4 100644
@@ -3419,7 +3419,7 @@ restart_ih:
 	if (wptr != rdev->ih.wptr)
 		goto restart_ih;
 	if (queue_hotplug)
-		queue_work(rdev->wq, &rdev->hotplug_work);
+		schedule_work(&rdev->hotplug_work);
 	rdev->ih.rptr = rptr;
 	WREG32(IH_RB_RPTR, rdev->ih.rptr);
 	spin_unlock_irqrestore(&rdev->ih.lock, flags);
drivers/gpu/drm/radeon/radeon.h +0 -1
index 3a70957..ba233a8 100644
@@ -1095,7 +1095,6 @@ struct radeon_device {
 	struct r700_vram_scratch vram_scratch;
 	int msi_enabled; /* msi enabled */
 	struct r600_ih ih; /* r6/700 interrupt ring */
-	struct workqueue_struct *wq;
 	struct work_struct hotplug_work;
 	int num_crtc; /* number of crtcs */
 	struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
drivers/gpu/drm/radeon/radeon_device.c +0 -6
index 501966a..4bc0012 100644
@@ -704,11 +704,6 @@ int radeon_device_init(struct radeon_device *rdev,
 	init_waitqueue_head(&rdev->irq.vblank_queue);
 	init_waitqueue_head(&rdev->irq.idle_queue);
 
-	/* setup workqueue */
-	rdev->wq = create_workqueue("radeon");
-	if (rdev->wq == NULL)
-		return -ENOMEM;
-
 	/* Set asic functions */
 	r = radeon_asic_init(rdev);
 	if (r)
@@ -806,7 +801,6 @@ void radeon_device_fini(struct radeon_device *rdev)
 	/* evict vram memory */
 	radeon_bo_evict_vram(rdev);
 	radeon_fini(rdev);
-	destroy_workqueue(rdev->wq);
 	vga_switcheroo_unregister_client(rdev->pdev);
 	vga_client_register(rdev->pdev, NULL, NULL, NULL);
 	if (rdev->rio_mem)
drivers/gpu/drm/radeon/radeon_irq_kms.c +3 -2
index a108c7e..33b9d21 100644
@@ -64,8 +64,6 @@ void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
 	struct radeon_device *rdev = dev->dev_private;
 	unsigned i;
 
-	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
-
 	/* Disable *all* interrupts */
 	rdev->irq.sw_int = false;
 	rdev->irq.gui_idle = false;
@@ -110,6 +108,8 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
 {
 	int r = 0;
 
+	INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
+
 	spin_lock_init(&rdev->irq.sw_lock);
 	r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
 	if (r) {
@@ -148,6 +148,7 @@ void radeon_irq_kms_fini(struct radeon_device *rdev)
 		if (rdev->msi_enabled)
 			pci_disable_msi(rdev->pdev);
 	}
+	flush_work_sync(&rdev->hotplug_work);
 }
 
 void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev)
drivers/gpu/drm/radeon/radeon_pm.c +16 -31

121 lines not on this page · raw message

drivers/gpu/drm/radeon/rs600.c +1 -1
index f1c6e02..2d707d4 100644
@@ -634,7 +634,7 @@ int rs600_irq_process(struct radeon_device *rdev)
 	/* reset gui idle ack.  the status bit is broken */
 	rdev->irq.gui_idle_acked = false;
 	if (queue_hotplug)
-		queue_work(rdev->wq, &rdev->hotplug_work);
+		schedule_work(&rdev->hotplug_work);
 	if (rdev->msi_enabled) {
 		switch (rdev->family) {
 		case CHIP_RS600:
Signature · 1 line
1.7.1
Acked-by on v1 9/32
#24 lore raw

Re: [PATCH 09/32] drm/radeon: use system_wq instead of dev_priv->wq

Quoted 11 lines · Tejun Heo

With cmwq, there's no reason for radeon to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because radeon_driver_irq_uninstall_kms() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from radeon_irq_kms_init/fini().

While at it, simplify canceling/flushing of rdev->pm.dynpm_idle_work. Always initialize and sync cancel instead of being unnecessarily smart about it.

Quoted 6 lines

---
Only compile tested.  Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Patch looks good to me. I'm not sure what's the best way to send this upstream. I'm working on some irq changes in the same area now, so I'd prefer if we pushed it through Dave's tree, but I can handle it either way.

Alex

Quoted 272 lines

Thanks.

 drivers/gpu/drm/radeon/evergreen.c      |    2 +- drivers/gpu/drm/radeon/r100.c           |    2 +- drivers/gpu/drm/radeon/r600.c           |    2 +- drivers/gpu/drm/radeon/radeon.h         |    1 - drivers/gpu/drm/radeon/radeon_device.c  |    6 ---- drivers/gpu/drm/radeon/radeon_irq_kms.c |    5 ++- drivers/gpu/drm/radeon/radeon_pm.c      |   47 ++++++++++-------------------- drivers/gpu/drm/radeon/rs600.c          |    2 +-

 8 files changed, 23 insertions(+), 44 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +1 -1
index 7b337c3..6540adb 100644
@@ -2516,7 +2516,7 @@ restart_ih:
        if (wptr != rdev->ih.wptr)
                goto restart_ih;
        if (queue_hotplug)
-               queue_work(rdev->wq, &rdev->hotplug_work);
+               schedule_work(&rdev->hotplug_work);
        rdev->ih.rptr = rptr;
        WREG32(IH_RB_RPTR, rdev->ih.rptr);
        spin_unlock_irqrestore(&rdev->ih.lock, flags);
drivers/gpu/drm/radeon/r100.c +1 -1
index 8e10aa9..1d15748 100644
@@ -622,7 +622,7 @@ int r100_irq_process(struct radeon_device *rdev)
        /* reset gui idle ack.  the status bit is broken */
        rdev->irq.gui_idle_acked = false;
        if (queue_hotplug)
-               queue_work(rdev->wq, &rdev->hotplug_work);
+               schedule_work(&rdev->hotplug_work);
        if (rdev->msi_enabled) {
                switch (rdev->family) {

               case CHIP_RS400:

drivers/gpu/drm/radeon/r600.c +1 -1
index 9c92db7..f927cd4 100644
@@ -3419,7 +3419,7 @@ restart_ih:
        if (wptr != rdev->ih.wptr)
                goto restart_ih;
        if (queue_hotplug)
-               queue_work(rdev->wq, &rdev->hotplug_work);
+               schedule_work(&rdev->hotplug_work);
        rdev->ih.rptr = rptr;
        WREG32(IH_RB_RPTR, rdev->ih.rptr);
        spin_unlock_irqrestore(&rdev->ih.lock, flags);
drivers/gpu/drm/radeon/radeon.h +0 -0
index 3a70957..ba233a8 100644
@@ -1095,7 +1095,6 @@ struct radeon_device {
        struct r700_vram_scratch vram_scratch;

       int msi_enabled; /* msi enabled */
       struct r600_ih ih; /* r6/700 interrupt ring */
-       struct workqueue_struct *wq;
       struct work_struct hotplug_work;
       int num_crtc; /* number of crtcs */
       struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */

drivers/gpu/drm/radeon/radeon_device.c +0 -6
index 501966a..4bc0012 100644
@@ -704,11 +704,6 @@ int radeon_device_init(struct radeon_device *rdev,
        init_waitqueue_head(&rdev->irq.vblank_queue);
        init_waitqueue_head(&rdev->irq.idle_queue);
 
-       /* setup workqueue */
-       rdev->wq = create_workqueue("radeon");
-       if (rdev->wq == NULL)
-               return -ENOMEM;
-
        /* Set asic functions */
        r = radeon_asic_init(rdev);
        if (r)
@@ -806,7 +801,6 @@ void radeon_device_fini(struct radeon_device *rdev)
        /* evict vram memory */
        radeon_bo_evict_vram(rdev);
        radeon_fini(rdev);
-       destroy_workqueue(rdev->wq);
        vga_switcheroo_unregister_client(rdev->pdev);
        vga_client_register(rdev->pdev, NULL, NULL, NULL);
        if (rdev->rio_mem)
drivers/gpu/drm/radeon/radeon_irq_kms.c +3 -2
index a108c7e..33b9d21 100644
@@ -64,8 +64,6 @@ void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
        struct radeon_device *rdev = dev->dev_private;
        unsigned i;
 
-       INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
-
        /* Disable *all* interrupts */
        rdev->irq.sw_int = false;
        rdev->irq.gui_idle = false;
@@ -110,6 +108,8 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
  {
        int r = 0;
 
+       INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
+
        spin_lock_init(&rdev->irq.sw_lock);
        r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
        if (r) {
@@ -148,6 +148,7 @@ void radeon_irq_kms_fini(struct radeon_device *rdev)
                if (rdev->msi_enabled)
                        pci_disable_msi(rdev->pdev);
        }
+       flush_work_sync(&rdev->hotplug_work);
  }
 
  void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev)
drivers/gpu/drm/radeon/radeon_pm.c +3 -14
index 8c9b2ef..845f295 100644
@@ -405,20 +405,13 @@ static ssize_t radeon_set_pm_method(struct device *dev,
                rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
                mutex_unlock(&rdev->pm.mutex);
        } else if (strncmp("profile", buf, strlen("profile")) == 0) {
-               bool flush_wq = false;
-
                mutex_lock(&rdev->pm.mutex);
-               if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
-                       cancel_delayed_work(&rdev->pm.dynpm_idle_work);
-                       flush_wq = true;
-               }
                /* disable dynpm */
                rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
                rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE;
                rdev->pm.pm_method = PM_METHOD_PROFILE;
                mutex_unlock(&rdev->pm.mutex);
-               if (flush_wq)
-                       flush_workqueue(rdev->wq);
+               cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
        } else {
                DRM_ERROR("invalid power method!\n");
                goto fail;
@@ -520,18 +513,14 @@ static void radeon_hwmon_fini(struct radeon_device *rdev)
 
  void radeon_pm_suspend(struct radeon_device *rdev)
  {
-       bool flush_wq = false;
-
        mutex_lock(&rdev->pm.mutex);
        if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
-               cancel_delayed_work(&rdev->pm.dynpm_idle_work);
                if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE)
                        rdev->pm.dynpm_state = DYNPM_STATE_SUSPENDED;
-               flush_wq = true;
        }
        mutex_unlock(&rdev->pm.mutex);
-       if (flush_wq)
-               flush_workqueue(rdev->wq);
+
+       cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
  }
 
  void radeon_pm_resume(struct radeon_device *rdev)
@@ -546,8 +535,8 @@ void radeon_pm_resume(struct radeon_device *rdev)

       if (rdev->pm.pm_method == PM_METHOD_DYNPM
           && rdev->pm.dynpm_state == DYNPM_STATE_SUSPENDED) { rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE;
-               queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
-                                       msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
+               schedule_delayed_work(&rdev->pm.dynpm_idle_work,
+                                     msecs_to_jiffies(RADEON_IDLE_LOOP_MS)); }
       mutex_unlock(&rdev->pm.mutex); radeon_pm_compute_clocks(rdev);

drivers/gpu/drm/radeon/radeon_pm.c +11 -15
@@ -581,6 +570,9 @@ int radeon_pm_init(struct radeon_device *rdev)
        ret = radeon_hwmon_init(rdev);
        if (ret)
                return ret;
+
+       INIT_DELAYED_WORK(&rdev->pm.dynpm_idle_work, radeon_dynpm_idle_work_handler);
+
        if (rdev->pm.num_power_states > 1) {
                /* where's the best place to put these? */
                ret = device_create_file(rdev->dev, &dev_attr_power_profile);
@@ -594,8 +586,6 @@ int radeon_pm_init(struct radeon_device *rdev)
                rdev->acpi_nb.notifier_call = radeon_acpi_event;
                register_acpi_notifier(&rdev->acpi_nb);
  #endif
-               INIT_DELAYED_WORK(&rdev->pm.dynpm_idle_work, radeon_dynpm_idle_work_handler);
-
                if (radeon_debugfs_pm_init(rdev)) {
                        DRM_ERROR("Failed to register debugfs file for PM!\n");
                }
@@ -609,25 +599,20 @@ int radeon_pm_init(struct radeon_device *rdev)
  void radeon_pm_fini(struct radeon_device *rdev)
  {
        if (rdev->pm.num_power_states > 1) {
-               bool flush_wq = false;
-
                mutex_lock(&rdev->pm.mutex);
                if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
                        rdev->pm.profile = PM_PROFILE_DEFAULT;
                        radeon_pm_update_profile(rdev);
                        radeon_pm_set_clocks(rdev);
                } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) {
-                       /* cancel work */
-                       cancel_delayed_work(&rdev->pm.dynpm_idle_work);
-                       flush_wq = true;
                        /* reset default clocks */
                        rdev->pm.dynpm_state = DYNPM_STATE_DISABLED;
                        rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT;
                        radeon_pm_set_clocks(rdev);
                }
                mutex_unlock(&rdev->pm.mutex);
-               if (flush_wq)
-                       flush_workqueue(rdev->wq);
+
+               cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work);
 
                device_remove_file(rdev->dev, &dev_attr_power_profile);
                device_remove_file(rdev->dev, &dev_attr_power_method);
@@ -686,12 +671,12 @@ void radeon_pm_compute_clocks(struct radeon_device *rdev)
                                        radeon_pm_get_dynpm_state(rdev);
                                        radeon_pm_set_clocks(rdev);
 
-                                       queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
-                                                          msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
+                                       schedule_delayed_work(&rdev->pm.dynpm_idle_work,
+                                                             msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
                                } else if (rdev->pm.dynpm_state == DYNPM_STATE_PAUSED) {
                                        rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE;
-                                       queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
-                                                          msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
+                                       schedule_delayed_work(&rdev->pm.dynpm_idle_work,
+                                                             msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
                                        DRM_DEBUG_DRIVER("radeon: dynamic power management activated\n");
                                }
                        } else { /* count == 0 */
@@ -796,8 +781,8 @@ static void radeon_dynpm_idle_work_handler(struct work_struct *work)
                        radeon_pm_set_clocks(rdev);
                }
 
-               queue_delayed_work(rdev->wq, &rdev->pm.dynpm_idle_work,
-                                       msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
+               schedule_delayed_work(&rdev->pm.dynpm_idle_work,
+                                     msecs_to_jiffies(RADEON_IDLE_LOOP_MS));
        }
        mutex_unlock(&rdev->pm.mutex);
        ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
drivers/gpu/drm/radeon/rs600.c +1 -1
index f1c6e02..2d707d4 100644
@@ -634,7 +634,7 @@ int rs600_irq_process(struct radeon_device *rdev)
        /* reset gui idle ack.  the status bit is broken */
        rdev->irq.gui_idle_acked = false;
        if (queue_hotplug)
-               queue_work(rdev->wq, &rdev->hotplug_work);
+               schedule_work(&rdev->hotplug_work);
        if (rdev->msi_enabled) {
                switch (rdev->family) {

               case CHIP_RS600:
--
1.7.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#25 lore raw

Re: [PATCH 09/32] drm/radeon: use system_wq instead of dev_priv->wq

Quoted 19 lines · Alex Deucher
Quoted 11 lines · Tejun Heo

With cmwq, there's no reason for radeon to use a dedicated workqueue. Drop dev_priv->wq and use system_wq instead.

Because radeon_driver_irq_uninstall_kms() may be called from unsleepable context, the work items can't be flushed from there. Instead, init and flush from radeon_irq_kms_init/fini().

While at it, simplify canceling/flushing of rdev->pm.dynpm_idle_work. Always initialize and sync cancel instead of being unnecessarily smart about it.

Quoted 6 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Quoted 4 lines

Patch looks good to me. I'm not sure what's the best way to send this upstream. I'm working on some irq changes in the same area now, so I'd prefer if we pushed it through Dave's tree, but I can handle it either way.

I'll pull it into my tree for merging to Linus.

Dave.

Quoted 3 lines
author
#26 lore raw

PATCH 10/32 input/tps6507x-ts: use system_wq instead of dedicated workqueue

In reply to Tejun Heo

With cmwq, there's no reason to use a separate workqueue. Drop tps6507x_ts->wq and use system_wq instead.

Cc Dmitry Torokhov <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Todd Fischer <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/input/touchscreen/tps6507x-ts.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/input/touchscreen/tps6507x-ts.c +4 -8
index c8c136c..4303149 100644
@@ -43,7 +43,6 @@ struct tps6507x_ts {
 	struct input_dev	*input_dev;
 	struct device		*dev;
 	char			phys[32];
-	struct workqueue_struct *wq;
 	struct delayed_work	work;
 	unsigned		polling;	/* polling is active */
 	struct ts_event		tc;
@@ -220,8 +219,8 @@ done:
 	poll = 1;
 
 	if (poll) {
-		schd = queue_delayed_work(tsc->wq, &tsc->work,
-					  msecs_to_jiffies(tsc->poll_period));
+		schd = schedule_delayed_work(&tsc->work,
+					msecs_to_jiffies(tsc->poll_period));
 		if (schd)
 			tsc->polling = 1;
 		else {
@@ -303,7 +302,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 	tsc->input_dev = input_dev;
 
 	INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler);
-	tsc->wq = create_workqueue("TPS6507x Touchscreen");
 
 	if (init_data) {
 		tsc->poll_period = init_data->poll_period;
@@ -325,8 +323,8 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 	if (error)
 		goto err2;
 
-	schd = queue_delayed_work(tsc->wq, &tsc->work,
-				  msecs_to_jiffies(tsc->poll_period));
+	schd = schedule_delayed_work(&tsc->work,
+				     msecs_to_jiffies(tsc->poll_period));
 
 	if (schd)
 		tsc->polling = 1;
@@ -341,7 +339,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 
 err2:
 	cancel_delayed_work_sync(&tsc->work);
-	destroy_workqueue(tsc->wq);
 	input_free_device(input_dev);
 err1:
 	kfree(tsc);
@@ -357,7 +354,6 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
 	struct input_dev *input_dev = tsc->input_dev;
 
 	cancel_delayed_work_sync(&tsc->work);
-	destroy_workqueue(tsc->wq);
 
 	input_unregister_device(input_dev);
 
Signature · 1 line
1.7.1
#27 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Quoted 12 lines · Tejun Heo

With cmwq, there's no reason to use a separate workqueue. Drop tps6507x_ts->wq and use system_wq instead.

Cc Dmitry Torokhov <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Todd Fischer <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

This is that driver that polls every 30 ms. :/ Todd, is there no way to avoid this? What was the status on that?

regards,
dan carpenter

#28 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Hi Dan,

Polling is only necessary because I was given brain dead hardware. I was expecting updated hardware with the interrupt signal connected properly, but haven't received it yet.

Any reasonable hardware will not need tps6507x-ts polling. I was under the impression I could only push patches that I have tested. Since I haven't tested an interrupt version of the driver, I didn't include a patch that removes the polling and replaces it with interrupts.

I have another customer planning on using the TPS6507x chip for touch screen. I expect their hardware in around 3 weeks.

Todd

Quoted 20 lines · Dan Carpenter
Quoted 12 lines · Tejun Heo

With cmwq, there's no reason to use a separate workqueue. Drop tps6507x_ts->wq and use system_wq instead.

Cc Dmitry Torokhov<[email protected]>
Cc Dan Carpenter<[email protected]>
Cc Todd Fischer<[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

This is that driver that polls every 30 ms. :/ Todd, is there no way to avoid this? What was the status on that?

regards,
dan carpenter

author
#29 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Quoted 6 lines · Todd Fischer

Hi Dan,

Polling is only necessary because I was given brain dead hardware. I was expecting updated hardware with the interrupt signal connected properly, but haven't received it yet.

Quoted 8 lines

Any reasonable hardware will not need tps6507x-ts polling. I was under the impression I could only push patches that I have tested. Since I haven't tested an interrupt version of the driver, I didn't include a patch that removes the polling and replaces it with interrupts.

I have another customer planning on using the TPS6507x chip for touch screen. I expect their hardware in around 3 weeks.

Shall I apply the patch?

Thanks.

Signature · 1 line
tejun
#30 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Quoted 2 lines · Tejun Heo

Shall I apply the patch?
Thanks

Yes, apply the patch. I am not sure of the syntax for attaching my sign off. Hope this is okay.

Todd

maintainer
#31 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Quoted 10 lines · Todd Fischer
Quoted 2 lines · Tejun Heo

Shall I apply the patch?
Thanks

Yes, apply the patch. I am not sure of the syntax for attaching my sign off. Hope this is okay.

Todd

That should be Acked-by since you are not passing the patch along.

Fine with the as well.

Thanks.

Signature · 1 line
Dmitry
author
#32 lore raw

Re: [PATCH 10/32] input/tps6507x-ts: use system_wq instead of dedicated workqueue

Quoted 7 lines · Dmitry Torokhov
Quoted 6 lines · Todd Fischer
Quoted 2 lines · Tejun Heo

Shall I apply the patch?
Thanks

Yes, apply the patch. I am not sure of the syntax for attaching my sign off. Hope this is okay.

Quoted 6 lines
Quoted 4 lines

Todd

That should be Acked-by since you are not passing the patch along.

Added ack-by's of Todd and you. Thank you.

Signature · 1 line
tejun
author
#33 lore raw

PATCH 11/32 v4l/cx18: update workqueue usage

In reply to Tejun Heo

With cmwq, there's no reason to use separate out_work_queue. Drop it and use system_wq instead. The in_work_queue needs to be ordered so can't use one of the system wqs; however, as it isn't used to reclaim memory, allocate the workqueue with alloc_ordered_workqueue() without WQ_MEM_RECLAIM.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/media/video/cx18/cx18-driver.c  |   24 ++----------------------
 drivers/media/video/cx18/cx18-driver.h  |    3 ---
 drivers/media/video/cx18/cx18-streams.h |    3 +--
 3 files changed, 3 insertions(+), 27 deletions(-)
drivers/media/video/cx18/cx18-driver.c +2 -22
index df60f27..41c0822 100644
@@ -656,7 +656,7 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 {
 	snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
 		 cx->v4l2_dev.name);
-	cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name);
+	cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0);
 	if (cx->in_work_queue == NULL) {
 		CX18_ERR("Unable to create incoming mailbox handler thread\n");
 		return -ENOMEM;
@@ -664,18 +664,6 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 	return 0;
 }
 
-static int __devinit cx18_create_out_workq(struct cx18 *cx)
-{
-	snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out",
-		 cx->v4l2_dev.name);
-	cx->out_work_queue = create_workqueue(cx->out_workq_name);
-	if (cx->out_work_queue == NULL) {
-		CX18_ERR("Unable to create outgoing mailbox handler threads\n");
-		return -ENOMEM;
-	}
-	return 0;
-}
-
 static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
 {
 	int i;
@@ -702,15 +690,9 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
 	mutex_init(&cx->epu2apu_mb_lock);
 	mutex_init(&cx->epu2cpu_mb_lock);
 
-	ret = cx18_create_out_workq(cx);
-	if (ret)
-		return ret;
-
 	ret = cx18_create_in_workq(cx);
-	if (ret) {
-		destroy_workqueue(cx->out_work_queue);
+	if (ret)
 		return ret;
-	}
 
 	cx18_init_in_work_orders(cx);
 
@@ -1094,7 +1076,6 @@ free_mem:
 	release_mem_region(cx->base_addr, CX18_MEM_SIZE);
 free_workqueues:
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 err:
 	if (retval == 0)
 		retval = -ENODEV;
@@ -1244,7 +1225,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
 	cx18_halt_firmware(cx);
 
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 
 	cx18_streams_cleanup(cx, 1);
 
drivers/media/video/cx18/cx18-driver.h +0 -3
index 77be58c..f7f71d1 100644
@@ -614,9 +614,6 @@ struct cx18 {
 	struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS];
 	char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
 
-	struct workqueue_struct *out_work_queue;
-	char out_workq_name[12]; /* "cx18-NN-out" */
-
 	/* i2c */
 	struct i2c_adapter i2c_adap[2];
 	struct i2c_algo_bit_data i2c_algo[2];
drivers/media/video/cx18/cx18-streams.h +1 -2
index 77412be..5837ffb 100644
@@ -41,8 +41,7 @@ static inline bool cx18_stream_enabled(struct cx18_stream *s)
 /* Related to submission of mdls to firmware */
 static inline void cx18_stream_load_fw_queue(struct cx18_stream *s)
 {
-	struct cx18 *cx = s->cx;
-	queue_work(cx->out_work_queue, &s->out_work_order);
+	schedule_work(&s->out_work_order);
 }
 
 static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s,
Signature · 1 line
1.7.1
#34 lore raw

Re: [PATCH 11/32] v4l/cx18: update workqueue usage

Quoted 9 lines · Tejun Heo

With cmwq, there's no reason to use separate out_work_queue. Drop it and use system_wq instead. The in_work_queue needs to be ordered so can't use one of the system wqs; however, as it isn't used to reclaim memory, allocate the workqueue with alloc_ordered_workqueue() without WQ_MEM_RECLAIM.

Tejun,

I have a question about cmwq, but to ask it, I need to give the context.

The non-system out_work_queue in cx18 had two purposes:

1. To prevent a userspace video rendering application from sleeping in read(), when it had emptied a cx18 driver DMA buffer and the cx18 driver had to sleep to notify the CX2318 engine that the buffer was available again.

Your change has no adverse effect on this.

2. To prevent work items being handled by keventd/n from being delayed too long, as the deferred work in question can involve a bit of sleeping due to contention, the workload of the CX23418's MPEG encoding engine, and the number of CX23418 devices in the system.

Will all the sleeping that can happen, is the move to a system wq, under cmwq, going to have adverse affects on processing other work items in the system?

I get the feeling it won't be a problem with cmwq, but I haven't paid enough attention to be sure.

Here are some gory details, if it helps:

A single CX23418 has *one* cx18 driver to CX23418 Capture Processing Unit (epu2cpu_mb) mailbox though which the cx18 driver sends all normal commands along with a notification interrupt to the CX23418.

The CX23418 will acknowledge all commands with ack back in the mailbox and an interrupt for the cx18 driver. Sometimes the ack happens right away. Sometimes the cx18 driver has to wait(), if the CX23418 is busy.

The cx18 driver uses a mutex (epu2cpu_mb_lock) to protect cx18 driver access to the one epu2cpu_mb mailbox. The mutex is grabbed and released on a per epu2cpu_mb mailbox command basis

To tell the CX23418 about a usable empty buffer for DMA, one epu2cpu mailbox command (CX18_CPU_DE_SET_MDL) must be performed for each usable empty buffer.

A CX23418 can support multiple, simultaneous logical capture streams at once. The streams for a DVB TS, analog video converted to MPEG, VBI data, and the MPEG Index data are common to have active simultaneously.

The CX23418 can keep track of 63 empty buffers for each active stream and the cx18 driver tries to ensure the CX23418 always has as close to 63 as possible available at any time.

The out_work_handler, when triggered for a capture stream type, will try to perform, as needed, from 1 to 63 CX18_CPU_DE_SET_MDL mailbox commands for that stream. At steady state, the number of CX18_CPU_DE_SET_MDL mailbox commands executed one after the other in a batch will likely be from 1 to 3.

It is not unusual for a non-commercial end user to have 2 or 3 CX23418 based capture cards in one machine. I am aware of at least one commercial user that had 5 CX23418 based cards in a modest machine.

It is not unusual for scheduled TV recording software to start nearly simultaneous DTV TS, MPEG, and VBI or MPEG Index streams on multiple
cards. So 3 CX23418 cards with 3 streams each. Let's nominally
estimate the timing of the CX18_CPU_DE_SET_MDL commands per stream at the PAL frame rate of 25 Hz; or 1 CX18_CPU_DE_SET_MDL mailbox command per stream per 40 milliseconds.

Regards,
Andy

Quoted 104 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/media/video/cx18/cx18-driver.c  |   24 ++----------------------
 drivers/media/video/cx18/cx18-driver.h  |    3 ---
 drivers/media/video/cx18/cx18-streams.h |    3 +--
 3 files changed, 3 insertions(+), 27 deletions(-)
drivers/media/video/cx18/cx18-driver.c +2 -22
index df60f27..41c0822 100644
@@ -656,7 +656,7 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 {
 	snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
 		 cx->v4l2_dev.name);
-	cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name);
+	cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0);
 	if (cx->in_work_queue == NULL) {
 		CX18_ERR("Unable to create incoming mailbox handler thread\n");
 		return -ENOMEM;
@@ -664,18 +664,6 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 	return 0;
 }
 
-static int __devinit cx18_create_out_workq(struct cx18 *cx)
-{
-	snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out",
-		 cx->v4l2_dev.name);
-	cx->out_work_queue = create_workqueue(cx->out_workq_name);
-	if (cx->out_work_queue == NULL) {
-		CX18_ERR("Unable to create outgoing mailbox handler threads\n");
-		return -ENOMEM;
-	}
-	return 0;
-}
-
 static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
 {
 	int i;
@@ -702,15 +690,9 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
 	mutex_init(&cx->epu2apu_mb_lock);
 	mutex_init(&cx->epu2cpu_mb_lock);
 
-	ret = cx18_create_out_workq(cx);
-	if (ret)
-		return ret;
-
 	ret = cx18_create_in_workq(cx);
-	if (ret) {
-		destroy_workqueue(cx->out_work_queue);
+	if (ret)
 		return ret;
-	}
 
 	cx18_init_in_work_orders(cx);
 
@@ -1094,7 +1076,6 @@ free_mem:
 	release_mem_region(cx->base_addr, CX18_MEM_SIZE);
 free_workqueues:
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 err:
 	if (retval == 0)
 		retval = -ENODEV;
@@ -1244,7 +1225,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
 	cx18_halt_firmware(cx);
 
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 
 	cx18_streams_cleanup(cx, 1);
 
drivers/media/video/cx18/cx18-driver.h +0 -3
index 77be58c..f7f71d1 100644
@@ -614,9 +614,6 @@ struct cx18 {
 	struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS];
 	char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
 
-	struct workqueue_struct *out_work_queue;
-	char out_workq_name[12]; /* "cx18-NN-out" */
-
 	/* i2c */
 	struct i2c_adapter i2c_adap[2];
 	struct i2c_algo_bit_data i2c_algo[2];
drivers/media/video/cx18/cx18-streams.h +1 -2
index 77412be..5837ffb 100644
@@ -41,8 +41,7 @@ static inline bool cx18_stream_enabled(struct cx18_stream *s)
 /* Related to submission of mdls to firmware */
 static inline void cx18_stream_load_fw_queue(struct cx18_stream *s)
 {
-	struct cx18 *cx = s->cx;
-	queue_work(cx->out_work_queue, &s->out_work_order);
+	schedule_work(&s->out_work_order);
 }
 
 static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s,
author
#35 lore raw

Re: [PATCH 11/32] v4l/cx18: update workqueue usage

Hello,

Quoted 11 lines · Andy Walls

2. To prevent work items being handled by keventd/n from being delayed too long, as the deferred work in question can involve a bit of sleeping due to contention, the workload of the CX23418's MPEG encoding engine, and the number of CX23418 devices in the system.

Will all the sleeping that can happen, is the move to a system wq, under cmwq, going to have adverse affects on processing other work items in the system?

I get the feeling it won't be a problem with cmwq, but I haven't paid enough attention to be sure.

It won't be a problem. Now the system_wq supports parallel execution of multiple works and manages concurrency automatically. Work items can sleep as necessary without worrying about other work items.

...

Quoted 6 lines

It is not unusual for scheduled TV recording software to start nearly simultaneous DTV TS, MPEG, and VBI or MPEG Index streams on multiple
cards. So 3 CX23418 cards with 3 streams each. Let's nominally
estimate the timing of the CX18_CPU_DE_SET_MDL commands per stream at the PAL frame rate of 25 Hz; or 1 CX18_CPU_DE_SET_MDL mailbox command per stream per 40 milliseconds.

IIUC, if they spend any significant amount of time executing, they'll be doing so by waiting for events (mutex, IRQ...), right? If so, there's nothing to worry about. If it's gonna burn a lot of CPU cycles, we'll need to use a workqueue marked CPU_INTENSIVE but I don't think that's the case here.

Thank you.

Signature · 1 line
tejun
#36 lore raw

Re: [PATCH 11/32] v4l/cx18: update workqueue usage

Quoted 12 lines · Tejun Heo

Hello,

Quoted 9 lines · Andy Walls

2. To prevent work items being handled by keventd/n from being delayed too long, as the deferred work in question can involve a bit of sleeping due to contention, the workload of the CX23418's MPEG encoding engine, and the number of CX23418 devices in the system.

Will all the sleeping that can happen, is the move to a system wq, under cmwq, going to have adverse affects on processing other work items in the system?

Quoted 6 lines
Quoted 2 lines

I get the feeling it won't be a problem with cmwq, but I haven't paid enough attention to be sure.

It won't be a problem. Now the system_wq supports parallel execution of multiple works and manages concurrency automatically. Work items can sleep as necessary without worrying about other work items.

OK, that's what I thought. I just wanted to ensure that busy CX23418 chips are not going to delay the processing of other work-events in the rest the system down.

Quoted 10 lines

...

Quoted 6 lines

It is not unusual for scheduled TV recording software to start nearly simultaneous DTV TS, MPEG, and VBI or MPEG Index streams on multiple
cards. So 3 CX23418 cards with 3 streams each. Let's nominally
estimate the timing of the CX18_CPU_DE_SET_MDL commands per stream at the PAL frame rate of 25 Hz; or 1 CX18_CPU_DE_SET_MDL mailbox command per stream per 40 milliseconds.

IIUC, if they spend any significant amount of time executing, they'll be doing so by waiting for events (mutex, IRQ...), right?

Right. As a CX23418 is expected to do more streaming by the host, the mailbox mutex contention goes up and the latency of the CX23418 responding to mailbox commands also goes up so there is more wait()ing.

Quoted 4 lines

If so,
there's nothing to worry about. If it's gonna burn a lot of CPU cycles, we'll need to use a workqueue marked CPU_INTENSIVE but I don't think that's the case here.

Correct, CPU is not the concern here.

Quoted 1 line

Thank you.

Thanks. I'll do a proper inspection of the patch tonight. It looked OK on cursory review.

Regards,
Andy

Reviewed-by Acked-by on v1 11/32
#37 lore raw

Re: [PATCH 11/32] v4l/cx18: update workqueue usage

In reply to Tejun Heo
Quoted 6 lines · Tejun Heo

With cmwq, there's no reason to use separate out_work_queue. Drop it and use system_wq instead. The in_work_queue needs to be ordered so can't use one of the system wqs; however, as it isn't used to reclaim memory, allocate the workqueue with alloc_ordered_workqueue() without WQ_MEM_RECLAIM.

Quoted 6 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Sorry it took so long for me to review. Please route via your wq tree for the cx18 driver.

Thanks,
Andy

Quoted 100 lines

Thanks.

 drivers/media/video/cx18/cx18-driver.c  |   24 ++----------------------
 drivers/media/video/cx18/cx18-driver.h  |    3 ---
 drivers/media/video/cx18/cx18-streams.h |    3 +--
 3 files changed, 3 insertions(+), 27 deletions(-)
drivers/media/video/cx18/cx18-driver.c +2 -22
index df60f27..41c0822 100644
@@ -656,7 +656,7 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 {
 	snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
 		 cx->v4l2_dev.name);
-	cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name);
+	cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0);
 	if (cx->in_work_queue == NULL) {
 		CX18_ERR("Unable to create incoming mailbox handler thread\n");
 		return -ENOMEM;
@@ -664,18 +664,6 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
 	return 0;
 }
 
-static int __devinit cx18_create_out_workq(struct cx18 *cx)
-{
-	snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out",
-		 cx->v4l2_dev.name);
-	cx->out_work_queue = create_workqueue(cx->out_workq_name);
-	if (cx->out_work_queue == NULL) {
-		CX18_ERR("Unable to create outgoing mailbox handler threads\n");
-		return -ENOMEM;
-	}
-	return 0;
-}
-
 static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
 {
 	int i;
@@ -702,15 +690,9 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
 	mutex_init(&cx->epu2apu_mb_lock);
 	mutex_init(&cx->epu2cpu_mb_lock);
 
-	ret = cx18_create_out_workq(cx);
-	if (ret)
-		return ret;
-
 	ret = cx18_create_in_workq(cx);
-	if (ret) {
-		destroy_workqueue(cx->out_work_queue);
+	if (ret)
 		return ret;
-	}
 
 	cx18_init_in_work_orders(cx);
 
@@ -1094,7 +1076,6 @@ free_mem:
 	release_mem_region(cx->base_addr, CX18_MEM_SIZE);
 free_workqueues:
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 err:
 	if (retval == 0)
 		retval = -ENODEV;
@@ -1244,7 +1225,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
 	cx18_halt_firmware(cx);
 
 	destroy_workqueue(cx->in_work_queue);
-	destroy_workqueue(cx->out_work_queue);
 
 	cx18_streams_cleanup(cx, 1);
 
drivers/media/video/cx18/cx18-driver.h +0 -3
index 77be58c..f7f71d1 100644
@@ -614,9 +614,6 @@ struct cx18 {
 	struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS];
 	char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
 
-	struct workqueue_struct *out_work_queue;
-	char out_workq_name[12]; /* "cx18-NN-out" */
-
 	/* i2c */
 	struct i2c_adapter i2c_adap[2];
 	struct i2c_algo_bit_data i2c_algo[2];
drivers/media/video/cx18/cx18-streams.h +1 -2
index 77412be..5837ffb 100644
@@ -41,8 +41,7 @@ static inline bool cx18_stream_enabled(struct cx18_stream *s)
 /* Related to submission of mdls to firmware */
 static inline void cx18_stream_load_fw_queue(struct cx18_stream *s)
 {
-	struct cx18 *cx = s->cx;
-	queue_work(cx->out_work_queue, &s->out_work_order);
+	schedule_work(&s->out_work_order);
 }
 
 static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s,
author
#38 lore raw

PATCH 12/32 i2o: use alloc_workqueue() instead of create_workqueue()

In reply to Tejun Heo

This is an identity conversion.

Cc Markus Lidel <[email protected]>

---
Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/message/i2o/driver.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/message/i2o/driver.c +2 -1
index a0421ef..8a5b2d8 100644
@@ -84,7 +84,8 @@ int i2o_driver_register(struct i2o_driver *drv)
 	osm_debug("Register driver %s\n", drv->name);
 
 	if (drv->event) {
-		drv->event_queue = create_workqueue(drv->name);
+		drv->event_queue = alloc_workqueue(drv->name,
+						   WQ_MEM_RECLAIM, 1);
 		if (!drv->event_queue) {
 			osm_err("Could not initialize event queue for driver "
 				"%s\n", drv->name);
Signature · 1 line
1.7.1
author
#39 lore raw

PATCH 13/32 misc/iwmc3200top: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason to use separate workqueues in iwmc3200top. Drop them and use system_wq instead. The used work items are sync flushed before driver detach.

Cc Tomas Winkler <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/misc/iwmc3200top/iwmc3200top.h |    4 +---
 drivers/misc/iwmc3200top/main.c        |   14 +++++---------
 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/misc/iwmc3200top/iwmc3200top.h +1 -3
index 740ff07..620973e 100644
@@ -183,9 +183,7 @@ struct iwmct_priv {
 	u32 barker;
 	struct iwmct_dbg dbg;
 
-	/* drivers work queue */
-	struct workqueue_struct *wq;
-	struct workqueue_struct *bus_rescan_wq;
+	/* drivers work items */
 	struct work_struct bus_rescan_worker;
 	struct work_struct isr_worker;
 
drivers/misc/iwmc3200top/main.c +5 -9
index c73cef2..727af07 100644
@@ -89,7 +89,7 @@ static void op_top_message(struct iwmct_priv *priv, struct top_msg *msg)
 	switch (msg->hdr.opcode) {
 	case OP_OPR_ALIVE:
 		LOG_INFO(priv, FW_MSG, "Got ALIVE from device, wake rescan\n");
-		queue_work(priv->bus_rescan_wq, &priv->bus_rescan_worker);
+		schedule_work(&priv->bus_rescan_worker);
 		break;
 	default:
 		LOG_INFO(priv, FW_MSG, "Received msg opcode 0x%X\n",
@@ -360,7 +360,7 @@ static void iwmct_irq(struct sdio_func *func)
 	/* clear the function's interrupt request bit (write 1 to clear) */
 	sdio_writeb(func, 1, IWMC_SDIO_INTR_CLEAR_ADDR, &ret);
 
-	queue_work(priv->wq, &priv->isr_worker);
+	schedule_work(&priv->isr_worker);
 
 	LOG_TRACE(priv, IRQ, "exit iwmct_irq\n");
 
@@ -506,10 +506,6 @@ static int iwmct_probe(struct sdio_func *func,
 	priv->func = func;
 	sdio_set_drvdata(func, priv);
 
-
-	/* create drivers work queue */
-	priv->wq = create_workqueue(DRV_NAME "_wq");
-	priv->bus_rescan_wq = create_workqueue(DRV_NAME "_rescan_wq");
 	INIT_WORK(&priv->bus_rescan_worker, iwmct_rescan_worker);
 	INIT_WORK(&priv->isr_worker, iwmct_irq_read_worker);
 
@@ -604,9 +600,9 @@ static void iwmct_remove(struct sdio_func *func)
 	sdio_release_irq(func);
 	sdio_release_host(func);
 
-	/* Safely destroy osc workqueue */
-	destroy_workqueue(priv->bus_rescan_wq);
-	destroy_workqueue(priv->wq);
+	/* Make sure works are finished */
+	flush_work_sync(&priv->bus_rescan_worker);
+	flush_work_sync(&priv->isr_worker);
 
 	sdio_claim_host(func);
 	sdio_disable_func(func);
Signature · 1 line
1.7.1
author
#40 lore raw

PATCH 14/32 wireless/ipw2x00: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason to use separate workqueues in ipw2x00 drivers. Drop them and use system_wq instead. All used work items are sync canceled on driver detach.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/net/wireless/ipw2x00/ipw2100.c |   70 +++++-------
 drivers/net/wireless/ipw2x00/ipw2100.h |    1 -
 drivers/net/wireless/ipw2x00/ipw2200.c |  196 ++++++++++++++------------------
 drivers/net/wireless/ipw2x00/ipw2200.h |    2 -
 4 files changed, 118 insertions(+), 151 deletions(-)
drivers/net/wireless/ipw2x00/ipw2100.c +30 -40
index 61915f3..471a52a 100644
@@ -706,11 +706,10 @@ static void schedule_reset(struct ipw2100_priv *priv)
 		netif_stop_queue(priv->net_dev);
 		priv->status |= STATUS_RESET_PENDING;
 		if (priv->reset_backoff)
-			queue_delayed_work(priv->workqueue, &priv->reset_work,
-					   priv->reset_backoff * HZ);
+			schedule_delayed_work(&priv->reset_work,
+					      priv->reset_backoff * HZ);
 		else
-			queue_delayed_work(priv->workqueue, &priv->reset_work,
-					   0);
+			schedule_delayed_work(&priv->reset_work, 0);
 
 		if (priv->reset_backoff < MAX_RESET_BACKOFF)
 			priv->reset_backoff++;
@@ -1474,7 +1473,7 @@ static int ipw2100_enable_adapter(struct ipw2100_priv *priv)
 
 	if (priv->stop_hang_check) {
 		priv->stop_hang_check = 0;
-		queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2);
+		schedule_delayed_work(&priv->hang_check, HZ / 2);
 	}
 
       fail_up:
@@ -1808,8 +1807,8 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred)
 
 		if (priv->stop_rf_kill) {
 			priv->stop_rf_kill = 0;
-			queue_delayed_work(priv->workqueue, &priv->rf_kill,
-					   round_jiffies_relative(HZ));
+			schedule_delayed_work(&priv->rf_kill,
+					      round_jiffies_relative(HZ));
 		}
 
 		deferred = 1;
@@ -2086,7 +2085,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status)
 	priv->status |= STATUS_ASSOCIATING;
 	priv->connect_start = get_seconds();
 
-	queue_delayed_work(priv->workqueue, &priv->wx_event_work, HZ / 10);
+	schedule_delayed_work(&priv->wx_event_work, HZ / 10);
 }
 
 static int ipw2100_set_essid(struct ipw2100_priv *priv, char *essid,
@@ -2166,9 +2165,9 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
 		return;
 
 	if (priv->status & STATUS_SECURITY_UPDATED)
-		queue_delayed_work(priv->workqueue, &priv->security_work, 0);
+		schedule_delayed_work(&priv->security_work, 0);
 
-	queue_delayed_work(priv->workqueue, &priv->wx_event_work, 0);
+	schedule_delayed_work(&priv->wx_event_work, 0);
 }
 
 static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
@@ -2183,8 +2182,7 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
 	/* Make sure the RF Kill check timer is running */
 	priv->stop_rf_kill = 0;
 	cancel_delayed_work(&priv->rf_kill);
-	queue_delayed_work(priv->workqueue, &priv->rf_kill,
-			   round_jiffies_relative(HZ));
+	schedule_delayed_work(&priv->rf_kill, round_jiffies_relative(HZ));
 }
 
 static void send_scan_event(void *data)
@@ -2219,13 +2217,12 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
 	/* Only userspace-requested scan completion events go out immediately */
 	if (!priv->user_requested_scan) {
 		if (!delayed_work_pending(&priv->scan_event_later))
-			queue_delayed_work(priv->workqueue,
-					&priv->scan_event_later,
-					round_jiffies_relative(msecs_to_jiffies(4000)));
+			schedule_delayed_work(&priv->scan_event_later,
+					      round_jiffies_relative(msecs_to_jiffies(4000)));
 	} else {
 		priv->user_requested_scan = 0;
 		cancel_delayed_work(&priv->scan_event_later);
-		queue_work(priv->workqueue, &priv->scan_event_now);
+		schedule_work(&priv->scan_event_now);
 	}
 }
 
@@ -4329,8 +4326,8 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio)
 			/* Make sure the RF_KILL check timer is running */
 			priv->stop_rf_kill = 0;
 			cancel_delayed_work(&priv->rf_kill);
-			queue_delayed_work(priv->workqueue, &priv->rf_kill,
-					   round_jiffies_relative(HZ));
+			schedule_delayed_work(&priv->rf_kill,
+					      round_jiffies_relative(HZ));
 		} else
 			schedule_reset(priv);
 	}
@@ -4461,20 +4458,17 @@ static void bd_queue_initialize(struct ipw2100_priv *priv,
 	IPW_DEBUG_INFO("exit\n");
 }
 
-static void ipw2100_kill_workqueue(struct ipw2100_priv *priv)
+static void ipw2100_kill_works(struct ipw2100_priv *priv)
 {
-	if (priv->workqueue) {
-		priv->stop_rf_kill = 1;
-		priv->stop_hang_check = 1;
-		cancel_delayed_work(&priv->reset_work);
-		cancel_delayed_work(&priv->security_work);
-		cancel_delayed_work(&priv->wx_event_work);
-		cancel_delayed_work(&priv->hang_check);
-		cancel_delayed_work(&priv->rf_kill);
-		cancel_delayed_work(&priv->scan_event_later);
-		destroy_workqueue(priv->workqueue);
-		priv->workqueue = NULL;
-	}
+	priv->stop_rf_kill = 1;
+	priv->stop_hang_check = 1;
+	cancel_delayed_work_sync(&priv->reset_work);
+	cancel_delayed_work_sync(&priv->security_work);
+	cancel_delayed_work_sync(&priv->wx_event_work);
+	cancel_delayed_work_sync(&priv->hang_check);
+	cancel_delayed_work_sync(&priv->rf_kill);
+	cancel_work_sync(&priv->scan_event_now);
+	cancel_delayed_work_sync(&priv->scan_event_later);
 }
 
 static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
@@ -6046,7 +6040,7 @@ static void ipw2100_hang_check(struct work_struct *work)
 	priv->last_rtc = rtc;
 
 	if (!priv->stop_hang_check)
-		queue_delayed_work(priv->workqueue, &priv->hang_check, HZ / 2);
+		schedule_delayed_work(&priv->hang_check, HZ / 2);
 
 	spin_unlock_irqrestore(&priv->low_lock, flags);
 }
@@ -6062,8 +6056,8 @@ static void ipw2100_rf_kill(struct work_struct *work)
 	if (rf_kill_active(priv)) {
 		IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n");
 		if (!priv->stop_rf_kill)
-			queue_delayed_work(priv->workqueue, &priv->rf_kill,
-					   round_jiffies_relative(HZ));
+			schedule_delayed_work(&priv->rf_kill,
+					      round_jiffies_relative(HZ));
 		goto exit_unlock;
 	}
 
@@ -6209,8 +6203,6 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
 	INIT_LIST_HEAD(&priv->fw_pend_list);
 	INIT_STAT(&priv->fw_pend_stat);
 
-	priv->workqueue = create_workqueue(DRV_NAME);
-
 	INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter);
 	INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work);
 	INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
@@ -6410,7 +6402,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
 		if (dev->irq)
 			free_irq(dev->irq, priv);
 
-		ipw2100_kill_workqueue(priv);
+		ipw2100_kill_works(priv);
 
 		/* These are safe to call even if they weren't allocated */
 		ipw2100_queues_free(priv);
@@ -6460,9 +6452,7 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
 		 * first, then close() will crash. */
 		unregister_netdev(dev);
 
-		/* ipw2100_down will ensure that there is no more pending work
-		 * in the workqueue's, so we can safely remove them now. */
-		ipw2100_kill_workqueue(priv);
+		ipw2100_kill_works(priv);
 
 		ipw2100_queues_free(priv);
 
drivers/net/wireless/ipw2x00/ipw2100.h +0 -1
index 838002b..99cba96 100644
@@ -580,7 +580,6 @@ struct ipw2100_priv {
 
 	struct tasklet_struct irq_tasklet;
 
-	struct workqueue_struct *workqueue;
 	struct delayed_work reset_work;
 	struct delayed_work security_work;
 	struct delayed_work wx_event_work;
drivers/net/wireless/ipw2x00/ipw2200.c +88 -108

476 lines not on this page · raw message

drivers/net/wireless/ipw2x00/ipw2200.h +0 -2
index d7d049c..0441445 100644
@@ -1299,8 +1299,6 @@ struct ipw_priv {
 	u8 direct_scan_ssid[IW_ESSID_MAX_SIZE];
 	u8 direct_scan_ssid_len;
 
-	struct workqueue_struct *workqueue;
-
 	struct delayed_work adhoc_check;
 	struct work_struct associate;
 	struct work_struct disassociate;
Signature · 1 line
1.7.1
#41 lore raw

Re: [PATCH 14/32] wireless/ipw2x00: use system_wq instead of dedicated workqueues

Quoted 10 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues in ipw2x00 drivers. Drop them and use system_wq instead. All used work items are sync canceled on driver detach.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

ACK

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
author
#42 lore raw

PATCH 15/32 wireless/libertas[_tf]: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason to use separate workqueues in libertas[_tf] drivers. Drop them and use system_wq instead. All used work items are sync flushed/canceled on driver detach.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/net/wireless/libertas/if_sdio.c        |   10 +++-------
 drivers/net/wireless/libertas_tf/cmd.c         |    6 +++---
 drivers/net/wireless/libertas_tf/libertas_tf.h |    2 --
 drivers/net/wireless/libertas_tf/main.c        |   16 ++++------------
 4 files changed, 10 insertions(+), 24 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +3 -7
index b4de0ca..257f664 100644
@@ -129,7 +129,6 @@ struct if_sdio_card {
 	spinlock_t		lock;
 	struct if_sdio_packet	*packets;
 
-	struct workqueue_struct	*workqueue;
 	struct work_struct	packet_worker;
 
 	u8			rx_unit;
@@ -828,7 +827,7 @@ static int if_sdio_host_to_card(struct lbs_private *priv,
 
 	spin_unlock_irqrestore(&card->lock, flags);
 
-	queue_work(card->workqueue, &card->packet_worker);
+	schedule_work(&card->packet_worker);
 
 	ret = 0;
 
@@ -986,7 +985,6 @@ static int if_sdio_probe(struct sdio_func *func,
 	}
 
 	spin_lock_init(&card->lock);
-	card->workqueue = create_workqueue("libertas_sdio");
 	INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
 
 	/* Check if we support this card */
@@ -1114,7 +1112,7 @@ out:
 	return ret;
 
 err_activate_card:
-	flush_workqueue(card->workqueue);
+	flush_work_sync(&card->packet_worker);
 	lbs_remove_card(priv);
 reclaim:
 	sdio_claim_host(func);
@@ -1125,7 +1123,6 @@ disable:
 release:
 	sdio_release_host(func);
 free:
-	destroy_workqueue(card->workqueue);
 	while (card->packets) {
 		packet = card->packets;
 		card->packets = card->packets->next;
@@ -1171,8 +1168,7 @@ static void if_sdio_remove(struct sdio_func *func)
 	lbs_stop_card(card->priv);
 	lbs_remove_card(card->priv);
 
-	flush_workqueue(card->workqueue);
-	destroy_workqueue(card->workqueue);
+	flush_work_sync(&card->packet_worker);
 
 	sdio_claim_host(func);
 	sdio_release_irq(func);
drivers/net/wireless/libertas_tf/cmd.c +3 -3
index 8945afd..c429e02 100644
@@ -623,7 +623,7 @@ static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv,
 		lbtf_deb_host("PREP_CMD: cmdnode is NULL\n");
 
 		/* Wake up main thread to execute next command */
-		queue_work(lbtf_wq, &priv->cmd_work);
+		schedule_work(&priv->cmd_work);
 		cmdnode = ERR_PTR(-ENOBUFS);
 		goto done;
 	}
@@ -645,7 +645,7 @@ static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv,
 
 	cmdnode->cmdwaitqwoken = 0;
 	lbtf_queue_cmd(priv, cmdnode);
-	queue_work(lbtf_wq, &priv->cmd_work);
+	schedule_work(&priv->cmd_work);
 
  done:
 	lbtf_deb_leave_args(LBTF_DEB_HOST, "ret %p", cmdnode);
@@ -707,7 +707,7 @@ EXPORT_SYMBOL_GPL(__lbtf_cmd);
 void lbtf_cmd_response_rx(struct lbtf_private *priv)
 {
 	priv->cmd_response_rxed = 1;
-	queue_work(lbtf_wq, &priv->cmd_work);
+	schedule_work(&priv->cmd_work);
 }
 EXPORT_SYMBOL_GPL(lbtf_cmd_response_rx);
 
drivers/net/wireless/libertas_tf/libertas_tf.h +0 -2
index ad77b92..6b0f932 100644
@@ -156,8 +156,6 @@ enum mv_ms_type {
 	MVMS_EVENT
 };
 
-extern struct workqueue_struct *lbtf_wq;
-
 struct lbtf_private;
 
 struct lbtf_offset_value {
drivers/net/wireless/libertas_tf/main.c +4 -12
index 9278b3c..622d029 100644
@@ -31,8 +31,6 @@ static const char lbtf_driver_version[] = "THINFIRM-USB8388-" DRIVER_RELEASE_VER
 #endif
 	"";
 
-struct workqueue_struct *lbtf_wq;
-
 static const struct ieee80211_channel lbtf_channels[] = {
 	{ .center_freq = 2412, .hw_value = 1 },
 	{ .center_freq = 2417, .hw_value = 2 },
@@ -188,7 +186,7 @@ static void command_timer_fn(unsigned long data)
 		le16_to_cpu(priv->cur_cmd->cmdbuf->command));
 
 	priv->cmd_timed_out = 1;
-	queue_work(lbtf_wq, &priv->cmd_work);
+	schedule_work(&priv->cmd_work);
 out:
 	spin_unlock_irqrestore(&priv->driver_lock, flags);
 	lbtf_deb_leave(LBTF_DEB_CMD);
@@ -230,7 +228,7 @@ static int lbtf_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 	struct lbtf_private *priv = hw->priv;
 
 	priv->skb_to_tx = skb;
-	queue_work(lbtf_wq, &priv->tx_work);
+	schedule_work(&priv->tx_work);
 	/*
 	 * queue will be restarted when we receive transmission feedback if
 	 * there are no buffered multicast frames to send
@@ -706,7 +704,7 @@ void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail)
 	if (!priv->skb_to_tx && skb_queue_empty(&priv->bc_ps_buf))
 		ieee80211_wake_queues(priv->hw);
 	else
-		queue_work(lbtf_wq, &priv->tx_work);
+		schedule_work(&priv->tx_work);
 }
 EXPORT_SYMBOL_GPL(lbtf_send_tx_feedback);
 
@@ -726,7 +724,7 @@ void lbtf_bcn_sent(struct lbtf_private *priv)
 		}
 		if (tx_buff_bc) {
 			ieee80211_stop_queues(priv->hw);
-			queue_work(lbtf_wq, &priv->tx_work);
+			schedule_work(&priv->tx_work);
 		}
 	}
 
@@ -742,11 +740,6 @@ EXPORT_SYMBOL_GPL(lbtf_bcn_sent);
 static int __init lbtf_init_module(void)
 {
 	lbtf_deb_enter(LBTF_DEB_MAIN);
-	lbtf_wq = create_workqueue("libertastf");
-	if (lbtf_wq == NULL) {
-		printk(KERN_ERR "libertastf: couldn't create workqueue\n");
-		return -ENOMEM;
-	}
 	lbtf_deb_leave(LBTF_DEB_MAIN);
 	return 0;
 }
@@ -754,7 +747,6 @@ static int __init lbtf_init_module(void)
 static void __exit lbtf_exit_module(void)
 {
 	lbtf_deb_enter(LBTF_DEB_MAIN);
-	destroy_workqueue(lbtf_wq);
 	lbtf_deb_leave(LBTF_DEB_MAIN);
 }
 
Signature · 1 line
1.7.1
author
#43 lore raw

Re: [PATCH 15/32] wireless/libertas[_tf]: use system_wq instead of dedicated workqueues

Quoted 9 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues in libertas[_tf] drivers. Drop them and use system_wq instead. All used work items are sync flushed/canceled on driver detach.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Dan, ping?

Signature · 1 line
tejun
author
#44 lore raw

PATCH 16/32 scsi/be2iscsi,qla2xxx: convert to alloc_workqueue()

In reply to Tejun Heo

Switch to new workqueue interface alloc_workqueue(). These are identity conversions.

Cc Jayamohan Kallickal <[email protected]>
Cc Andrew Vasquez <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>

---
Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/scsi/be2iscsi/be_main.c |    2 +-
 drivers/scsi/qla2xxx/qla_os.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/be2iscsi/be_main.c +1 -1
index 75a85aa..4339196 100644
@@ -4276,7 +4276,7 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
 
 	snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_q_irq%u",
 		 phba->shost->host_no);
-	phba->wq = create_workqueue(phba->wq_name);
+	phba->wq = alloc_workqueue(phba->wq_name, WQ_MEM_RECLAIM, 1);
 	if (!phba->wq) {
 		shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-"
 				"Failed to allocate work queue\n");
drivers/scsi/qla2xxx/qla_os.c +1 -1
index 2c0876c..2cd0a77 100644
@@ -356,7 +356,7 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
 				"Can't create request queue\n");
 			goto fail;
 		}
-		ha->wq = create_workqueue("qla2xxx_wq");
+		ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
 		vha->req = ha->req_q_map[req];
 		options |= BIT_1;
 		for (ques = 1; ques < ha->max_rsp_queues; ques++) {
Signature · 1 line
1.7.1
#45 lore raw

Re: [PATCH 16/32] scsi/be2iscsi,qla2xxx: convert to alloc_workqueue()

Quoted 18 lines · Tejun Heo
drivers/scsi/be2iscsi/be_main.c +1 -1
index 75a85aa..4339196 100644
@@ -4276,7 +4276,7 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
 
  	snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_q_irq%u",
  		 phba->shost->host_no);
-	phba->wq = create_workqueue(phba->wq_name);
+	phba->wq = alloc_workqueue(phba->wq_name, WQ_MEM_RECLAIM, 1);
  	if (!phba->wq) {
  		shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-"
  				"Failed to allocate work queue\n");
drivers/scsi/qla2xxx/qla_os.c +0 -0
index 2c0876c..2cd0a77 100644

drivers/scsi/qla2xxx/qla_os.c static int qla25xx_setup_mode(struct scsi_qla_host *vha) · line 362

Quoted 8 lines
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -356,7 +356,7 @@ static int qla25xx_setup_mode(struct scsi_qla_host *vha)
  				"Can't create request queue\n");
  			goto fail;
  		}
-		ha->wq = create_workqueue("qla2xxx_wq");
+		ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
  		vha->req = ha->req_q_map[req];
  		options |= BIT_1;
  		for (ques = 1; ques<  ha->max_rsp_queues; ques++) {

I think these are used in the main IO path, so would you also want WQ_HIGHPRI | WQ_CPU_INTENSIVE to be set? I think qla2xxx was using this in a path they expected to have high throughput/low latency, and from the interrupt handler they would try to queue the work on the same cpu the isr was answered on. With the new workqueue code could you possibly get queued onto a workqueue that is doing other work for other drivers?

Should qla2xxx be using the blkiopoll framework instead of a workqueue or will workqueues still provide the same performance when setting WQ_HIGHPRI | WQ_CPU_INTENSIVE?

author
#46 lore raw

Re: [PATCH 16/32] scsi/be2iscsi,qla2xxx: convert to alloc_workqueue()

Hello,

Quoted 2 lines · Mike Christie

I think these are used in the main IO path, so would you also want WQ_HIGHPRI | WQ_CPU_INTENSIVE to be set?

Maybe HIGHPRI but definitely not CPU_INTENSIVE, but even HIGHPRI isn't usually necessary. The queue of pending works tend to be short and consumed pretty fast.

Quoted 5 lines

I think qla2xxx was using this in a path they expected to have high throughput/low latency, and from the interrupt handler they would try to queue the work on the same cpu the isr was answered on. With the new workqueue code could you possibly get queued onto a workqueue that is doing other work for other drivers?

There are no separate workqueues. There's one per cpu which is used by all workqueue users. HIGHPRI boosts the queueing order in that queue.

Quoted 3 lines

Should qla2xxx be using the blkiopoll framework instead of a workqueue or will workqueues still provide the same performance when setting WQ_HIGHPRI | WQ_CPU_INTENSIVE?

CPU_INTENSIVE isn't applicable at all unless you want to run crypto or zlib from the driver.

blk_iopoll runs off softirq and will always have lower latency than workqueue which requires scheduling, so it depends on the requirements. I guess the best thing would be playing with things a bit and make decisions on test results. It shouldn't be too difficult to switch among them.

Thanks.

Signature · 1 line
tejun
#47 lore raw

Re: [PATCH 16/32] scsi/be2iscsi,qla2xxx: convert to alloc_workqueue()

Quoted 3 lines · Tejun Heo

usually necessary. The queue of pending works tend to be short and consumed pretty fast.

What if we want to do something that could take a while, like doing recovery of a device/transport (so you have to send resets and logouts/logins and wait for the results but they could take a while if they timeout), should we be using something other than a workqueue so it does not interfere with other users?

author
#48 lore raw

Re: [PATCH 16/32] scsi/be2iscsi,qla2xxx: convert to alloc_workqueue()

Hello, Mike.

Quoted 9 lines · Mike Christie
Quoted 2 lines · Tejun Heo

usually necessary. The queue of pending works tend to be short and consumed pretty fast.

What if we want to do something that could take a while, like doing recovery of a device/transport (so you have to send resets and logouts/logins and wait for the results but they could take a while if they timeout), should we be using something other than a workqueue so it does not interfere with other users?

As long as you don't use ordered workqueue, it wouldn't be a problem. The max concurrency is determined by @max_active parameter to alloc_workqueue() and workqueue will try to provide concurrency upto the limit on demand as long as resources are available.

Thanks.

Signature · 1 line
tejun
author
#49 lore raw

PATCH 17/32 scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

In reply to Tejun Heo

The target driver is not in the memory reclaim path and doesn't need a dedicated workqueue. Drop vtgtd and use system_wq instead. The used work item is sync flushed on removal.

Cc FUJITA Tomonori <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/scsi/ibmvscsi/ibmvstgt.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/ibmvscsi/ibmvstgt.c +4 -11
index 2256bab..47fc632 100644
@@ -74,7 +74,6 @@ struct vio_port {
 	struct srp_rport *rport;
 };
 
-static struct workqueue_struct *vtgtd;
 static struct scsi_transport_template *ibmvstgt_transport_template;
 
 /*
@@ -546,7 +545,7 @@ static irqreturn_t ibmvstgt_interrupt(int dummy, void *data)
 	struct vio_port *vport = target_to_port(target);
 
 	vio_disable_interrupts(vport->dma_dev);
-	queue_work(vtgtd, &vport->crq_work);
+	schedule_work(&vport->crq_work);
 
 	return IRQ_HANDLED;
 }
@@ -900,6 +899,7 @@ static int ibmvstgt_remove(struct vio_dev *dev)
 	crq_queue_destroy(target);
 	srp_remove_host(shost);
 	scsi_remove_host(shost);
+	flush_work_sync(&vport->crq_work);
 	scsi_tgt_free_queue(shost);
 	srp_target_free(target);
 	kfree(vport);
@@ -967,21 +967,15 @@ static int __init ibmvstgt_init(void)
 	if (!ibmvstgt_transport_template)
 		return err;
 
-	vtgtd = create_workqueue("ibmvtgtd");
-	if (!vtgtd)
-		goto release_transport;
-
 	err = get_system_info();
 	if (err)
-		goto destroy_wq;
+		goto release_transport;
 
 	err = vio_register_driver(&ibmvstgt_driver);
 	if (err)
-		goto destroy_wq;
+		goto release_transport;
 
 	return 0;
-destroy_wq:
-	destroy_workqueue(vtgtd);
 release_transport:
 	srp_release_transport(ibmvstgt_transport_template);
 	return err;
@@ -991,7 +985,6 @@ static void __exit ibmvstgt_exit(void)
 {
 	printk("Unregister IBM virtual SCSI driver\n");
 
-	destroy_workqueue(vtgtd);
 	vio_unregister_driver(&ibmvstgt_driver);
 	srp_release_transport(ibmvstgt_transport_template);
 }
Signature · 1 line
1.7.1
#50 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Quoted 3 lines · Tejun Heo

The target driver is not in the memory reclaim path and doesn't need a dedicated workqueue.  Drop vtgtd and use system_wq instead.  The used work item is sync flushed on removal.

[ ... ]

Hi Tejun,

No matter which storage target will go upstream, I'm afraid that this patch will conflict with it. See e.g.
http://dchs.spinics.net/lists/linux-scsi/msg49105.html.

Bart.

author
#51 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Hello,

Quoted 3 lines · Bart Van Assche

No matter which storage target will go upstream, I'm afraid that this patch will conflict with it. See e.g.
http://dchs.spinics.net/lists/linux-scsi/msg49105.html.

Ah, okay. The full conversion is gonna span several devel cycles anyway. I'll re-convert ibmvstgt when the dust settles down.

Thank you.

--
tejun

#52 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

In reply to Tejun Heo
Quoted 72 lines · Tejun Heo

The target driver is not in the memory reclaim path and doesn't need a dedicated workqueue.  Drop vtgtd and use system_wq instead.  The used work item is sync flushed on removal.

Cc FUJITA Tomonori <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>

---
Only compile tested.  Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/scsi/ibmvscsi/ibmvstgt.c |   15 ++++-----------

 1 files changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/ibmvscsi/ibmvstgt.c +4 -10
index 2256bab..47fc632 100644
@@ -74,7 +74,6 @@ struct vio_port {
        struct srp_rport *rport;
  };
 
-static struct workqueue_struct *vtgtd;
  static struct scsi_transport_template *ibmvstgt_transport_template;
 
  /*
@@ -546,7 +545,7 @@ static irqreturn_t ibmvstgt_interrupt(int dummy, void *data)
        struct vio_port *vport = target_to_port(target);
 
        vio_disable_interrupts(vport->dma_dev);
-       queue_work(vtgtd, &vport->crq_work);
+       schedule_work(&vport->crq_work);
 
        return IRQ_HANDLED;
  }
@@ -900,6 +899,7 @@ static int ibmvstgt_remove(struct vio_dev *dev)
        crq_queue_destroy(target);
        srp_remove_host(shost);
        scsi_remove_host(shost);
+       flush_work_sync(&vport->crq_work);
        scsi_tgt_free_queue(shost);
        srp_target_free(target);
        kfree(vport);
@@ -967,21 +967,15 @@ static int __init ibmvstgt_init(void)
        if (!ibmvstgt_transport_template)
                return err;
 
-       vtgtd = create_workqueue("ibmvtgtd");
-       if (!vtgtd)
-               goto release_transport;
-
        err = get_system_info();
        if (err)
-               goto destroy_wq;
+               goto release_transport;
 
        err = vio_register_driver(&ibmvstgt_driver);
        if (err)
-               goto destroy_wq;
+               goto release_transport;
 
        return 0;
-destroy_wq:
-       destroy_workqueue(vtgtd);

 release_transport:
       srp_release_transport(ibmvstgt_transport_template); return err;

drivers/scsi/ibmvscsi/ibmvstgt.c static void __exit ibmvstgt_exit(void) · line 990

Quoted 7 lines
drivers/scsi/ibmvscsi/ibmvstgt.c +0 -1
@@ -991,7 +985,6 @@ static void __exit ibmvstgt_exit(void)
  {
        printk("Unregister IBM virtual SCSI driver\n");
 
-       destroy_workqueue(vtgtd);
        vio_unregister_driver(&ibmvstgt_driver);
        srp_release_transport(ibmvstgt_transport_template);
  }

(added Brian King and Robert Jennings in CC)

Hello Tejun,

Insertion of flush_work_sync() fixes a race - that's a good catch. flush_work_sync() should be invoked a little earlier though because the scheduled work may access the queue destroyed by the crq_queue_destroy(target) call. And the CRQ interrupt should be disabled from before flush_work_sync() is invoked until after the CRQ has been destroyed.

Regarding the queue removal: I might have missed something, but why would you like to remove the vtgtd work queue ? Since the ibmvstgt driver is a storage target driver, processing latency matters. I'm afraid that switching from a dedicated queue to the global work queue will increase processing latency.

Bart.

author
#53 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Hello,

Quoted 6 lines · Bart Van Assche

Insertion of flush_work_sync() fixes a race - that's a good catch. flush_work_sync() should be invoked a little earlier though because the scheduled work may access the queue destroyed by the crq_queue_destroy(target) call. And the CRQ interrupt should be disabled from before flush_work_sync() is invoked until after the CRQ has been destroyed.

Heh, I'm a bit out of my depth here. If you know what's necessary, please go ahead and make the change.

Quoted 5 lines

Regarding the queue removal: I might have missed something, but why would you like to remove the vtgtd work queue ? Since the ibmvstgt driver is a storage target driver, processing latency matters. I'm afraid that switching from a dedicated queue to the global work queue will increase processing latency.

Having a dedicated workqueue no longer makes any difference regarding processing latency. Each workqueue is mere frontend to the shared worker pool anyway. Dedicated workqueues are now meaningful only as forward progress guarantee, attribute and/or flush domain - IOW, when the workqueue needs to be used during memory reclaim, the work items need to have specific attributes or certain group of work items need to be flushed together. Apart from that, there's virtually no difference between using the system_wq and a dedicated one. As using the system one is usually simpler, it's natural to do that.

Thank you.

Signature · 1 line
tejun
author
#54 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Quoted 19 lines · Tejun Heo

Hello,

Quoted 6 lines · Bart Van Assche

Insertion of flush_work_sync() fixes a race - that's a good catch. flush_work_sync() should be invoked a little earlier though because the scheduled work may access the queue destroyed by the crq_queue_destroy(target) call. And the CRQ interrupt should be disabled from before flush_work_sync() is invoked until after the CRQ has been destroyed.

Heh, I'm a bit out of my depth here. If you know what's necessary, please go ahead and make the change.

Quoted 5 lines

Regarding the queue removal: I might have missed something, but why would you like to remove the vtgtd work queue ? Since the ibmvstgt driver is a storage target driver, processing latency matters. I'm afraid that switching from a dedicated queue to the global work queue will increase processing latency.

Quoted 9 lines

Having a dedicated workqueue no longer makes any difference regarding processing latency. Each workqueue is mere frontend to the shared worker pool anyway. Dedicated workqueues are now meaningful only as forward progress guarantee, attribute and/or flush domain - IOW, when the workqueue needs to be used during memory reclaim, the work items need to have specific attributes or certain group of work items need to be flushed together. Apart from that, there's virtually no difference between using the system_wq and a dedicated one. As using the system one is usually simpler, it's natural to do that.

Ping. Are you interested in doing the conversion?

Thanks.

Signature · 1 line
tejun
#55 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Quoted 30 lines · On Tue, 1 Feb 2011 11:40:43 +0100 Tejun Heo <[email protected]> wrote:
Quoted 19 lines · Tejun Heo

Hello,

Quoted 6 lines · Bart Van Assche

Insertion of flush_work_sync() fixes a race - that's a good catch. flush_work_sync() should be invoked a little earlier though because the scheduled work may access the queue destroyed by the crq_queue_destroy(target) call. And the CRQ interrupt should be disabled from before flush_work_sync() is invoked until after the CRQ has been destroyed.

Heh, I'm a bit out of my depth here. If you know what's necessary, please go ahead and make the change.

Quoted 5 lines

Regarding the queue removal: I might have missed something, but why would you like to remove the vtgtd work queue ? Since the ibmvstgt driver is a storage target driver, processing latency matters. I'm afraid that switching from a dedicated queue to the global work queue will increase processing latency.

Quoted 9 lines

Having a dedicated workqueue no longer makes any difference regarding processing latency. Each workqueue is mere frontend to the shared worker pool anyway. Dedicated workqueues are now meaningful only as forward progress guarantee, attribute and/or flush domain - IOW, when the workqueue needs to be used during memory reclaim, the work items need to have specific attributes or certain group of work items need to be flushed together. Apart from that, there's virtually no difference between using the system_wq and a dedicated one. As using the system one is usually simpler, it's natural to do that.

Quoted 1 line

Ping. Are you interested in doing the conversion?

FYI, this driver will be replaced shortly. Now I have the working ibmvscsis driver for the new target framework. I'll submit it this week. So this driver will be removed soon or later (if James prefer to go through the proper Documentation/feature-removal-schedule.txt process, it'll be for some time). You could leave this alone, I guess.

#56 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

Quoted 33 lines · FUJITA Tomonori
Quoted 30 lines · On Tue, 1 Feb 2011 11:40:43 +0100 Tejun Heo <[email protected]> wrote:
Quoted 28 lines · Tejun Heo

Hello,

Quoted 6 lines · Bart Van Assche

Insertion of flush_work_sync() fixes a race - that's a good catch. flush_work_sync() should be invoked a little earlier though because the scheduled work may access the queue destroyed by the crq_queue_destroy(target) call. And the CRQ interrupt should be disabled from before flush_work_sync() is invoked until after the CRQ has been destroyed.

Heh, I'm a bit out of my depth here. If you know what's necessary, please go ahead and make the change.

Quoted 5 lines

Regarding the queue removal: I might have missed something, but why would you like to remove the vtgtd work queue ? Since the ibmvstgt driver is a storage target driver, processing latency matters. I'm afraid that switching from a dedicated queue to the global work queue will increase processing latency.

Having a dedicated workqueue no longer makes any difference regarding processing latency. Each workqueue is mere frontend to the shared worker pool anyway. Dedicated workqueues are now meaningful only as forward progress guarantee, attribute and/or flush domain - IOW, when the workqueue needs to be used during memory reclaim, the work items need to have specific attributes or certain group of work items need to be flushed together. Apart from that, there's virtually no difference between using the system_wq and a dedicated one. As using the system one is usually simpler, it's natural to do that.

Quoted 7 lines
Quoted 1 line

Ping. Are you interested in doing the conversion?

FYI, this driver will be replaced shortly. Now I have the working ibmvscsis driver for the new target framework. I'll submit it this week. So this driver will be removed soon or later (if James prefer to go through the proper Documentation/feature-removal-schedule.txt process, it'll be for some time). You could leave this alone, I guess.

Whatever works for you is fine by me. I don't think we need to go through feature removal since we're not technically removing the feature.

James

author
#57 lore raw

Re: [PATCH 17/32] scsi/ibmvstgt: use system_wq instead of vtgtd workqueue

In reply to FUJITA Tomonori
Quoted 7 lines · FUJITA Tomonori
Quoted 1 line

Ping. Are you interested in doing the conversion?

FYI, this driver will be replaced shortly. Now I have the working ibmvscsis driver for the new target framework. I'll submit it this week. So this driver will be removed soon or later (if James prefer to go through the proper Documentation/feature-removal-schedule.txt process, it'll be for some time). You could leave this alone, I guess.

I see. I'll drop the patch then. Please keep in mind that I'm planning on marking flush_scheduled_work() deprecated in linux-next in a month or so. create_singlethread_workqueue() will follow in the next cycle and then create_workqueue() the next.

Thank you.

Signature · 1 line
tejun
author
#58 lore raw

PATCH 18/32 scsi/scsi_tgt_lib: scsi_tgtd isn't used in memory reclaim path

In reply to Tejun Heo

Workqueue scsi_tgtd isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM.

Cc FUJITA Tomonori <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/scsi/scsi_tgt_lib.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/scsi_tgt_lib.c +1 -1
index c399be9..f672820 100644
@@ -629,7 +629,7 @@ static int __init scsi_tgt_init(void)
 	if (!scsi_tgt_cmd_cache)
 		return -ENOMEM;
 
-	scsi_tgtd = create_workqueue("scsi_tgtd");
+	scsi_tgtd = alloc_workqueue("scsi_tgtd", 0, 1);
 	if (!scsi_tgtd) {
 		err = -ENOMEM;
 		goto free_kmemcache;
Signature · 1 line
1.7.1
author
#59 lore raw

PATCH 19/32 usb/ueagle-atm: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop uea_softc->work_q and use system_wq instead. The used work item is sync flushed on driver detach.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/usb/atm/ueagle-atm.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
drivers/usb/atm/ueagle-atm.c +5 -14
index 44447f5..55c1d3b 100644
@@ -168,7 +168,6 @@ struct uea_softc {
 	union cmv_dsc cmv_dsc;
 
 	struct work_struct task;
-	struct workqueue_struct *work_q;
 	u16 pageno;
 	u16 ovl;
 
@@ -1879,7 +1878,7 @@ static int uea_start_reset(struct uea_softc *sc)
 	/* start loading DSP */
 	sc->pageno = 0;
 	sc->ovl = 0;
-	queue_work(sc->work_q, &sc->task);
+	schedule_work(&sc->task);
 
 	/* wait for modem ready CMV */
 	ret = wait_cmv_ack(sc);
@@ -2091,14 +2090,14 @@ static void uea_schedule_load_page_e1(struct uea_softc *sc,
 {
 	sc->pageno = intr->e1_bSwapPageNo;
 	sc->ovl = intr->e1_bOvl >> 4 | intr->e1_bOvl << 4;
-	queue_work(sc->work_q, &sc->task);
+	schedule_work(&sc->task);
 }
 
 static void uea_schedule_load_page_e4(struct uea_softc *sc,
 						struct intr_pkt *intr)
 {
 	sc->pageno = intr->e4_bSwapPageNo;
-	queue_work(sc->work_q, &sc->task);
+	schedule_work(&sc->task);
 }
 
 /*
@@ -2170,13 +2169,6 @@ static int uea_boot(struct uea_softc *sc)
 
 	init_waitqueue_head(&sc->sync_q);
 
-	sc->work_q = create_workqueue("ueagle-dsp");
-	if (!sc->work_q) {
-		uea_err(INS_TO_USBDEV(sc), "cannot allocate workqueue\n");
-		uea_leaves(INS_TO_USBDEV(sc));
-		return -ENOMEM;
-	}
-
 	if (UEA_CHIP_VERSION(sc) == ADI930)
 		load_XILINX_firmware(sc);
 
@@ -2222,7 +2214,6 @@ err1:
 	sc->urb_int = NULL;
 	kfree(intr);
 err0:
-	destroy_workqueue(sc->work_q);
 	uea_leaves(INS_TO_USBDEV(sc));
 	return -ENOMEM;
 }
@@ -2243,8 +2234,8 @@ static void uea_stop(struct uea_softc *sc)
 	kfree(sc->urb_int->transfer_buffer);
 	usb_free_urb(sc->urb_int);
 
-	/* stop any pending boot process, when no one can schedule work */
-	destroy_workqueue(sc->work_q);
+	/* flush the work item, when no one can schedule it */
+	flush_work_sync(&sc->task);
 
 	if (sc->dsp_firm)
 		release_firmware(sc->dsp_firm);
Signature · 1 line
1.7.1
author
#60 lore raw

PATCH 20/32 video/msm_fb: use system_wq instead of dedicated workqueues

In reply to Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/video/msm/msm_fb.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/video/msm/msm_fb.c +1 -10
index debe593..5436aeb 100644
@@ -81,7 +81,6 @@ struct msmfb_info {
 	spinlock_t update_lock;
 	struct mutex panel_init_lock;
 	wait_queue_head_t frame_wq;
-	struct workqueue_struct *resume_workqueue;
 	struct work_struct resume_work;
 	struct msmfb_callback dma_callback;
 	struct msmfb_callback vsync_callback;
@@ -111,7 +110,7 @@ static void msmfb_handle_dma_interrupt(struct msmfb_callback *callback)
 	if (msmfb->sleeping == UPDATING &&
 	    msmfb->frame_done == msmfb->update_frame) {
 		DLOG(SUSPEND_RESUME, "full update completed\n");
-		queue_work(msmfb->resume_workqueue, &msmfb->resume_work);
+		schedule_work(&msmfb->resume_work);
 	}
 	spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
 	wake_up(&msmfb->frame_wq);
@@ -559,12 +558,6 @@ static int msmfb_probe(struct platform_device *pdev)
 	spin_lock_init(&msmfb->update_lock);
 	mutex_init(&msmfb->panel_init_lock);
 	init_waitqueue_head(&msmfb->frame_wq);
-	msmfb->resume_workqueue = create_workqueue("panel_on");
-	if (msmfb->resume_workqueue == NULL) {
-		printk(KERN_ERR "failed to create panel_on workqueue\n");
-		ret = -ENOMEM;
-		goto error_create_workqueue;
-	}
 	INIT_WORK(&msmfb->resume_work, power_on_panel);
 	msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres,
 			       GFP_KERNEL);
@@ -589,8 +582,6 @@ static int msmfb_probe(struct platform_device *pdev)
 	return 0;
 
 error_register_framebuffer:
-	destroy_workqueue(msmfb->resume_workqueue);
-error_create_workqueue:
 	iounmap(fb->screen_base);
 error_setup_fbmem:
 	framebuffer_release(msmfb->fb);
Signature · 1 line
1.7.1
#61 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 5 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

Quoted 57 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 drivers/video/msm/msm_fb.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/video/msm/msm_fb.c +1 -10
index debe593..5436aeb 100644
@@ -81,7 +81,6 @@ struct msmfb_info {
 	spinlock_t update_lock;
 	struct mutex panel_init_lock;
 	wait_queue_head_t frame_wq;
-	struct workqueue_struct *resume_workqueue;
 	struct work_struct resume_work;
 	struct msmfb_callback dma_callback;
 	struct msmfb_callback vsync_callback;
@@ -111,7 +110,7 @@ static void msmfb_handle_dma_interrupt(struct msmfb_callback *callback)
 	if (msmfb->sleeping == UPDATING &&
 	    msmfb->frame_done == msmfb->update_frame) {
 		DLOG(SUSPEND_RESUME, "full update completed\n");
-		queue_work(msmfb->resume_workqueue, &msmfb->resume_work);
+		schedule_work(&msmfb->resume_work);
 	}
 	spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
 	wake_up(&msmfb->frame_wq);
@@ -559,12 +558,6 @@ static int msmfb_probe(struct platform_device *pdev)
 	spin_lock_init(&msmfb->update_lock);
 	mutex_init(&msmfb->panel_init_lock);
 	init_waitqueue_head(&msmfb->frame_wq);
-	msmfb->resume_workqueue = create_workqueue("panel_on");
-	if (msmfb->resume_workqueue == NULL) {
-		printk(KERN_ERR "failed to create panel_on workqueue\n");
-		ret = -ENOMEM;
-		goto error_create_workqueue;
-	}
 	INIT_WORK(&msmfb->resume_work, power_on_panel);
 	msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres,
 			       GFP_KERNEL);
@@ -589,8 +582,6 @@ static int msmfb_probe(struct platform_device *pdev)
 	return 0;
 
 error_register_framebuffer:
-	destroy_workqueue(msmfb->resume_workqueue);
-error_create_workqueue:
 	iounmap(fb->screen_base);
 error_setup_fbmem:
 	framebuffer_release(msmfb->fb);
Signature · 1 line
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#62 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>
L:      [email protected]
F:      arch/arm/mach-msm/
F:      drivers/video/msm/
F:      drivers/mmc/host/msm_sdcc.c
F:      drivers/mmc/host/msm_sdcc.h
F:      drivers/serial/msm_serial.h
F:      drivers/serial/msm_serial.c
T:      git git://codeaurora.org/quic/kernel/davidb/linux-msm.git
S:      Maintained
Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#63 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 5 lines · Daniel Walker
Quoted 4 lines · Stanislaw Gruszka
Quoted 3 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>

Oops, sorry about that. So how does the patch look? Are you gonna take it through msm tree or shall I take it?

Thanks.

Signature · 5 lines
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#64 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 10 lines · Tejun Heo
Quoted 9 lines · Daniel Walker
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

Quoted 7 lines
Quoted 4 lines

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>

Oops, sorry about that. So how does the patch look? Are you gonna take it through msm tree or shall I take it?

David ?

Daniel

Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#65 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 16 lines · Daniel Walker
Quoted 15 lines · Tejun Heo
Quoted 13 lines · Daniel Walker
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>
Quoted 6 lines
Quoted 2 lines

Oops, sorry about that. So how does the patch look? Are you gonna take it through msm tree or shall I take it?

David ?

Daniel

Is it difficult for you to test this change, Daniel? I can pull it in once we verify it still works.

Thanks,
David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#66 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 21 lines · David Brown
Quoted 19 lines · Daniel Walker
Quoted 17 lines · Tejun Heo
Quoted 5 lines · Daniel Walker
Quoted 4 lines · Stanislaw Gruszka
Quoted 3 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>

Oops, sorry about that. So how does the patch look? Are you gonna take it through msm tree or shall I take it?

Quoted 6 lines
Quoted 3 lines

David ?

Daniel

Is it difficult for you to test this change, Daniel? I can pull it in once we verify it still works.

Carl V. can test it, and review it I think ..

Daniel

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#67 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 24 lines · Daniel Walker
Quoted 23 lines · David Brown
Quoted 21 lines · Daniel Walker
Quoted 10 lines · Tejun Heo
Quoted 9 lines · Daniel Walker
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Cc Stanislaw Gruszka <[email protected]>

I'm not the right person, CC according to MAINTAINERS

Quoted 7 lines
Quoted 4 lines

ARM/QUALCOMM MSM MACHINE SUPPORT

M:      David Brown <[email protected]>
M:      Daniel Walker <[email protected]>
M:      Bryan Huntsman <[email protected]>

Oops, sorry about that. So how does the patch look? Are you gonna take it through msm tree or shall I take it?

David ?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Daniel

Is it difficult for you to test this change, Daniel? I can pull it in once we verify it still works.

Carl V. can test it, and review it I think ..

Daniel

Tested booting on MSM7X00A; appears to work fine (all I checked was that it arrived at a buildroot login prompt).

Carl V.

Signature · 7 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#68 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

In reply to Tejun Heo
Quoted 9 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

I'll pull this into the MSM tree.

Thanks,
David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
author
#69 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 5 lines · David Brown
Quoted 3 lines · Tejun Heo

With cmwq, there's no reason to use separate workqueues. Drop msmfb_info->resume_workqueue and use system_wq instead.

Quoted 8 lines
Quoted 6 lines

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

I'll pull this into the MSM tree.

I suppose it will show up in linux-next? I'm planning on marking flush_scheduled_work() deprecated there soonish, so...

Thanks.

Signature · 1 line
tejun
#70 lore raw

Re: [PATCH 20/32] video/msm_fb: use system_wq instead of dedicated workqueues

Quoted 4 lines · Tejun Heo

On Tue, Jan 25, 2011 at 03:21:31PM -0800, David Brown wrote:

I suppose it will show up in linux-next? I'm planning on marking flush_scheduled_work() deprecated there soonish, so...

Hmm, it should be there. Well, it will at least be there when the next linux-next tree comes out.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
author
#71 lore raw

PATCH 21/32 fs/aio: aio_wq isn't used in memory reclaim path

In reply to Tejun Heo

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

---
Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/aio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/aio.c +2 -2
index 8c8f6c5..dc3fcbb 100644
@@ -85,7 +85,7 @@ static int __init aio_setup(void)
 	kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 	kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 
-	aio_wq = create_workqueue("aio");
+	aio_wq = alloc_workqueue("aio", 0, 1);	/* used to limit concurrency */
 	abe_pool = mempool_create_kmalloc_pool(1, sizeof(struct aio_batch_entry));
 	BUG_ON(!abe_pool);
 
@@ -569,7 +569,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
 		spin_lock(&fput_lock);
 		list_add(&req->ki_list, &fput_head);
 		spin_unlock(&fput_lock);
-		queue_work(aio_wq, &fput_work);
+		schedule_work(&fput_work);
 	} else {
 		req->ki_filp = NULL;
 		really_put_req(ctx, req);
Signature · 1 line
1.7.1
#72 lore raw

Re: [PATCH 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 4 lines · Tejun Heo

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

I would think that just given that it may block would be enough to keep it off of the system workqueue.

Quoted 17 lines

---
Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/aio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/aio.c +0 -0
index 8c8f6c5..dc3fcbb 100644

fs/aio.c static int __init aio_setup(void) · line 88

Quoted 5 lines
fs/aio.c +1 -1
@@ -85,7 +85,7 @@ static int __init aio_setup(void)
 	kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 	kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 
-	aio_wq = create_workqueue("aio");
+	aio_wq = alloc_workqueue("aio", 0, 1);	/* used to limit concurrency */

OK, the only difference here is the removal of the WQ_MEM_RECLAIM flag, as you noted.

fs/aio.c static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) · line 572

Quoted 9 lines
fs/aio.c +1 -1
 	abe_pool = mempool_create_kmalloc_pool(1, sizeof(struct aio_batch_entry));
 	BUG_ON(!abe_pool);
 
@@ -569,7 +569,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
 		spin_lock(&fput_lock);
 		list_add(&req->ki_list, &fput_head);
 		spin_unlock(&fput_lock);
-		queue_work(aio_wq, &fput_work);
+		schedule_work(&fput_work);

I'm not sure where this change fits into the patch description. Why did you do this?

Cheers,
Jeff

author
#73 lore raw

Re: [PATCH 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Hello,

Quoted 7 lines · Jeff Moyer
Quoted 4 lines

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

I would think that just given that it may block would be enough to keep it off of the system workqueue.

Oh, workqueue now can handle parallel execution. Blocking on system workqueue is no longer a problem. One of the main reasons for this whole series.

Quoted 9 lines

fs/aio.c static int __init aio_setup(void) · line 88

Quoted 6 lines
fs/aio.c +1 -1
@@ -85,7 +85,7 @@ static int __init aio_setup(void)
 	kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 	kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 
-	aio_wq = create_workqueue("aio");
+	aio_wq = alloc_workqueue("aio", 0, 1);	/* used to limit concurrency */

OK, the only difference here is the removal of the WQ_MEM_RECLAIM flag, as you noted.

Yeap. Do you agree that the concurrency limit is necessary? If not, we can just put everything onto system_wq.

Quoted 9 lines

fs/aio.c static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) · line 572

Quoted 6 lines
fs/aio.c +1 -1
@@ -569,7 +569,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
 		spin_lock(&fput_lock);
 		list_add(&req->ki_list, &fput_head);
 		spin_unlock(&fput_lock);
-		queue_work(aio_wq, &fput_work);
+		schedule_work(&fput_work);

I'm not sure where this change fits into the patch description. Why did you do this?

Yeah, that's me being forgetful. Now that aio_wq is solely used to throttle the max concurrency of aio work items, I thought it would be better to push fput_work to system workqueue so that it doesn't interact with aio work items. I'll update the patch description.

Thanks.

Signature · 1 line
tejun
#74 lore raw

Re: [PATCH 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 8 lines · Tejun Heo

Hello,

Quoted 5 lines · Jeff Moyer
Quoted 4 lines

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

Quoted 6 lines
Quoted 2 lines

I would think that just given that it may block would be enough to keep it off of the system workqueue.

Oh, workqueue now can handle parallel execution. Blocking on system workqueue is no longer a problem. One of the main reasons for this whole series.

OK, thanks for clarifying for me.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
fs/aio.c +0 -0
@@ -85,7 +85,7 @@ static int __init aio_setup(void)
 	kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 	kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 
Quoted 8 lines
Quoted 5 lines

fs/aio.c static int __init aio_setup(void) · line 88

Quoted 2 lines
fs/aio.c +1 -1
-	aio_wq = create_workqueue("aio");
+	aio_wq = alloc_workqueue("aio", 0, 1);	/* used to limit concurrency */

OK, the only difference here is the removal of the WQ_MEM_RECLAIM flag, as you noted.

Yeap. Do you agree that the concurrency limit is necessary? If not, we can just put everything onto system_wq.

I'm not sure whether it's strictly necessary (there may very well be a need for this in the usb gadgetfs code), but keeping it the same at least seems safe.

Quoted 10 lines
Quoted 9 lines

fs/aio.c static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) · line 572

Quoted 6 lines
fs/aio.c +1 -1
@@ -569,7 +569,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
 		spin_lock(&fput_lock);
 		list_add(&req->ki_list, &fput_head);
 		spin_unlock(&fput_lock);
-		queue_work(aio_wq, &fput_work);
+		schedule_work(&fput_work);

I'm not sure where this change fits into the patch description. Why did you do this?

Quoted 4 lines

Yeah, that's me being forgetful. Now that aio_wq is solely used to throttle the max concurrency of aio work items, I thought it would be better to push fput_work to system workqueue so that it doesn't interact with aio work items. I'll update the patch description.

OK, thanks.

-Jeff

maintainer
#75 lore raw

Re: [PATCH 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 6 lines · Jeff Moyer
Quoted 2 lines

Yeap. Do you agree that the concurrency limit is necessary? If not, we can just put everything onto system_wq.

I'm not sure whether it's strictly necessary (there may very well be a need for this in the usb gadgetfs code), but keeping it the same at least seems safe.

Limiting concurrency on aio requests is exactly the opposite of what the usb gadgetfs requires. It's similarly bad for filesystem aio when there's a mix of small and large requests in flight.

-ben

#76 lore raw

Re: [PATCH 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 10 lines · Benjamin LaHaise
Quoted 6 lines · Jeff Moyer
Quoted 2 lines

Yeap. Do you agree that the concurrency limit is necessary? If not, we can just put everything onto system_wq.

I'm not sure whether it's strictly necessary (there may very well be a need for this in the usb gadgetfs code), but keeping it the same at least seems safe.

Limiting concurrency on aio requests is exactly the opposite of what the usb gadgetfs requires.

I'll have to dig on what their requirements are. After briefly looking at mailing list archives, it appears they use the aio workqueue to queue work after a completed I/O. I think Zach actually had posted a patch to change them over to using their own workqueue for that. At any rate, it may well be that they don't have a concurrency requirement (in fact, it would be surprising if they did). However, I wasn't going to propose changing the way things were done w/o someone chiming in and saying they needed it.

Quoted 2 lines

It's similarly bad for filesystem aio when there's a mix of small and large requests in flight.

Well, the aio workqueue isn't actually used by the filesystem aio paths at all (except for the fput_work, and that's being moved to the system workqueue).

Cheers,
Jeff

author
#77 lore raw

PATCH 21/32 fs/aio: aio_wq isn't used in memory reclaim path

In reply to Tejun Heo

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

Also, move fput_work to system_wq so that aio_wq is used soley to throttle the max concurrency of aio work items and fput_work doesn't interact with other work items.

---
Patch description updated to describe fput_work change. If there's no further objection, I'll push it through workqueue#for-2.6.39. Thanks.

 fs/aio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/aio.c +2 -2
Index: work/fs/aio.c
===================================================================
@@ -85,7 +85,7 @@ static int __init aio_setup(void)
 	kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 	kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
 
-	aio_wq = create_workqueue("aio");
+	aio_wq = alloc_workqueue("aio", 0, 1);	/* used to limit concurrency */
 	abe_pool = mempool_create_kmalloc_pool(1, sizeof(struct aio_batch_entry));
 	BUG_ON(!aio_wq || !abe_pool);
 
@@ -569,7 +569,7 @@ static int __aio_put_req(struct kioctx *
 		spin_lock(&fput_lock);
 		list_add(&req->ki_list, &fput_head);
 		spin_unlock(&fput_lock);
-		queue_work(aio_wq, &fput_work);
+		schedule_work(&fput_work);
 	} else {
 		req->ki_filp = NULL;
 		really_put_req(ctx, req);
Acked-by on v1 21/32
#78 lore raw

Re: [PATCH UPDATED 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 5 lines · Tejun Heo

aio_wq isn't used during memory reclaim. Convert to alloc_workqueue() without WQ_MEM_RECLAIM. It's possible to use system_wq but given that the number of work items is determined from userland and the work item may block, enforcing strict concurrency limit would be a good idea.

Quoted 7 lines

Also, move fput_work to system_wq so that aio_wq is used soley to throttle the max concurrency of aio work items and fput_work doesn't interact with other work items.

Cc Benjamin LaHaise <[email protected]>
Cc Jeff Moyer <[email protected]>

You actually missed that CC. ;-)

Quoted 4 lines

---
Patch description updated to describe fput_work change. If there's no further objection, I'll push it through workqueue#for-2.6.39. Thanks.

Looks good to me, based on not changing existing semantics.

Cheers,
Jeff

author
#79 lore raw

Re: [PATCH UPDATED 21/32] fs/aio: aio_wq isn't used in memory reclaim path

Quoted 5 lines · Jeff Moyer
Quoted 3 lines
Cc Benjamin LaHaise <[email protected]>
Cc Jeff Moyer <[email protected]>

You actually missed that CC. ;-)

Oops, sorry about that.

Quoted 8 lines
Quoted 4 lines

---
Patch description updated to describe fput_work change. If there's no further objection, I'll push it through workqueue#for-2.6.39. Thanks.

Looks good to me, based on not changing existing semantics.

Thanks. Applying to workqueue tree w/ acked by added.

Signature · 1 line
tejun
author
#80 lore raw

PATCH 22/32 ceph: fsc->*_wq's aren't used in memory reclaim path

In reply to Tejun Heo

fsc->*_wq's aren't depended upon during memory reclaim. Convert to alloc_workqueue() w/o WQ_MEM_RECLAIM.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/ceph/super.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
fs/ceph/super.c +7 -3
index 08b460a..1f6436e 100644
@@ -443,13 +443,17 @@ struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
 		goto fail_client;
 
 	err = -ENOMEM;
-	fsc->wb_wq = create_workqueue("ceph-writeback");
+	/*
+	 * The number of concurrent works can be high but they don't need
+	 * to be processed in parallel, limit concurrency.
+	 */
+	fsc->wb_wq = alloc_workqueue("ceph-writeback", 0, 1);
 	if (fsc->wb_wq == NULL)
 		goto fail_bdi;
-	fsc->pg_inv_wq = create_singlethread_workqueue("ceph-pg-invalid");
+	fsc->pg_inv_wq = alloc_workqueue("ceph-pg-invalid", 0, 1);
 	if (fsc->pg_inv_wq == NULL)
 		goto fail_wb_wq;
-	fsc->trunc_wq = create_singlethread_workqueue("ceph-trunc");
+	fsc->trunc_wq = alloc_workqueue("ceph-trunc", 0, 1);
 	if (fsc->trunc_wq == NULL)
 		goto fail_pg_inv_wq;
 
Signature · 1 line
1.7.1
#81 lore raw

Re: [PATCH 22/32] ceph: fsc->*_wq's aren't used in memory reclaim path

Quoted 9 lines · Tejun Heo

fsc->*_wq's aren't depended upon during memory reclaim. Convert to alloc_workqueue() w/o WQ_MEM_RECLAIM.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

I'll take this one through the ceph tree as well.

Thanks!
sage

Quoted 40 lines

Thanks.

 fs/ceph/super.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
fs/ceph/super.c +7 -3
index 08b460a..1f6436e 100644
@@ -443,13 +443,17 @@ struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
 		goto fail_client;
 
 	err = -ENOMEM;
-	fsc->wb_wq = create_workqueue("ceph-writeback");
+	/*
+	 * The number of concurrent works can be high but they don't need
+	 * to be processed in parallel, limit concurrency.
+	 */
+	fsc->wb_wq = alloc_workqueue("ceph-writeback", 0, 1);
 	if (fsc->wb_wq == NULL)
 		goto fail_bdi;
-	fsc->pg_inv_wq = create_singlethread_workqueue("ceph-pg-invalid");
+	fsc->pg_inv_wq = alloc_workqueue("ceph-pg-invalid", 0, 1);
 	if (fsc->pg_inv_wq == NULL)
 		goto fail_wb_wq;
-	fsc->trunc_wq = create_singlethread_workqueue("ceph-trunc");
+	fsc->trunc_wq = alloc_workqueue("ceph-trunc", 0, 1);
 	if (fsc->trunc_wq == NULL)
 		goto fail_pg_inv_wq;
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#82 lore raw

PATCH 23/32 net/ceph: make ceph_msgr_wq non-reentrant

In reply to Tejun Heo

ceph messenger code does a rather complex dancing around multithread workqueue to make sure the same work item isn't executed concurrently on different CPUs. This restriction can be provided by workqueue with WQ_NON_REENTRANT.

Make ceph_msgr_wq non-reentrant workqueue with the default concurrency level and remove the QUEUED/BUSY logic.

* This removes backoff handling in con_work() but it couldn't reliably block execution of con_work() to begin with - queue_con() can be called after the work started but before BUSY is set. It seems that it was an optimization for a rather cold path and can be safely removed.

* The number of concurrent work items is bound by the number of connections and connetions are independent from each other. With the default concurrency level, different connections will be executed independently.

---
Only compile tested. I think the dropping of backoff logic is safe but am not completely sure. Please verify it's actually okay. Feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 include/linux/ceph/messenger.h |    5 ----
 net/ceph/messenger.c           |   46 +--------------------------------------
 2 files changed, 2 insertions(+), 49 deletions(-)
include/linux/ceph/messenger.h +0 -5
index a108b42..c3011be 100644
@@ -110,17 +110,12 @@ struct ceph_msg_pos {
 
 /*
  * ceph_connection state bit flags
- *
- * QUEUED and BUSY are used together to ensure that only a single
- * thread is currently opening, reading or writing data to the socket.
  */
 #define LOSSYTX         0  /* we can close channel or drop messages on errors */
 #define CONNECTING	1
 #define NEGOTIATING	2
 #define KEEPALIVE_PENDING      3
 #define WRITE_PENDING	4  /* we have data ready to send */
-#define QUEUED          5  /* there is work queued on this connection */
-#define BUSY            6  /* work is being done */
 #define STANDBY		8  /* no outgoing messages, socket closed.  we keep
 			    * the ceph_connection around to maintain shared
 			    * state with the peer. */
net/ceph/messenger.c +2 -44

83 lines not on this page · raw message

Signature · 1 line
1.7.1
#83 lore raw

Re: [PATCH 23/32] net/ceph: make ceph_msgr_wq non-reentrant

Quoted 19 lines · Tejun Heo

ceph messenger code does a rather complex dancing around multithread workqueue to make sure the same work item isn't executed concurrently on different CPUs. This restriction can be provided by workqueue with WQ_NON_REENTRANT.

Make ceph_msgr_wq non-reentrant workqueue with the default concurrency level and remove the QUEUED/BUSY logic.

* This removes backoff handling in con_work() but it couldn't reliably block execution of con_work() to begin with - queue_con() can be called after the work started but before BUSY is set. It seems that it was an optimization for a rather cold path and can be safely removed.

* The number of concurrent work items is bound by the number of connections and connetions are independent from each other. With the default concurrency level, different connections will be executed independently.

Quoted 8 lines

---
Only compile tested. I think the dropping of backoff logic is safe but am not completely sure. Please verify it's actually okay. Feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Tejun- this is a very welcome simplification! I'll take it through the ceph tree, as I want to test it thoroughly and make sure the backoff change is correct (there was some subtlety there, IIRC).

Thanks!
sage

Quoted 130 lines

Thanks.

 include/linux/ceph/messenger.h |    5 ----
 net/ceph/messenger.c           |   46 +--------------------------------------
 2 files changed, 2 insertions(+), 49 deletions(-)
include/linux/ceph/messenger.h +0 -5
index a108b42..c3011be 100644
@@ -110,17 +110,12 @@ struct ceph_msg_pos {
 
 /*
  * ceph_connection state bit flags
- *
- * QUEUED and BUSY are used together to ensure that only a single
- * thread is currently opening, reading or writing data to the socket.
  */
 #define LOSSYTX         0  /* we can close channel or drop messages on errors */
 #define CONNECTING	1
 #define NEGOTIATING	2
 #define KEEPALIVE_PENDING      3
 #define WRITE_PENDING	4  /* we have data ready to send */
-#define QUEUED          5  /* there is work queued on this connection */
-#define BUSY            6  /* work is being done */
 #define STANDBY		8  /* no outgoing messages, socket closed.  we keep
 			    * the ceph_connection around to maintain shared
 			    * state with the peer. */
net/ceph/messenger.c +2 -44
index b6ff4a1..dff633d 100644
@@ -96,7 +96,7 @@ struct workqueue_struct *ceph_msgr_wq;
 
 int ceph_msgr_init(void)
 {
-	ceph_msgr_wq = create_workqueue("ceph-msgr");
+	ceph_msgr_wq = alloc_workqueue("ceph-msgr", WQ_NON_REENTRANT, 0);
 	if (!ceph_msgr_wq) {
 		pr_err("msgr_init failed to create workqueue\n");
 		return -ENOMEM;
@@ -1920,20 +1920,6 @@ bad_tag:
 /*
  * Atomically queue work on a connection.  Bump @con reference to
  * avoid races with connection teardown.
- *
- * There is some trickery going on with QUEUED and BUSY because we
- * only want a _single_ thread operating on each connection at any
- * point in time, but we want to use all available CPUs.
- *
- * The worker thread only proceeds if it can atomically set BUSY.  It
- * clears QUEUED and does it's thing.  When it thinks it's done, it
- * clears BUSY, then rechecks QUEUED.. if it's set again, it loops
- * (tries again to set BUSY).
- *
- * To queue work, we first set QUEUED, _then_ if BUSY isn't set, we
- * try to queue work.  If that fails (work is already queued, or BUSY)
- * we give up (work also already being done or is queued) but leave QUEUED
- * set so that the worker thread will loop if necessary.
  */
 static void queue_con(struct ceph_connection *con)
 {
@@ -1948,11 +1934,7 @@ static void queue_con(struct ceph_connection *con)
 		return;
 	}
 
-	set_bit(QUEUED, &con->state);
-	if (test_bit(BUSY, &con->state)) {
-		dout("queue_con %p - already BUSY\n", con);
-		con->ops->put(con);
-	} else if (!queue_work(ceph_msgr_wq, &con->work.work)) {
+	if (!queue_delayed_work(ceph_msgr_wq, &con->work, 0)) {
 		dout("queue_con %p - already queued\n", con);
 		con->ops->put(con);
 	} else {
@@ -1967,15 +1949,6 @@ static void con_work(struct work_struct *work)
 {
 	struct ceph_connection *con = container_of(work, struct ceph_connection,
 						   work.work);
-	int backoff = 0;
-
-more:
-	if (test_and_set_bit(BUSY, &con->state) != 0) {
-		dout("con_work %p BUSY already set\n", con);
-		goto out;
-	}
-	dout("con_work %p start, clearing QUEUED\n", con);
-	clear_bit(QUEUED, &con->state);
 
 	mutex_lock(&con->mutex);
 
@@ -1994,28 +1967,13 @@ more:
 	    try_read(con) < 0 ||
 	    try_write(con) < 0) {
 		mutex_unlock(&con->mutex);
-		backoff = 1;
 		ceph_fault(con);     /* error/fault path */
 		goto done_unlocked;
 	}
 
 done:
 	mutex_unlock(&con->mutex);
-
 done_unlocked:
-	clear_bit(BUSY, &con->state);
-	dout("con->state=%lu\n", con->state);
-	if (test_bit(QUEUED, &con->state)) {
-		if (!backoff || test_bit(OPENING, &con->state)) {
-			dout("con_work %p QUEUED reset, looping\n", con);
-			goto more;
-		}
-		dout("con_work %p QUEUED reset, but just faulted\n", con);
-		clear_bit(QUEUED, &con->state);
-	}
-	dout("con_work %p done\n", con);
-
-out:
 	con->ops->put(con);
 }
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#84 lore raw

PATCH 24/32 dlm: dlm workqueues aren't used in memory reclaim path

In reply to Tejun Heo

dlm isn't depended upon during memory reclaim and so are its two workqueues. Convert to alloc[_ordered]_workqueue() without WQ_MEM_RECLAIM. While at it, fix workqueue allocation failure handling. They return %NULL on failure not ERR_PTR() value.

Cc Christine Caulfield <[email protected]>
Cc David Teigland <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/dlm/lowcomms.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)
fs/dlm/lowcomms.c +8 -11
index 37a34c2..9aad7c0 100644
@@ -1430,20 +1430,17 @@ static void work_stop(void)
 
 static int work_start(void)
 {
-	int error;
-	recv_workqueue = create_workqueue("dlm_recv");
-	error = IS_ERR(recv_workqueue);
-	if (error) {
-		log_print("can't start dlm_recv %d", error);
-		return error;
+	recv_workqueue = alloc_workqueue("dlm_recv", 0, 1);
+	if (!recv_workqueue) {
+		log_print("can't start dlm_recv");
+		return -ENOMEM;
 	}
 
-	send_workqueue = create_singlethread_workqueue("dlm_send");
-	error = IS_ERR(send_workqueue);
-	if (error) {
-		log_print("can't start dlm_send %d", error);
+	send_workqueue = alloc_ordered_workqueue("dlm_send", 0);
+	if (!send_workqueue) {
+		log_print("can't start dlm_send");
 		destroy_workqueue(recv_workqueue);
-		return error;
+		return -ENOMEM;
 	}
 
 	return 0;
Signature · 1 line
1.7.1
#85 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Hi,

You already acked a patch to do this, which is in the DLM git tree, waiting for the next merge window:

http://git.kernel.org/?p=linux/kernel/git/teigland/dlm.git;a=commitdiff;h=dcce240ead802d42b1e45ad2fcb2ed4a399cb255

Steve.

Quoted 51 lines · Tejun Heo

dlm isn't depended upon during memory reclaim and so are its two workqueues. Convert to alloc[_ordered]_workqueue() without WQ_MEM_RECLAIM. While at it, fix workqueue allocation failure handling. They return %NULL on failure not ERR_PTR() value.

Cc Christine Caulfield <[email protected]>
Cc David Teigland <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/dlm/lowcomms.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)
fs/dlm/lowcomms.c +8 -11
index 37a34c2..9aad7c0 100644
@@ -1430,20 +1430,17 @@ static void work_stop(void)
 
 static int work_start(void)
 {
-	int error;
-	recv_workqueue = create_workqueue("dlm_recv");
-	error = IS_ERR(recv_workqueue);
-	if (error) {
-		log_print("can't start dlm_recv %d", error);
-		return error;
+	recv_workqueue = alloc_workqueue("dlm_recv", 0, 1);
+	if (!recv_workqueue) {
+		log_print("can't start dlm_recv");
+		return -ENOMEM;
 	}
 
-	send_workqueue = create_singlethread_workqueue("dlm_send");
-	error = IS_ERR(send_workqueue);
-	if (error) {
-		log_print("can't start dlm_send %d", error);
+	send_workqueue = alloc_ordered_workqueue("dlm_send", 0);
+	if (!send_workqueue) {
+		log_print("can't start dlm_send");
 		destroy_workqueue(recv_workqueue);
-		return error;
+		return -ENOMEM;
 	}
 
 	return 0;
author
#86 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Quoted 6 lines · Steven Whitehouse

Hi,

You already acked a patch to do this, which is in the DLM git tree, waiting for the next merge window:

http://git.kernel.org/?p=linux/kernel/git/teigland/dlm.git;a=commitdiff;h=dcce240ead802d42b1e45ad2fcb2ed4a399cb255

Ooh, I see. Hmmm... maybe I've asked this before but do you really need WQ_MEM_RECLAIM there? Is dlm used during memory reclaim?

Thanks.

Signature · 1 line
tejun
#87 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Hi,

Quoted 6 lines · Tejun Heo
Quoted 5 lines · Steven Whitehouse

Hi,

You already acked a patch to do this, which is in the DLM git tree, waiting for the next merge window:

Quoted 7 lines
Quoted 1 line

http://git.kernel.org/?p=linux/kernel/git/teigland/dlm.git;a=commitdiff;h=dcce240ead802d42b1e45ad2fcb2ed4a399cb255

Ooh, I see. Hmmm... maybe I've asked this before but do you really need WQ_MEM_RECLAIM there? Is dlm used during memory reclaim?

Thanks.

Yes, it is in case of deallocation of inodes, so we have to be careful about that,

Steve.

author
#88 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Hello again,

Quoted 5 lines · Steven Whitehouse
Quoted 2 lines

Ooh, I see. Hmmm... maybe I've asked this before but do you really need WQ_MEM_RECLAIM there? Is dlm used during memory reclaim?

Yes, it is in case of deallocation of inodes, so we have to be careful about that,

I see. I'm still slightly unsure about the WQ_MEM_RECLAIM rules when it comes to distributed file systems and stuff related to them, but I think it basically comes down to whether the code can be in the swap path or not. e.g. for nfs backed write shared mapped files, nfs definitely can be used during memory reclaim _but_ it's not guaranteed to make forward progress under memory pressure and thus can't be depended upon and shouldn't be used for swap. IOW, it may free memory but it's not in the critical path which should guarantee forward progress. Isn't dlm the same case?

Thank you.

Signature · 1 line
tejun
#89 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Hi,

Quoted 19 lines · Tejun Heo

Hello again,

Quoted 5 lines · Steven Whitehouse
Quoted 2 lines

Ooh, I see. Hmmm... maybe I've asked this before but do you really need WQ_MEM_RECLAIM there? Is dlm used during memory reclaim?

Yes, it is in case of deallocation of inodes, so we have to be careful about that,

I see. I'm still slightly unsure about the WQ_MEM_RECLAIM rules when it comes to distributed file systems and stuff related to them, but I think it basically comes down to whether the code can be in the swap path or not. e.g. for nfs backed write shared mapped files, nfs definitely can be used during memory reclaim _but_ it's not guaranteed to make forward progress under memory pressure and thus can't be depended upon and shouldn't be used for swap. IOW, it may free memory but it's not in the critical path which should guarantee forward progress. Isn't dlm the same case?

Quoted 2 lines

Thank you.

No, the issue arises in case an inode is being ejected from cache with a 0 link count (and this need deallocation). At this point the dlm is required in order to coordinate which node will perform the deallocation, but if it blocks on memory reclaim (via the fs, so GFP_NOFS is ok, but GFP_KERNEL is not) then it can land up calling back into the fs via a shrink of the dcache which can potentially then also call back into the dlm.

Since there is no workqueue option to indicate that GFP_NOFS is ok, but GFP_KERNEL is not, I think in the workqueue case we must mark it as WQ_MEM_RECLAIM. So far as I can tell thats a limitation of task creation which was the reason for the pre-allocated rescuer thread. I'd rather be safe than sorry in this case,

Steve.

author
#90 lore raw

Re: [PATCH 24/32] dlm: dlm workqueues aren't used in memory reclaim path

Hello,

Quoted 7 lines · Steven Whitehouse

No, the issue arises in case an inode is being ejected from cache with a 0 link count (and this need deallocation). At this point the dlm is required in order to coordinate which node will perform the deallocation, but if it blocks on memory reclaim (via the fs, so GFP_NOFS is ok, but GFP_KERNEL is not) then it can land up calling back into the fs via a shrink of the dcache which can potentially then also call back into the dlm.

I see. Thanks for the explanation.

Quoted 5 lines

Since there is no workqueue option to indicate that GFP_NOFS is ok, but GFP_KERNEL is not, I think in the workqueue case we must mark it as WQ_MEM_RECLAIM. So far as I can tell thats a limitation of task creation which was the reason for the pre-allocated rescuer thread. I'd rather be safe than sorry in this case,

Yeap, in such case, WQ_MEM_RECLAIM seems like the right choice. It may call into GFP_KERNEL path again, but the dependency chain isn't hard. It will be broken pretty soon and rescuer will kick in.

As the case is rather special, it might be a good idea to explain why WQ_MEM_RECLAIM is necessary for future references?

Thank you.

Signature · 1 line
tejun
author
#91 lore raw

PATCH 25/32 ext4: convert to alloc_workqueue()

In reply to Tejun Heo

Convert create_workqueue() to alloc_workqueue(). This is an identity conversion.

Cc "Theodore Ts'o" <[email protected]>
Cc Andreas Dilger <[email protected]>

---
It might be helpful to use higher max concurrency. I don't think it would make a lot of difference tho. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/ext4/super.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
fs/ext4/super.c +6 -1
index fb15c9c..f682c40 100644
@@ -3495,7 +3495,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	percpu_counter_set(&sbi->s_dirtyblocks_counter, 0);
 
 no_journal:
-	EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten");
+	/*
+	 * The maximum number of concurrent works can be high and
+	 * concurrency isn't really necessary.  Limit it to 1.
+	 */
+	EXT4_SB(sb)->dio_unwritten_wq =
+		alloc_workqueue("ext4-dio-unwritten", WQ_MEM_RECLAIM, 1);
 	if (!EXT4_SB(sb)->dio_unwritten_wq) {
 		printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n");
 		goto failed_mount_wq;
Signature · 1 line
1.7.1
author
#92 lore raw

PATCH 26/32 ocfs2: use system_wq instead of ocfs2_quota_wq

In reply to Tejun Heo

ocfs2_quota_wq is not depended upon during memory reclaim and, with cmwq, there's no reason to use a dedicated workqueue. Drop ocfs2_quota_wq and use system_wq instead. dqi_sync_work is already sync canceled on quota disable and no further synchronization is necessary.

This change makes ocfs2_quota_setup/shutdown() noops. Both functions removed.

Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/ocfs2/quota.h        |    3 ---
 fs/ocfs2/quota_global.c |   27 ++++-----------------------
 fs/ocfs2/super.c        |    7 -------
 3 files changed, 4 insertions(+), 33 deletions(-)
fs/ocfs2/quota.h +0 -3
index 196fcb5..d5ab56c 100644
@@ -114,7 +114,4 @@ int ocfs2_local_write_dquot(struct dquot *dquot);
 extern const struct dquot_operations ocfs2_quota_operations;
 extern struct quota_format_type ocfs2_quota_format;
 
-int ocfs2_quota_setup(void);
-void ocfs2_quota_shutdown(void);
-
 #endif /* _OCFS2_QUOTA_H */
fs/ocfs2/quota_global.c +4 -23
index 4607923..a73f641 100644
@@ -63,8 +63,6 @@
  *        write to gf
  */
 
-static struct workqueue_struct *ocfs2_quota_wq = NULL;
-
 static void qsync_work_fn(struct work_struct *work);
 
 static void ocfs2_global_disk2memdqb(struct dquot *dquot, void *dp)
@@ -400,8 +398,8 @@ int ocfs2_global_read_info(struct super_block *sb, int type)
 						OCFS2_QBLK_RESERVED_SPACE;
 	oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi);
 	INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn);
-	queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
-			   msecs_to_jiffies(oinfo->dqi_syncms));
+	schedule_delayed_work(&oinfo->dqi_sync_work,
+			      msecs_to_jiffies(oinfo->dqi_syncms));
 
 out_err:
 	mlog_exit(status);
@@ -635,8 +633,8 @@ static void qsync_work_fn(struct work_struct *work)
 	struct super_block *sb = oinfo->dqi_gqinode->i_sb;
 
 	dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type);
-	queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
-			   msecs_to_jiffies(oinfo->dqi_syncms));
+	schedule_delayed_work(&oinfo->dqi_sync_work,
+			      msecs_to_jiffies(oinfo->dqi_syncms));
 }
 
 /*
@@ -923,20 +921,3 @@ const struct dquot_operations ocfs2_quota_operations = {
 	.alloc_dquot	= ocfs2_alloc_dquot,
 	.destroy_dquot	= ocfs2_destroy_dquot,
 };
-
-int ocfs2_quota_setup(void)
-{
-	ocfs2_quota_wq = create_workqueue("o2quot");
-	if (!ocfs2_quota_wq)
-		return -ENOMEM;
-	return 0;
-}
-
-void ocfs2_quota_shutdown(void)
-{
-	if (ocfs2_quota_wq) {
-		flush_workqueue(ocfs2_quota_wq);
-		destroy_workqueue(ocfs2_quota_wq);
-		ocfs2_quota_wq = NULL;
-	}
-}
fs/ocfs2/super.c +0 -7
index cfeab7c..23dd818 100644
@@ -1639,16 +1639,11 @@ static int __init ocfs2_init(void)
 		mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
 	}
 
-	status = ocfs2_quota_setup();
-	if (status)
-		goto leave;
-
 	ocfs2_set_locking_protocol();
 
 	status = register_quota_format(&ocfs2_quota_format);
 leave:
 	if (status < 0) {
-		ocfs2_quota_shutdown();
 		ocfs2_free_mem_caches();
 		exit_ocfs2_uptodate_cache();
 	}
@@ -1665,8 +1660,6 @@ static void __exit ocfs2_exit(void)
 {
 	mlog_entry_void();
 
-	ocfs2_quota_shutdown();
-
 	if (ocfs2_wq) {
 		flush_workqueue(ocfs2_wq);
 		destroy_workqueue(ocfs2_wq);
Signature · 1 line
1.7.1
author
#93 lore raw

PATCH 27/32 reiserfs: make commit_wq use the default concurrency level

In reply to Tejun Heo

The maximum number of concurrent work items queued on commit_wq is bound by the number of active journals. Convert to alloc_workqueue() and use the default concurrency level so that they can be processed in parallel.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/reiserfs/journal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/reiserfs/journal.c +1 -1
index d31bce1..ee311c0 100644
@@ -2883,7 +2883,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
 	reiserfs_mounted_fs_count++;
 	if (reiserfs_mounted_fs_count <= 1) {
 		reiserfs_write_unlock(sb);
-		commit_wq = create_workqueue("reiserfs");
+		commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0);
 		reiserfs_write_lock(sb);
 	}
 
Signature · 1 line
1.7.1
author
#94 lore raw

PATCH 28/32 xfs: convert to alloc_workqueue()

In reply to Tejun Heo

Convert from create[_singlethread]_workqueue() to alloc_workqueue().

* xfsdatad_workqueue and xfsconvertd_workqueue are identity converted. Using higher concurrency limit might be useful but given the complexity of workqueue usage in xfs, proceeding cautiously seems better.

* xfs_mru_reap_wq is converted to non-ordered workqueue with max concurrency of 1 as the work items don't require any specific ordering and already have proper synchronization. It seems it was singlethreaded to save worker threads, which is no longer a concern.

Cc Alex Elder <[email protected]>
Cc Christoph Hellwig <[email protected]>

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 fs/xfs/linux-2.6/xfs_buf.c |    5 +++--
 fs/xfs/xfs_mru_cache.c     |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
fs/xfs/linux-2.6/xfs_buf.c +3 -2
index 4c5deb6..d6da590 100644
@@ -1944,11 +1944,12 @@ xfs_buf_init(void)
 	if (!xfslogd_workqueue)
 		goto out_free_buf_zone;
 
-	xfsdatad_workqueue = create_workqueue("xfsdatad");
+	xfsdatad_workqueue = alloc_workqueue("xfsdatad", WQ_MEM_RECLAIM, 1);
 	if (!xfsdatad_workqueue)
 		goto out_destroy_xfslogd_workqueue;
 
-	xfsconvertd_workqueue = create_workqueue("xfsconvertd");
+	xfsconvertd_workqueue = alloc_workqueue("xfsconvertd",
+						WQ_MEM_RECLAIM, 1);
 	if (!xfsconvertd_workqueue)
 		goto out_destroy_xfsdatad_workqueue;
 
fs/xfs/xfs_mru_cache.c +1 -1
index 45ce15d..2acdc77 100644
@@ -309,7 +309,7 @@ xfs_mru_cache_init(void)
 	if (!xfs_mru_elem_zone)
 		goto out;
 
-	xfs_mru_reap_wq = create_singlethread_workqueue("xfs_mru_cache");
+	xfs_mru_reap_wq = alloc_workqueue("xfs_mru_cache", WQ_MEM_RECLAIM, 1);
 	if (!xfs_mru_reap_wq)
 		goto out_destroy_mru_elem_zone;
 
Signature · 1 line
1.7.1
author
#95 lore raw

PATCH 29/32 net/9p: use system_wq instead of p9_mux_wq

In reply to Tejun Heo

With cmwq, there's no reason to use a dedicated workqueue in trans_fd. Drop p9_mux_wq and use system_wq instead. The used work items are already sync canceled in p9_conn_destroy() and doesn't require further synchronization.

Cc Eric Van Hensbergen <[email protected]>
Cc Ron Minnich <[email protected]>
Cc Latchesar Ionkov <[email protected]>

---
Lightly tested with userland server. Seems to work fine. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 net/9p/trans_fd.c |   20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)
net/9p/trans_fd.c +5 -15
index 078eb16..e9f797d 100644
@@ -155,7 +155,6 @@ struct p9_conn {
 
 static DEFINE_SPINLOCK(p9_poll_lock);
 static LIST_HEAD(p9_poll_pending_list);
-static struct workqueue_struct *p9_mux_wq;
 static struct task_struct *p9_poll_task;
 
 static void p9_mux_poll_stop(struct p9_conn *m)
@@ -384,7 +383,7 @@ static void p9_read_work(struct work_struct *work)
 
 		if (n & POLLIN) {
 			P9_DPRINTK(P9_DEBUG_TRANS, "sched read work %p\n", m);
-			queue_work(p9_mux_wq, &m->rq);
+			schedule_work(&m->rq);
 		} else
 			clear_bit(Rworksched, &m->wsched);
 	} else
@@ -497,7 +496,7 @@ static void p9_write_work(struct work_struct *work)
 
 		if (n & POLLOUT) {
 			P9_DPRINTK(P9_DEBUG_TRANS, "sched write work %p\n", m);
-			queue_work(p9_mux_wq, &m->wq);
+			schedule_work(&m->wq);
 		} else
 			clear_bit(Wworksched, &m->wsched);
 	} else
@@ -629,7 +628,7 @@ static void p9_poll_mux(struct p9_conn *m)
 		P9_DPRINTK(P9_DEBUG_TRANS, "mux %p can read\n", m);
 		if (!test_and_set_bit(Rworksched, &m->wsched)) {
 			P9_DPRINTK(P9_DEBUG_TRANS, "sched read work %p\n", m);
-			queue_work(p9_mux_wq, &m->rq);
+			schedule_work(&m->rq);
 		}
 	}
 
@@ -639,7 +638,7 @@ static void p9_poll_mux(struct p9_conn *m)
 		if ((m->wsize || !list_empty(&m->unsent_req_list)) &&
 		    !test_and_set_bit(Wworksched, &m->wsched)) {
 			P9_DPRINTK(P9_DEBUG_TRANS, "sched write work %p\n", m);
-			queue_work(p9_mux_wq, &m->wq);
+			schedule_work(&m->wq);
 		}
 	}
 }
@@ -677,7 +676,7 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
 		n = p9_fd_poll(m->client, NULL);
 
 	if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched))
-		queue_work(p9_mux_wq, &m->wq);
+		schedule_work(&m->wq);
 
 	return 0;
 }
@@ -1083,15 +1082,8 @@ static int p9_poll_proc(void *a)
 
 int p9_trans_fd_init(void)
 {
-	p9_mux_wq = create_workqueue("v9fs");
-	if (!p9_mux_wq) {
-		printk(KERN_WARNING "v9fs: mux: creating workqueue failed\n");
-		return -ENOMEM;
-	}
-
 	p9_poll_task = kthread_run(p9_poll_proc, NULL, "v9fs-poll");
 	if (IS_ERR(p9_poll_task)) {
-		destroy_workqueue(p9_mux_wq);
 		printk(KERN_WARNING "v9fs: mux: creating poll task failed\n");
 		return PTR_ERR(p9_poll_task);
 	}
@@ -1109,6 +1101,4 @@ void p9_trans_fd_exit(void)
 	v9fs_unregister_trans(&p9_tcp_trans);
 	v9fs_unregister_trans(&p9_unix_trans);
 	v9fs_unregister_trans(&p9_fd_trans);
-
-	destroy_workqueue(p9_mux_wq);
 }
Signature · 1 line
1.7.1
author
#96 lore raw

PATCH 30/32 net/9p: replace p9_poll_task with a work

In reply to Tejun Heo

Now that cmwq can handle high concurrency, it's more efficient to use work than a dedicated kthread. Convert p9_poll_proc() to a work function for p9_poll_work and make p9_pollwake() schedule it on each poll event. The work is sync flushed on module exit.

Cc Eric Van Hensbergen <[email protected]>
Cc Ron Minnich <[email protected]>
Cc Latchesar Ionkov <[email protected]>

---
Lightly tested with userland server. Seems to work fine. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 net/9p/trans_fd.c |   32 ++++++++------------------------
 1 files changed, 8 insertions(+), 24 deletions(-)
net/9p/trans_fd.c +8 -24
index e9f797d..a30471e 100644
@@ -153,9 +153,11 @@ struct p9_conn {
 	unsigned long wsched;
 };
 
+static void p9_poll_workfn(struct work_struct *work);
+
 static DEFINE_SPINLOCK(p9_poll_lock);
 static LIST_HEAD(p9_poll_pending_list);
-static struct task_struct *p9_poll_task;
+static DECLARE_WORK(p9_poll_work, p9_poll_workfn);
 
 static void p9_mux_poll_stop(struct p9_conn *m)
 {
@@ -515,15 +517,14 @@ static int p9_pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key)
 		container_of(wait, struct p9_poll_wait, wait);
 	struct p9_conn *m = pwait->conn;
 	unsigned long flags;
-	DECLARE_WAITQUEUE(dummy_wait, p9_poll_task);
 
 	spin_lock_irqsave(&p9_poll_lock, flags);
 	if (list_empty(&m->poll_pending_link))
 		list_add_tail(&m->poll_pending_link, &p9_poll_pending_list);
 	spin_unlock_irqrestore(&p9_poll_lock, flags);
 
-	/* perform the default wake up operation */
-	return default_wake_function(&dummy_wait, mode, sync, key);
+	schedule_work(&p9_poll_work);
+	return 1;
 }
 
 /**
@@ -1046,12 +1047,12 @@ static struct p9_trans_module p9_fd_trans = {
  *
  */
 
-static int p9_poll_proc(void *a)
+static void p9_poll_workfn(struct work_struct *work)
 {
 	unsigned long flags;
 
 	P9_DPRINTK(P9_DEBUG_TRANS, "start %p\n", current);
- repeat:
+
 	spin_lock_irqsave(&p9_poll_lock, flags);
 	while (!list_empty(&p9_poll_pending_list)) {
 		struct p9_conn *conn = list_first_entry(&p9_poll_pending_list,
@@ -1066,28 +1067,11 @@ static int p9_poll_proc(void *a)
 	}
 	spin_unlock_irqrestore(&p9_poll_lock, flags);
 
-	set_current_state(TASK_INTERRUPTIBLE);
-	if (list_empty(&p9_poll_pending_list)) {
-		P9_DPRINTK(P9_DEBUG_TRANS, "sleeping...\n");
-		schedule();
-	}
-	__set_current_state(TASK_RUNNING);
-
-	if (!kthread_should_stop())
-		goto repeat;
-
 	P9_DPRINTK(P9_DEBUG_TRANS, "finish\n");
-	return 0;
 }
 
 int p9_trans_fd_init(void)
 {
-	p9_poll_task = kthread_run(p9_poll_proc, NULL, "v9fs-poll");
-	if (IS_ERR(p9_poll_task)) {
-		printk(KERN_WARNING "v9fs: mux: creating poll task failed\n");
-		return PTR_ERR(p9_poll_task);
-	}
-
 	v9fs_register_trans(&p9_tcp_trans);
 	v9fs_register_trans(&p9_unix_trans);
 	v9fs_register_trans(&p9_fd_trans);
@@ -1097,7 +1081,7 @@ int p9_trans_fd_init(void)
 
 void p9_trans_fd_exit(void)
 {
-	kthread_stop(p9_poll_task);
+	flush_work_sync(&p9_poll_work);
 	v9fs_unregister_trans(&p9_tcp_trans);
 	v9fs_unregister_trans(&p9_unix_trans);
 	v9fs_unregister_trans(&p9_fd_trans);
Signature · 1 line
1.7.1
author
#97 lore raw

PATCH 31/32 rds/ib: use system_wq instead of rds_ib_fmr_wq

In reply to Tejun Heo

With cmwq, there's no reason to use dedicated rds_ib_fmr_wq - it's not in the memory reclaim path and the maximum number of concurrent work items is bound by the number of devices. Drop it and use system_wq instead. This rds_ib_fmr_init/exit() noops. Both removed.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 net/rds/ib.c      |    9 +--------
 net/rds/ib.h      |    2 --
 net/rds/ib_rdma.c |   27 +++------------------------
 3 files changed, 4 insertions(+), 34 deletions(-)
net/rds/ib.c +1 -8
index 4123967..cce19f9 100644
@@ -364,7 +364,6 @@ void rds_ib_exit(void)
 	rds_ib_sysctl_exit();
 	rds_ib_recv_exit();
 	rds_trans_unregister(&rds_ib_transport);
-	rds_ib_fmr_exit();
 }
 
 struct rds_transport rds_ib_transport = {
@@ -400,13 +399,9 @@ int rds_ib_init(void)
 
 	INIT_LIST_HEAD(&rds_ib_devices);
 
-	ret = rds_ib_fmr_init();
-	if (ret)
-		goto out;
-
 	ret = ib_register_client(&rds_ib_client);
 	if (ret)
-		goto out_fmr_exit;
+		goto out;
 
 	ret = rds_ib_sysctl_init();
 	if (ret)
@@ -430,8 +425,6 @@ out_sysctl:
 	rds_ib_sysctl_exit();
 out_ibreg:
 	rds_ib_unregister_client();
-out_fmr_exit:
-	rds_ib_fmr_exit();
 out:
 	return ret;
 }
net/rds/ib.h +0 -2
index e34ad03..4297d92 100644
@@ -307,8 +307,6 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
 void rds_ib_sync_mr(void *trans_private, int dir);
 void rds_ib_free_mr(void *trans_private, int invalidate);
 void rds_ib_flush_mrs(void);
-int rds_ib_fmr_init(void);
-void rds_ib_fmr_exit(void);
 
 /* ib_recv.c */
 int rds_ib_recv_init(void);
net/rds/ib_rdma.c +3 -24
index 18a833c..819c35a 100644
@@ -38,8 +38,6 @@
 #include "ib.h"
 #include "xlist.h"
 
-static struct workqueue_struct *rds_ib_fmr_wq;
-
 static DEFINE_PER_CPU(unsigned long, clean_list_grace);
 #define CLEAN_LIST_BUSY_BIT 0
 
@@ -307,7 +305,7 @@ static struct rds_ib_mr *rds_ib_alloc_fmr(struct rds_ib_device *rds_ibdev)
 	int err = 0, iter = 0;
 
 	if (atomic_read(&pool->dirty_count) >= pool->max_items / 10)
-		queue_delayed_work(rds_ib_fmr_wq, &pool->flush_worker, 10);
+		schedule_delayed_work(&pool->flush_worker, 10);
 
 	while (1) {
 		ibmr = rds_ib_reuse_fmr(pool);
@@ -696,24 +694,6 @@ out_nolock:
 	return ret;
 }
 
-int rds_ib_fmr_init(void)
-{
-	rds_ib_fmr_wq = create_workqueue("rds_fmr_flushd");
-	if (!rds_ib_fmr_wq)
-		return -ENOMEM;
-	return 0;
-}
-
-/*
- * By the time this is called all the IB devices should have been torn down and
- * had their pools freed.  As each pool is freed its work struct is waited on,
- * so the pool flushing work queue should be idle by the time we get here.
- */
-void rds_ib_fmr_exit(void)
-{
-	destroy_workqueue(rds_ib_fmr_wq);
-}
-
 static void rds_ib_mr_pool_flush_worker(struct work_struct *work)
 {
 	struct rds_ib_mr_pool *pool = container_of(work, struct rds_ib_mr_pool, flush_worker.work);
@@ -741,7 +721,7 @@ void rds_ib_free_mr(void *trans_private, int invalidate)
 	/* If we've pinned too many pages, request a flush */
 	if (atomic_read(&pool->free_pinned) >= pool->max_free_pinned ||
 	    atomic_read(&pool->dirty_count) >= pool->max_items / 10)
-		queue_delayed_work(rds_ib_fmr_wq, &pool->flush_worker, 10);
+		schedule_delayed_work(&pool->flush_worker, 10);
 
 	if (invalidate) {
 		if (likely(!in_interrupt())) {
@@ -749,8 +729,7 @@ void rds_ib_free_mr(void *trans_private, int invalidate)
 		} else {
 			/* We get here if the user created a MR marked
 			 * as use_once and invalidate at the same time. */
-			queue_delayed_work(rds_ib_fmr_wq,
-					   &pool->flush_worker, 10);
+			schedule_delayed_work(&pool->flush_worker, 10);
 		}
 	}
 
Signature · 1 line
1.7.1
author
#98 lore raw

PATCH 32/32 rxrpc: rxrpc_workqueue isn't used during memory reclaim

In reply to Tejun Heo

rxrpc_workqueue isn't depended upon while reclaiming memory. Convert to alloc_workqueue() without WQ_MEM_RECLAIM.

---
Only compile tested. Please feel free to take it into the subsystem tree or simply ack - I'll route it through the wq tree.

Thanks.

 net/rxrpc/af_rxrpc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/rxrpc/af_rxrpc.c +1 -1
index 0b9bb20..74c064c 100644
@@ -808,7 +808,7 @@ static int __init af_rxrpc_init(void)
 		goto error_call_jar;
 	}
 
-	rxrpc_workqueue = create_workqueue("krxrpcd");
+	rxrpc_workqueue = alloc_workqueue("krxrpcd", 0, 1);
 	if (!rxrpc_workqueue) {
 		printk(KERN_NOTICE "RxRPC: Failed to allocate work queue\n");
 		goto error_work_queue;
Signature · 1 line
1.7.1
author
#99 lore raw
In reply to Tejun Heo

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.

0006-acpi-kacpi-_wq-don-t-need-WQ_MEM_RECLAIM.patch 0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch 0012-i2o-use-alloc_workqueue-instead-of-create_workqueue.patch 0013-misc-iwmc3200top-use-system_wq-instead-of-dedicated-.patch 0016-scsi-be2iscsi-qla2xxx-convert-to-alloc_workqueue.patch 0018-scsi-scsi_tgt_lib-scsi_tgtd-isn-t-used-in-memory-rec.patch 0019-usb-ueagle-atm-use-system_wq-instead-of-dedicated-wo.patch 0025-ext4-convert-to-alloc_workqueue.patch 0026-ocfs2-use-system_wq-instead-of-ocfs2_quota_wq.patch 0027-reiserfs-make-commit_wq-use-the-default-concurrency-.patch 0028-xfs-convert-to-alloc_workqueue.patch 0029-net-9p-use-system_wq-instead-of-p9_mux_wq.patch 0030-net-9p-replace-p9_poll_task-with-a-work.patch 0031-rds-ib-use-system_wq-instead-of-rds_ib_fmr_wq.patch

The whole series can be found at the following URL.

http://thread.gmane.org/gmane.linux.kernel/1082587

Thank you.

Signature · 1 line
tejun
#100 lore raw
Quoted 8 lines · Tejun Heo

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.
..
0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch

Feel free to add my

to this.

I looked it over, and didn't see anything objectionable.

Dave

author
#101 lore raw
Quoted 10 lines · Dave Jones
Quoted 8 lines · Tejun Heo

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.
..
0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch

Quoted 5 lines

Feel free to add my

to this.

I looked it over, and didn't see anything objectionable.

As the patch is going through wq tree, I added Acked-by instead of Signed-off-by.

Thank you.

Signature · 1 line
tejun
Acked-by
#102 lore raw
In reply to Tejun Heo

Tejun,

Here's my ack for patch #16 from the QLogic side:

Cheers,
Madhu

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tejun Heo
Sent: Tuesday, January 25, 2011 6:29 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Andrew Vasquez; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCHSET] workqueue: update workqueue users - replace create_workqueue()

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.

0006-acpi-kacpi-_wq-don-t-need-WQ_MEM_RECLAIM.patch 0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch 0012-i2o-use-alloc_workqueue-instead-of-create_workqueue.patch 0013-misc-iwmc3200top-use-system_wq-instead-of-dedicated-.patch 0016-scsi-be2iscsi-qla2xxx-convert-to-alloc_workqueue.patch 0018-scsi-scsi_tgt_lib-scsi_tgtd-isn-t-used-in-memory-rec.patch 0019-usb-ueagle-atm-use-system_wq-instead-of-dedicated-wo.patch 0025-ext4-convert-to-alloc_workqueue.patch 0026-ocfs2-use-system_wq-instead-of-ocfs2_quota_wq.patch 0027-reiserfs-make-commit_wq-use-the-default-concurrency-.patch 0028-xfs-convert-to-alloc_workqueue.patch 0029-net-9p-use-system_wq-instead-of-p9_mux_wq.patch 0030-net-9p-replace-p9_poll_task-with-a-work.patch 0031-rds-ib-use-system_wq-instead-of-rds_ib_fmr_wq.patch

The whole series can be found at the following URL.

http://thread.gmane.org/gmane.linux.kernel/1082587

Thank you.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.

#103 lore raw
In reply to Tejun Heo
Quoted 8 lines · Tejun Heo

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.

0019-usb-ueagle-atm-use-system_wq-instead-of-dedicated-wo.patch

I've already taken this in my usb-next tree to go into .39.

thanks,

greg k-h

author
#104 lore raw
In reply to Tejun Heo
Quoted 7 lines · Tejun Heo

Hello,

There was no response for the following patches and I'm planning on routing them through workqueue#for-2.6.39. If you have an objection or want to take the patch through a different tree, please let me know.

Quoted 14 lines

0006-acpi-kacpi-_wq-don-t-need-WQ_MEM_RECLAIM.patch 0007-cpufreq-use-system_wq-instead-of-dedicated-workqueue.patch 0012-i2o-use-alloc_workqueue-instead-of-create_workqueue.patch 0013-misc-iwmc3200top-use-system_wq-instead-of-dedicated-.patch 0016-scsi-be2iscsi-qla2xxx-convert-to-alloc_workqueue.patch 0018-scsi-scsi_tgt_lib-scsi_tgtd-isn-t-used-in-memory-rec.patch 0019-usb-ueagle-atm-use-system_wq-instead-of-dedicated-wo.patch 0025-ext4-convert-to-alloc_workqueue.patch 0026-ocfs2-use-system_wq-instead-of-ocfs2_quota_wq.patch 0027-reiserfs-make-commit_wq-use-the-default-concurrency-.patch 0028-xfs-convert-to-alloc_workqueue.patch 0029-net-9p-use-system_wq-instead-of-p9_mux_wq.patch 0030-net-9p-replace-p9_poll_task-with-a-work.patch 0031-rds-ib-use-system_wq-instead-of-rds_ib_fmr_wq.patch

Patches applied to wq#for-2.6.39 w/ collected acks added.

Thank you.

Signature · 1 line
tejun