Skip to contentSkip to conversation

mtd: don't use flush_scheduled_work()

PATCH Applied Tejun Heo 16 participants 33 messages Dec 11, 2010 – Jan 31, 2011 9 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Tejun Heo

author
#1 lore raw

PATCH 27/30 mtd: don't use flush_scheduled_work()

flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush cxt->work_{erase|write} on removal instead.

---
This is part of a series to remove flush_scheduled_work() usage to prepare for deprecation of flush_scheduled_work(). Patches in this series are self contained and mostly straight-forward.

Please feel free to take it into the appropriate tree, or just ack it. In the latter case, I'll merge the patch through the workqueue tree during the next merge window.

If you're seeing this patch for the second time, it's because the commit hasn't showed up in mainline yet. Please let me know what should be done.

Thank you.

 drivers/mtd/mtdoops.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mtd/mtdoops.c +2 -1
index 1ee72f3..8b10273 100644
@@ -396,7 +396,8 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
 		printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n");
 
 	cxt->mtd = NULL;
-	flush_scheduled_work();
+	flush_work_sync(&cxt->work_erase);
+	flush_work_sync(&cxt->work_write);
 }
 
 
Signature · 1 line
1.7.1
#2 lore raw
Quoted 11 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush cxt->work_{erase|write} on removal instead.

---
This is part of a series to remove flush_scheduled_work() usage to prepare for deprecation of flush_scheduled_work(). Patches in this series are self contained and mostly straight-forward.

Quoted 7 lines

Please feel free to take it into the appropriate tree, or just ack it. In the latter case, I'll merge the patch through the workqueue tree during the next merge window.

If you're seeing this patch for the second time, it's because the commit hasn't showed up in mainline yet. Please let me know what should be done.

Pushed to l2-mtd-2.6.git, thanks. This means this will be merged to the mtd tree a bit later and will go upstream.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#4 lore raw

Re: [PATCH 07/30] ocfs2: don't use flush_scheduled_work()

Quoted 10 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed.

* cancel_delayed_work() + flush_schedule_work() -> cancel_delayed_work_sync().

* flush qs->qs_work directly on exit instead.

Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Signature · 9 lines
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

Joel Becker
Senior Development Manager
Oracle
E-mail: [email protected]
Phone: (650) 506-8127

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

At Sat, 11 Dec 2010 17:51:26 +0100,

Quoted 14 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed.

* cancel[_delayed]_work() + flush_scheduled_work() -> cancel[_delayed]_work_sync().

* wm8350, wm8753 and soc-core use custom code to cancel a delayed work, execute it immediately if it was pending and wait for its completion. This is equivalent to flush_delayed_work_sync(). Use it instead.

Cc Takashi Iwai <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Quoted 8 lines

---
This is part of a series to remove flush_scheduled_work() usage to prepare for deprecation of flush_scheduled_work(). Patches in this series are self contained and mostly straight-forward.

Please feel free to take it into the appropriate tree, or just ack it. In the latter case, I'll merge the patch through the workqueue tree during the next merge window.

The most of parts look OK to me, but I'm not sure about ASoC changes, e.g. below one:

Quoted 16 lines
sound/soc/codecs/wm8350.c +0 -1
index 7611add..b3e9fac 100644
@@ -1626,7 +1626,6 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 {
 	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
 	struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
-	int ret;
 
 	wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
 			  WM8350_JDL_ENA | WM8350_JDR_ENA);
@@ -1641,15 +1640,9 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 	priv->hpr.jack = NULL;
 	priv->mic.jack = NULL;
 

sound/soc/codecs/wm8350.c static int wm8350_codec_remove(struct snd_soc_codec *codec) · line 1645

Quoted 10 lines
sound/soc/codecs/wm8350.c +1 -7
-	/* cancel any work waiting to be queued. */
-	ret = cancel_delayed_work(&codec->delayed_work);
-
 	/* if there was any work waiting then we run it now and
 	 * wait for its completion */
-	if (ret) {
-		schedule_delayed_work(&codec->delayed_work, 0);
-		flush_scheduled_work();
-	}
+	flush_delayed_work_sync(&codec->delayed_work);

I vaguely remember Liam introduced this kind of code by some reason.

Liam, isn't it better for cancel_delayed_work_sync(), or should it be like the above?

thanks,

Takashi

author
#7 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Hello, Takashi.

Quoted 29 lines · Takashi Iwai
Quoted 16 lines
sound/soc/codecs/wm8350.c +0 -1
index 7611add..b3e9fac 100644
@@ -1626,7 +1626,6 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 {
 	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
 	struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
-	int ret;
 
 	wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
 			  WM8350_JDL_ENA | WM8350_JDR_ENA);
@@ -1641,15 +1640,9 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 	priv->hpr.jack = NULL;
 	priv->mic.jack = NULL;
 

sound/soc/codecs/wm8350.c static int wm8350_codec_remove(struct snd_soc_codec *codec) · line 1645

Quoted 10 lines
sound/soc/codecs/wm8350.c +1 -7
-	/* cancel any work waiting to be queued. */
-	ret = cancel_delayed_work(&codec->delayed_work);
-
 	/* if there was any work waiting then we run it now and
 	 * wait for its completion */
-	if (ret) {
-		schedule_delayed_work(&codec->delayed_work, 0);
-		flush_scheduled_work();
-	}
+	flush_delayed_work_sync(&codec->delayed_work);

I vaguely remember Liam introduced this kind of code by some reason.

Quoted 2 lines

Liam, isn't it better for cancel_delayed_work_sync(), or should it be like the above?

flush_delayed_work_sync() semantics has been recently changed such that if a delayed work is pending it's queued immediately and then completion is waited. IOW, the behavior remains unchanged with the above change.

Thanks.

Signature · 1 line
tejun
#8 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

At Sun, 12 Dec 2010 10:15:55 +0100,

Quoted 33 lines · Tejun Heo

Hello, Takashi.

Quoted 29 lines · Takashi Iwai
Quoted 16 lines
sound/soc/codecs/wm8350.c +0 -1
index 7611add..b3e9fac 100644
@@ -1626,7 +1626,6 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 {
 	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
 	struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
-	int ret;
 
 	wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
 			  WM8350_JDL_ENA | WM8350_JDR_ENA);
@@ -1641,15 +1640,9 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
 	priv->hpr.jack = NULL;
 	priv->mic.jack = NULL;
 

sound/soc/codecs/wm8350.c static int wm8350_codec_remove(struct snd_soc_codec *codec) · line 1645

Quoted 10 lines
sound/soc/codecs/wm8350.c +1 -7
-	/* cancel any work waiting to be queued. */
-	ret = cancel_delayed_work(&codec->delayed_work);
-
 	/* if there was any work waiting then we run it now and
 	 * wait for its completion */
-	if (ret) {
-		schedule_delayed_work(&codec->delayed_work, 0);
-		flush_scheduled_work();
-	}
+	flush_delayed_work_sync(&codec->delayed_work);

I vaguely remember Liam introduced this kind of code by some reason.

Quoted 7 lines
Quoted 2 lines

Liam, isn't it better for cancel_delayed_work_sync(), or should it be like the above?

flush_delayed_work_sync() semantics has been recently changed such that if a delayed work is pending it's queued immediately and then completion is waited. IOW, the behavior remains unchanged with the above change.

Yes, I noticed it while I was reviewing your patch. So it's pretty correct.

Meanwhile, I wondered whether it's the really wanted behavior for that particular code path, thus the previous question to Liam.

thanks,

Takashi

#9 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 2 lines · Takashi Iwai

Meanwhile, I wondered whether it's the really wanted behavior for that particular code path, thus the previous question to Liam.

Yes, it's desired behaviour. That's what the old code was trying to do. I've not seen the original patch, could someone resend it to me please (or send a pointer)?

author
#10 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 8 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

Meanwhile, I wondered whether it's the really wanted behavior for that particular code path, thus the previous question to Liam.

Yes, it's desired behaviour. That's what the old code was trying to do. I've not seen the original patch, could someone resend it to me please (or send a pointer)?

Weirdly, lkml seemed to have eaten the original postings. I can't find them in any archive. The following is the original patch.

http://git.kernel.org/?p=linux/kernel/git/tj/wq.git;a=commitdiff;h=01f8126c2e14245cf0ba11a25fb9a291710066e1;hp=cd591981a8d06d6aaca6d7ef2412d12a7adf47ed

Thanks.

Signature · 1 line
tejun
Acked-by
#11 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 2 lines · Tejun Heo

Weirdly, lkml seemed to have eaten the original postings. I can't find them in any archive. The following is the original patch.

Possibly too big or something?

Quoted 1 line

http://git.kernel.org/?p=linux/kernel/git/tj/wq.git;a=commitdiff;h=01f8126c2e14245cf0ba11a25fb9a291710066e1;hp=cd591981a8d06d6aaca6d7ef2412d12a7adf47ed

For future reference please note that sound/soc is maintained as a subtree of ALSA - if you could send patches to that separately to myself and Liam as well as Takashi and Jaroslav that'd make life a little easier.

author
#12 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Hello,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Tejun Heo

Weirdly, lkml seemed to have eaten the original postings. I can't find them in any archive. The following is the original patch.

Possibly too big or something?

Quoted 8 lines
Quoted 1 line

http://git.kernel.org/?p=linux/kernel/git/tj/wq.git;a=commitdiff;h=01f8126c2e14245cf0ba11a25fb9a291710066e1;hp=cd591981a8d06d6aaca6d7ef2412d12a7adf47ed

For future reference please note that sound/soc is maintained as a subtree of ALSA - if you could send patches to that separately to myself and Liam as well as Takashi and Jaroslav that'd make life a little easier.

I can resplit and resend if necessary. Takashi, do you wanna take the patch as-is or resplit? Or shall I route it through wq tree?

Thanks.

Signature · 1 line
tejun
#13 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 7 lines · Tejun Heo
Quoted 4 lines

For future reference please note that sound/soc is maintained as a subtree of ALSA - if you could send patches to that separately to myself and Liam as well as Takashi and Jaroslav that'd make life a little easier.

I can resplit and resend if necessary. Takashi, do you wanna take the patch as-is or resplit? Or shall I route it through wq tree?

No need, just merge it along with the rest of the patch however that's going. I was mentioning this for future reference rather than for the present patch.

Liam, will the TWL6040 updates Magi posted the other day also be affected? I seem to remember they added the same pattern as WM835x has.

#14 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 10 lines · Mark Brown
Quoted 7 lines · Tejun Heo
Quoted 4 lines

For future reference please note that sound/soc is maintained as a subtree of ALSA - if you could send patches to that separately to myself and Liam as well as Takashi and Jaroslav that'd make life a little easier.

I can resplit and resend if necessary. Takashi, do you wanna take the patch as-is or resplit? Or shall I route it through wq tree?

Quoted 6 lines

No need, just merge it along with the rest of the patch however that's going. I was mentioning this for future reference rather than for the present patch.

Liam, will the TWL6040 updates Magi posted the other day also be affected? I seem to remember they added the same pattern as WM835x has.

Not sure myself.

Magi, could you check your patch queue for any use of flush_scheduled_work() here ?

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#15 lore raw

RE: [PATCH 09/30] sound: don't use flush_scheduled_work()

Hi Liam,

Quoted 29 lines

-----Original Message-----
From: Liam Girdwood [mailto:[email protected]]
Sent: Monday, December 13, 2010 7:32 AM
To: Mark Brown; Olaya, Margarita
Cc: Tejun Heo; Takashi Iwai; [email protected]; Jaroslav Kysela
Subject: Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 3 lines · Mark Brown
Quoted 1 line · Tejun Heo
Quoted 1 line

For future reference please note that sound/soc is

maintained as a

Quoted 1 line
Quoted 1 line
Quoted 1 line

subtree of ALSA - if you could send patches to that

separately to myself

Quoted 1 line
Quoted 1 line
Quoted 1 line

and Liam as well as Takashi and Jaroslav that'd make

life a little

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

easier.

I can resplit and resend if necessary. Takashi, do you

wanna take the

Quoted 3 lines
Quoted 1 line

patch as-is or resplit? Or shall I route it through wq tree?

No need, just merge it along with the rest of the patch

however that's

Quoted 1 line

going. I was mentioning this for future reference rather

than for the

Quoted 2 lines

present patch.

Quoted 8 lines
Quoted 2 lines

Liam, will the TWL6040 updates Magi posted the other day also be affected? I seem to remember they added the same pattern

as WM835x has.

Not sure myself.

Magi, could you check your patch queue for any use of flush_scheduled_work() here ?

flush_scheduled_work() is not being used in TWL6040 patches.

Regards,
Margarita

Quoted 10 lines

Thanks

Liam

Signature · 5 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
#16 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

In reply to Mark Brown

At Sun, 12 Dec 2010 12:40:41 +0000,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

Meanwhile, I wondered whether it's the really wanted behavior for that particular code path, thus the previous question to Liam.

Yes, it's desired behaviour. That's what the old code was trying to do.

OK, now I merged to sound git tree.
Also it's merged back to topic/asoc branch with a conflict fix. Please pull appropriately.

(I still don't remember why it had to be flush_work_sync() instead
of cancel_work_sync() in the remove callback path for ASoC, though... Both aren't so much different nowadays and should work fine in such a case, though :)

thanks,

Takashi

#17 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

Quoted 10 lines · Takashi Iwai

At Sun, 12 Dec 2010 12:40:41 +0000,

Quoted 7 lines · Mark Brown
Quoted 2 lines · Takashi Iwai

Meanwhile, I wondered whether it's the really wanted behavior for that particular code path, thus the previous question to Liam.

Yes, it's desired behaviour. That's what the old code was trying to do.

Quoted 8 lines

OK, now I merged to sound git tree.
Also it's merged back to topic/asoc branch with a conflict fix. Please pull appropriately.

(I still don't remember why it had to be flush_work_sync() instead
of cancel_work_sync() in the remove callback path for ASoC, though... Both aren't so much different nowadays and should work fine in such a case, though :)

Fwiw, I can't remember either why it had to be flush_work_sync() here. The initial soc-core stuff was 5 years ago and the reason is well and truly forgotten ;-)

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#18 lore raw

Re: [PATCH 09/30] sound: don't use flush_scheduled_work()

In reply to Takashi Iwai
Quoted 3 lines · Takashi Iwai

OK, now I merged to sound git tree.
Also it's merged back to topic/asoc branch with a conflict fix. Please pull appropriately.

Now merged up into my tree also.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#21 lore raw

Re: [PATCH 20/30] macintosh/ams: don't use flush_scheduled_work()

Quoted 6 lines · Jean Delvare
Quoted 2 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush ams_info.worker on detach instead.

The AMS driver is maintained by Stelian Pop and Michael Hanselmann according to MAINTAINERS. I am Cc'ing them both.

Change looks good to me, but can't test due to lack of hardware.

Michael

#22 lore raw

Re: [PATCH 20/30] macintosh/ams: don't use flush_scheduled_work()

Quoted 9 lines · Michael Hanselmann
Quoted 6 lines · Jean Delvare
Quoted 2 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush ams_info.worker on detach instead.

The AMS driver is maintained by Stelian Pop and Michael Hanselmann according to MAINTAINERS. I am Cc'ing them both.

Change looks good to me, but can't test due to lack of hardware.

Same here. Looks like this driver can be orphaned...

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#23 lore raw

Re: [PATCH 20/30] macintosh/ams: don't use flush_scheduled_work()

Quoted 7 lines · Stelian Pop
Quoted 5 lines · Michael Hanselmann
Quoted 4 lines · Jean Delvare
Quoted 2 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush ams_info.worker on detach instead.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The AMS driver is maintained by Stelian Pop and Michael Hanselmann according to MAINTAINERS. I am Cc'ing them both.

Change looks good to me, but can't test due to lack of hardware.

Same here. Looks like this driver can be orphaned...

If so, please submit a patch updating MAINTAINERS. Otherwise you'll keep getting patches asking for your acknowledgment.

Signature · 1 line
Jean Delvare
#24 lore raw

PATCH 1/1 Remove myself from MAINTAINERS as I no longer have the hardware to test.

This driver is PPC only, and I can no longer test it.

Subject: [PATCH] Remove myself from MAINTAINERS as I no longer have the hardware to test.

---
 MAINTAINERS |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
Quoted 9 lines · Jean Delvare
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The AMS driver is maintained by Stelian Pop and Michael Hanselmann according to MAINTAINERS. I am Cc'ing them both.

Change looks good to me, but can't test due to lack of hardware.

Same here. Looks like this driver can be orphaned...

If so, please submit a patch updating MAINTAINERS. Otherwise you'll keep getting patches asking for your acknowledgment.

Here it is.

I'll let Michael remove itself from MAINTAINERS and orphan the driver if he no longer has any related hardware.

Thanks,

Stelian.

MAINTAINERS +0 -1
index 1a1c27b..61d8c41 100644
@@ -429,7 +429,6 @@ S:	Supported
 F:	arch/x86/kernel/microcode_amd.c
 
 AMS (Apple Motion Sensor) DRIVER
-M:	Stelian Pop <[email protected]>
 M:	Michael Hanselmann <[email protected]>
 S:	Supported
 F:	drivers/macintosh/ams/
Signature · 1 line
1.7.1
#25 lore raw

Re: [PATCH] Remove myself from MAINTAINERS as I no longer have the hardware to test.

Hi Stelian,

Quoted 15 lines · Stelian Pop

This driver is PPC only, and I can no longer test it.

Subject: [PATCH] Remove myself from MAINTAINERS as I no longer have the hardware to test.

---
 MAINTAINERS |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

(...)

MAINTAINERS +0 -0
index 1a1c27b..61d8c41 100644

MAINTAINERS S: Supported · line 434

Quoted 7 lines
MAINTAINERS +0 -1
@@ -429,7 +429,6 @@ S:	Supported
 F:	arch/x86/kernel/microcode_amd.c
 
 AMS (Apple Motion Sensor) DRIVER
-M:	Stelian Pop <[email protected]>
 M:	Michael Hanselmann <[email protected]>
 S:	Supported
 F:	drivers/macintosh/ams/

I suggest that you send this patch to Andrew Morton or Benjamin Herrenschmidt. It doesn't fit in any of my trees so I can't pick it.

Thanks,

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#31 lore raw

Re: [PATCH 01/30] infiniband: update workqueue usage

Thanks Tejun. A couple questions:

Quoted 5 lines

* ib_wq is added, which is used as the common workqueue for infiniband instead of the system workqueue. All system workqueue usages including flush_scheduled_work() callers are converted to use and flush ib_wq. This is to prepare for deprecation of flush_scheduled_work().

Why do we want to move to a subsystem-specific workqueue? Can we just replace flush_scheduled_work() by cancel_delayed_work_sync() as appropriate and not create yet another work queue?

Quoted 1 line

* qib_wq is removed and ib_wq is used instead.

You obviously looked at the comment

- /*
- * We create our own workqueue mainly because we want to be
- * able to flush it when devices are being removed. We can't
- * use schedule_work()/flush_scheduled_work() because both
- * unregister_netdev() and linkwatch_event take the rtnl lock,
- * so flush_scheduled_work() can deadlock during device
- * removal.
- */
- qib_wq = create_workqueue("qib");

and know that with the new workqueue stuff, this issue no longer exists. But for both my education and also the clarity of the changelog for this patch, perhaps you could expand on why ib_wq is safe here.

Quoted 3 lines

* create[_singlethread]_workqueue() usages are replaced with the new alloc[_ordered]_workqueue(). This removes rescuers from all infiniband workqueues.

What are rescuers?

Can we replace some of these driver-specific work queues by the ib_wq?

Are all these things just possibilities for future cleanup?

Thanks,
Roland

author
#32 lore raw

Re: [PATCH 01/30] infiniband: update workqueue usage

Hello, Roland. Sorry about the delay.

Quoted 11 lines · Roland Dreier

Thanks Tejun. A couple questions:

Quoted 5 lines

* ib_wq is added, which is used as the common workqueue for infiniband instead of the system workqueue. All system workqueue usages including flush_scheduled_work() callers are converted to use and flush ib_wq. This is to prepare for deprecation of flush_scheduled_work().

Why do we want to move to a subsystem-specific workqueue? Can we just replace flush_scheduled_work() by cancel_delayed_work_sync() as appropriate and not create yet another work queue?

Because there are places where work is used to free the containing structure. Before a module is unloaded, all works which uses functions in the module should be flushed; however, if a work is used to free the containing structure, such work can't be flushed explicitly, so the workqueue which processes such works should be flushed.

So, in this case, ib_wq is added primarily to serve as a flush domain. For driver midlayers, this seems often necessary. Also, the workqueue doesn't have any dedicated worker and is quite cheap.

Quoted 15 lines
Quoted 2 lines

* qib_wq is removed and ib_wq is used instead.

You obviously looked at the comment

(quoted diff) +0 -9
-	/*
-	 * We create our own workqueue mainly because we want to be
-	 * able to flush it when devices are being removed.  We can't
-	 * use schedule_work()/flush_scheduled_work() because both
-	 * unregister_netdev() and linkwatch_event take the rtnl lock,
-	 * so flush_scheduled_work() can deadlock during device
-	 * removal.
-	 */
-	qib_wq = create_workqueue("qib");
Quoted 3 lines

and know that with the new workqueue stuff, this issue no longer exists. But for both my education and also the clarity of the changelog for this patch, perhaps you could expand on why ib_wq is safe here.

I think I got confused. I thought the comment was indicating the separation between qib_wq and qib_cq_wq. It's between system_wq and qib_wq, right? I'll drop this part from the series, but then again what's the difference from ib_srp, which flushes the common workqueue? Why doesn't ib_srp have the same problem?

Quoted 5 lines
Quoted 3 lines

* create[_singlethread]_workqueue() usages are replaced with the new alloc[_ordered]_workqueue(). This removes rescuers from all infiniband workqueues.

What are rescuers?

Normally, all workqueues share global per-cpu worker pool, but certain workqueues needs forward progress guarantee under memory pressure (the ones which are used to free memory). In this case, the workqueues are created with WQ_MEM_RECLAIM and has a single rescuer worker reserved. So, any workqueue which is in memory reclaim path needs to have the flag set to avoid the unlikely but still possible deadlock under memory pressure.

Quoted 3 lines

Can we replace some of these driver-specific work queues by the ib_wq?

Are all these things just possibilities for future cleanup?

Hmm... Yeah, sure, they can be. With the new implementation, separate workqueues are used for the following purposes.

* As a forward progress guarantee domain as decribed above.

* As a flushing domain.

* As a property domain. Different workqueues have different execution and queueing properties set.

Unless one of the above is necessary, work items can be queued together into the same workqueue. Concurrency-wise, it wouldn't make any difference. They all use the same set of workers anyway, but I don't know the code well enough to make the changes myself. If you're interested in doing it, I'll be happy to help.

Thanks.

Signature · 1 line
tejun
#33 lore raw

Re: [PATCH 01/30] infiniband: update workqueue usage

Quoted 16 lines · Tejun Heo
Quoted 15 lines · Roland Dreier
Quoted 2 lines

* qib_wq is removed and ib_wq is used instead.

You obviously looked at the comment

(quoted diff) +0 -9
-	/*
-	 * We create our own workqueue mainly because we want to be
-	 * able to flush it when devices are being removed.  We can't
-	 * use schedule_work()/flush_scheduled_work() because both
-	 * unregister_netdev() and linkwatch_event take the rtnl lock,
-	 * so flush_scheduled_work() can deadlock during device
-	 * removal.
-	 */
-	qib_wq = create_workqueue("qib");
Quoted 9 lines
Quoted 3 lines

and know that with the new workqueue stuff, this issue no longer exists. But for both my education and also the clarity of the changelog for this patch, perhaps you could expand on why ib_wq is safe here.

I think I got confused. I thought the comment was indicating the separation between qib_wq and qib_cq_wq. It's between system_wq and qib_wq, right? I'll drop this part from the series, but then again what's the difference from ib_srp, which flushes the common workqueue? Why doesn't ib_srp have the same problem?

Looking at qib, I'm not sure the comment isn't confused -- the only place I see where qib_wq or qib_cq_wq get flushed is by destroy_workqueue() when the module is being unloaded. And we shouldn't be there with rtnl_lock held by the caller.

Roland, please let me know how plan to proceed -- I need to update ib_srp to get rid of *scheduled_work(), and I can either use the IB core's queue, or define my own. Since it's cheap, I don't suppose it matters much, but I think I'd prefer to share if possible.

Thanks,
Dave

author
#35 lore raw

PATCH 1/1 RDMA: update missed converion of flush_scheduled_work()

Commit f0626710 (d9112f11586830d22501d0e26245ea) introduced ib_wq and removed the use of flush_scheduled_work(); however, during merge process one chunk was lost in ib_sa_remove_one(). Fix it.

Cc Roland Dreier <[email protected]>
---
 drivers/infiniband/core/sa_query.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/sa_query.c +1 -1
Index: work/drivers/infiniband/core/sa_query.c
===================================================================
@@ -1079,7 +1079,7 @@ static void ib_sa_remove_one(struct ib_d
 
 	ib_unregister_event_handler(&sa_dev->event_handler);
 
-	flush_scheduled_work();
+	flush_workqueue(ib_wq);
 
 	for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
 		if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
author
#36 lore raw

RFC PATCH 1/1 RDMA: use alloc[_ordered]_workqueue()

Replace create[_singlethread]_workqueue() usages with the new alloc[_ordered]_workqueue(). This removes rescuers from all infiniband workqueues.

Cc Roland Dreier <[email protected]>
Cc Sean Hefty <[email protected]>
Cc Hal Rosenstock <[email protected]>

---
Hello,

So, all the create* -> alloc* conversions were dropped (one flush_scheduled_work() conversion was incorrectly dropped in the process, fixed by the other patch). Was this because of forward progress under memory pressure guarantee?

It doesn't look like infiniband can be safely used in memory reclaim path anyway (ie. it doesn't seem safe to host swap space) but I could definitely be mistaken. If forward progress is necessary, the right thing to do is adding WQ_MEM_RECLAIM flag to workqueue allocation calls.

Thank you.

 drivers/infiniband/core/addr.c            |    2 +-
 drivers/infiniband/core/cm.c              |    2 +-
 drivers/infiniband/core/cma.c             |    2 +-
 drivers/infiniband/core/iwcm.c            |    2 +-
 drivers/infiniband/core/mad.c             |    2 +-
 drivers/infiniband/core/multicast.c       |    2 +-
 drivers/infiniband/hw/cxgb3/iwch_cm.c     |    2 +-
 drivers/infiniband/hw/cxgb4/cm.c          |    2 +-
 drivers/infiniband/hw/mlx4/main.c         |    2 +-
 drivers/infiniband/hw/mthca/mthca_catas.c |    2 +-
 drivers/infiniband/hw/nes/nes_cm.c        |    4 ++--
 drivers/infiniband/ulp/ipoib/ipoib_main.c |    2 +-
 12 files changed, 13 insertions(+), 13 deletions(-)
drivers/infiniband/core/addr.c +1 -1
Index: work/drivers/infiniband/core/addr.c
===================================================================
@@ -438,7 +438,7 @@ static struct notifier_block nb = {
 
 static int __init addr_init(void)
 {
-	addr_wq = create_singlethread_workqueue("ib_addr");
+	addr_wq = alloc_ordered_workqueue("ib_addr", 0);
 	if (!addr_wq)
 		return -ENOMEM;
 
drivers/infiniband/core/cma.c +1 -1
Index: work/drivers/infiniband/core/cma.c
===================================================================
@@ -3257,7 +3257,7 @@ static int __init cma_init(void)
 {
 	int ret;
 
-	cma_wq = create_singlethread_workqueue("rdma_cm");
+	cma_wq = alloc_ordered_workqueue("rdma_cm", 0);
 	if (!cma_wq)
 		return -ENOMEM;
 
drivers/infiniband/core/iwcm.c +1 -1
Index: work/drivers/infiniband/core/iwcm.c
===================================================================
@@ -1015,7 +1015,7 @@ EXPORT_SYMBOL(iw_cm_init_qp_attr);
 
 static int __init iw_cm_init(void)
 {
-	iwcm_wq = create_singlethread_workqueue("iw_cm_wq");
+	iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", 0);
 	if (!iwcm_wq)
 		return -ENOMEM;
 
drivers/infiniband/core/mad.c +1 -1
Index: work/drivers/infiniband/core/mad.c
===================================================================
@@ -2839,7 +2839,7 @@ static int ib_mad_port_open(struct ib_de
 		goto error7;
 
 	snprintf(name, sizeof name, "ib_mad%d", port_num);
-	port_priv->wq = create_singlethread_workqueue(name);
+	port_priv->wq = alloc_ordered_workqueue(name, 0);
 	if (!port_priv->wq) {
 		ret = -ENOMEM;
 		goto error8;
drivers/infiniband/core/multicast.c +1 -1
Index: work/drivers/infiniband/core/multicast.c
===================================================================
@@ -872,7 +872,7 @@ int mcast_init(void)
 {
 	int ret;
 
-	mcast_wq = create_singlethread_workqueue("ib_mcast");
+	mcast_wq = alloc_ordered_workqueue("ib_mcast", 0);
 	if (!mcast_wq)
 		return -ENOMEM;
 
drivers/infiniband/hw/cxgb3/iwch_cm.c +1 -1
Index: work/drivers/infiniband/hw/cxgb3/iwch_cm.c
===================================================================
@@ -2236,7 +2236,7 @@ int __init iwch_cm_init(void)
 {
 	skb_queue_head_init(&rxq);
 
-	workq = create_singlethread_workqueue("iw_cxgb3");
+	workq = alloc_ordered_workqueue("iw_cxgb3", 0);
 	if (!workq)
 		return -ENOMEM;
 
drivers/infiniband/hw/cxgb4/cm.c +1 -1
Index: work/drivers/infiniband/hw/cxgb4/cm.c
===================================================================
@@ -2356,7 +2356,7 @@ int __init c4iw_cm_init(void)
 	spin_lock_init(&timeout_lock);
 	skb_queue_head_init(&rxq);
 
-	workq = create_singlethread_workqueue("iw_cxgb4");
+	workq = alloc_ordered_workqueue("iw_cxgb4", 0);
 	if (!workq)
 		return -ENOMEM;
 
drivers/infiniband/hw/mlx4/main.c +1 -1
Index: work/drivers/infiniband/hw/mlx4/main.c
===================================================================
@@ -1214,7 +1214,7 @@ static int __init mlx4_ib_init(void)
 {
 	int err;
 
-	wq = create_singlethread_workqueue("mlx4_ib");
+	wq = alloc_ordered_workqueue("mlx4_ib", 0);
 	if (!wq)
 		return -ENOMEM;
 
drivers/infiniband/hw/mthca/mthca_catas.c +1 -1
Index: work/drivers/infiniband/hw/mthca/mthca_catas.c
===================================================================
@@ -186,7 +186,7 @@ int __init mthca_catas_init(void)
 {
 	INIT_WORK(&catas_work, catas_reset);
 
-	catas_wq = create_singlethread_workqueue("mthca_catas");
+	catas_wq = alloc_ordered_workqueue("mthca_catas", 0);
 	if (!catas_wq)
 		return -ENOMEM;
 
drivers/infiniband/hw/nes/nes_cm.c +2 -2
Index: work/drivers/infiniband/hw/nes/nes_cm.c
===================================================================
@@ -2381,10 +2381,10 @@ static struct nes_cm_core *nes_cm_alloc_
 	nes_debug(NES_DBG_CM, "Init CM Core completed -- cm_core=%p\n", cm_core);
 
 	nes_debug(NES_DBG_CM, "Enable QUEUE EVENTS\n");
-	cm_core->event_wq = create_singlethread_workqueue("nesewq");
+	cm_core->event_wq = alloc_ordered_workqueue("nesewq", 0);
 	cm_core->post_event = nes_cm_post_event;
 	nes_debug(NES_DBG_CM, "Enable QUEUE DISCONNECTS\n");
-	cm_core->disconn_wq = create_singlethread_workqueue("nesdwq");
+	cm_core->disconn_wq = alloc_ordered_workqueue("nesdwq", 0);
 
 	print_core(cm_core);
 	return cm_core;
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -1
Index: work/drivers/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
@@ -1374,7 +1374,7 @@ static int __init ipoib_init_module(void
 	 * so flush_scheduled_work() can deadlock during device
 	 * removal.
 	 */
-	ipoib_workqueue = create_singlethread_workqueue("ipoib");
+	ipoib_workqueue = alloc_ordered_workqueue("ipoib", 0);
 	if (!ipoib_workqueue) {
 		ret = -ENOMEM;
 		goto err_fs;
drivers/infiniband/core/cm.c +1 -1
Index: work/drivers/infiniband/core/cm.c
===================================================================
@@ -3804,7 +3804,7 @@ static int __init ib_cm_init(void)
 	if (ret)
 		return -ENOMEM;
 
-	cm.wq = create_workqueue("ib_cm");
+	cm.wq = alloc_workqueue("ib_cm", 0, 0);
 	if (!cm.wq) {
 		ret = -ENOMEM;
 		goto error1;
#37 lore raw

Re: [PATCH] RDMA: update missed converion of flush_scheduled_work()

In reply to Tejun Heo
Quoted 3 lines

Commit f0626710 (d9112f11586830d22501d0e26245ea) introduced ib_wq and removed the use of flush_scheduled_work(); however, during merge process one chunk was lost in ib_sa_remove_one().  Fix it.

Thanks, applied.

BTW in the future if you can cc the linux-rdma@vger mailing list on RDMA patches that helps me out, since the patch goes into the linux-rdma patchwork and I'm much
less likely to lose it in my inbox.

Thanks,
Roland

author
#38 lore raw

Re: [PATCH] RDMA: update missed converion of flush_scheduled_work()

Hello,

Quoted 10 lines · Roland Dreier
Quoted 3 lines

Commit f0626710 (d9112f11586830d22501d0e26245ea) introduced ib_wq and removed the use of flush_scheduled_work(); however, during merge process one chunk was lost in ib_sa_remove_one().  Fix it.

Thanks, applied.

BTW in the future if you can cc the linux-rdma@vger mailing list on RDMA patches that helps me out, since the patch goes into the linux-rdma patchwork and I'm much
less likely to lose it in my inbox.

Oh, I see. I'll try to remember that.

Thank you.

Signature · 1 line
tejun

A message that is not in the archive (sent off-list or not yet received): [email protected]

#40 lore raw

Re: [PATCH 28/30] battery: don't use flush_scheduled_work()

Quoted 17 lines · Tejun Heo

flush_scheduled_work() is deprecated and scheduled to be removed.

In battery drivers, the work can be canceled on probe failure and removal and should be flushed on suspend. Replace flush_scheduled_work() usages with direct cancels and flushes.

Cc Anton Vorontsov <[email protected]>

---
This is part of a series to remove flush_scheduled_work() usage to prepare for deprecation of flush_scheduled_work(). Patches in this series are self contained and mostly straight-forward.

Please feel free to take it into the appropriate tree, or just ack it. In the latter case, I'll merge the patch through the workqueue tree during the next merge window.

Quoted 5 lines

If you're seeing this patch for the second time, it's because the commit hasn't showed up in mainline yet. Please let me know what should be done.

Thank you.

I applied this to battery-2.6.git, thanks!

Signature · 2 lines
Anton Vorontsov
Email: [email protected]
author
#41 lore raw

Re: [PATCHSET] workqueue: remove flush_scheduled_work() usage

In reply to a message not in the archive
Quoted 31 lines · Tejun Heo

Hello,

This patchset removes flush_scheduled_work() usage to prepare for deprecation of the interface. Patches in this series are self contained and mostly straight-forward. More complex conversions will be done in separate patchsets.

This patchset contains the following 30 patches.

0001-infiniband-update-workqueue-usage.patch 0002-isdn-capi-unregister-capictr-notifier-after-init-fai.patch 0003-isdn-capi-make-kcapi-use-a-separate-workqueue.patch 0004-drm-ttm-use-cancel_delayed_work_sync-in-ttm_bo.patch 0005-net-dsa-don-t-use-flush_scheduled_work.patch 0006-ncpfs-don-t-use-flush_scheduled_work.patch 0007-ocfs2-don-t-use-flush_scheduled_work.patch 0008-afs-add-afs_wq-and-use-it-instead-of-the-system-work.patch 0009-sound-don-t-use-flush_scheduled_work.patch 0010-arm-sharpsl-don-t-use-flush_scheduled_work.patch 0011-sh-don-t-use-flush_scheduled_work.patch 0012-floppy-don-t-use-flush_scheduled_work.patch 0013-gdrom-don-t-use-flush_scheduled_work.patch 0014-xen-don-t-use-flush_scheduled_work.patch 0015-hvsi-don-t-use-flush_scheduled_work.patch 0016-sonypi-don-t-use-flush_scheduled_work.patch 0017-tpm-don-t-use-flush_scheduled_work.patch 0018-vmwgfx-don-t-use-flush_scheduled_work.patch 0019-hid-picolcd-don-t-use-flush_scheduled_work.patch 0020-macintosh-ams-don-t-use-flush_scheduled_work.patch 0021-pcmcia-ipwireless-don-t-use-flush_scheduled_work.patch 0022-mISDN-don-t-use-flush_scheduled_work.patch

Quoted 8 lines

0023-leds-wm8350-don-t-use-flush_scheduled_work.patch 0024-dvb-don-t-use-flush_scheduled_work.patch 0025-mfd-update-workqueue-usages.patch 0026-mmc-update-workqueue-usages.patch 0027-mtd-don-t-use-flush_scheduled_work.patch 0028-battery-don-t-use-flush_scheduled_work.patch 0029-rtc-don-t-use-flush_scheduled_work.patch 0030-s390-don-t-use-flush_scheduled_work.patch

Patches other than 0001 and 0008 are merged into wq#for-next.

Thanks.

Signature · 1 line
tejun