aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 00:58:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 00:58:52 -0500
commit1eaec8212e35aef6606a4e8b40aa9ad9ba87672a (patch)
treeaa0ae10e129d3642b5470bc430f0b174dc08a381
parent1a13c0b181f218bf56a1a6b8edbaf2876b22314b (diff)
parent23663c873154f01220ef679558e1ca110c4c4ca4 (diff)
Merge branch 'for-3.9-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue [delayed_]work_pending() cleanups from Tejun Heo: "This is part of on-going cleanups to remove / minimize usages of workqueue interfaces which are deprecated and/or misleading. This round drops a number of usages of [delayed_]work_pending(), which are dangerous as they lack any form of synchronization and thus often lead to buggy / unnecessary code. There are a couple legitimate use cases in kernel. Hopefully, they can be converted and [delayed_]work_pending() can be removed completely. Even if not, removing most of misuses should make it more difficult to find examples of misuses and thus slow down growth of them. These changes are independent from other workqueue changes." * 'for-3.9-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: wimax/i2400m: fix i2400m->wake_tx_skb handling kprobes: fix wait_for_kprobe_optimizer() ipw2x00: simplify scan_event handling video/exynos: don't use [delayed_]work_pending() tty/max3100: don't use [delayed_]work_pending() x86/mce: don't use [delayed_]work_pending() rfkill: don't use [delayed_]work_pending() wl1251: don't use [delayed_]work_pending() thinkpad_acpi: don't use [delayed_]work_pending() mwifiex: don't use [delayed_]work_pending() sja1000: don't use [delayed_]work_pending()
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c14
-rw-r--r--drivers/net/can/sja1000/peak_pci.c3
-rw-r--r--drivers/net/wimax/i2400m/netdev.c31
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c31
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.h3
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c13
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c9
-rw-r--r--drivers/net/wireless/ti/wl1251/ps.c3
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c3
-rw-r--r--drivers/tty/serial/max3100.c3
-rw-r--r--drivers/video/exynos/exynos_dp_core.c6
-rw-r--r--kernel/kprobes.c23
-rw-r--r--net/rfkill/input.c8
13 files changed, 60 insertions, 90 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 80dbda84f1c3..fc7608a89d93 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -512,11 +512,8 @@ int mce_available(struct cpuinfo_x86 *c)
512 512
513static void mce_schedule_work(void) 513static void mce_schedule_work(void)
514{ 514{
515 if (!mce_ring_empty()) { 515 if (!mce_ring_empty())
516 struct work_struct *work = &__get_cpu_var(mce_work); 516 schedule_work(&__get_cpu_var(mce_work));
517 if (!work_pending(work))
518 schedule_work(work);
519 }
520} 517}
521 518
522DEFINE_PER_CPU(struct irq_work, mce_irq_work); 519DEFINE_PER_CPU(struct irq_work, mce_irq_work);
@@ -1351,12 +1348,7 @@ int mce_notify_irq(void)
1351 /* wake processes polling /dev/mcelog */ 1348 /* wake processes polling /dev/mcelog */
1352 wake_up_interruptible(&mce_chrdev_wait); 1349 wake_up_interruptible(&mce_chrdev_wait);
1353 1350
1354 /* 1351 if (mce_helper[0])
1355 * There is no risk of missing notifications because
1356 * work_pending is always cleared before the function is
1357 * executed.
1358 */
1359 if (mce_helper[0] && !work_pending(&mce_trigger_work))
1360 schedule_work(&mce_trigger_work); 1352 schedule_work(&mce_trigger_work);
1361 1353
1362 if (__ratelimit(&ratelimit)) 1354 if (__ratelimit(&ratelimit))
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index d84888f03d92..600ac7226e5c 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -339,8 +339,7 @@ static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s)
339 */ 339 */
340static void peak_pciec_start_led_work(struct peak_pciec_card *card) 340static void peak_pciec_start_led_work(struct peak_pciec_card *card)
341{ 341{
342 if (!delayed_work_pending(&card->led_work)) 342 schedule_delayed_work(&card->led_work, HZ);
343 schedule_delayed_work(&card->led_work, HZ);
344} 343}
345 344
346/* 345/*
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 1d76ae855f07..530581ca0191 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -156,7 +156,7 @@ void i2400m_wake_tx_work(struct work_struct *ws)
156 struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws); 156 struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
157 struct net_device *net_dev = i2400m->wimax_dev.net_dev; 157 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
158 struct device *dev = i2400m_dev(i2400m); 158 struct device *dev = i2400m_dev(i2400m);
159 struct sk_buff *skb = i2400m->wake_tx_skb; 159 struct sk_buff *skb;
160 unsigned long flags; 160 unsigned long flags;
161 161
162 spin_lock_irqsave(&i2400m->tx_lock, flags); 162 spin_lock_irqsave(&i2400m->tx_lock, flags);
@@ -236,23 +236,26 @@ void i2400m_tx_prep_header(struct sk_buff *skb)
236void i2400m_net_wake_stop(struct i2400m *i2400m) 236void i2400m_net_wake_stop(struct i2400m *i2400m)
237{ 237{
238 struct device *dev = i2400m_dev(i2400m); 238 struct device *dev = i2400m_dev(i2400m);
239 struct sk_buff *wake_tx_skb;
240 unsigned long flags;
239 241
240 d_fnstart(3, dev, "(i2400m %p)\n", i2400m); 242 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
241 /* See i2400m_hard_start_xmit(), references are taken there 243 /*
242 * and here we release them if the work was still 244 * See i2400m_hard_start_xmit(), references are taken there and
243 * pending. Note we can't differentiate work not pending vs 245 * here we release them if the packet was still pending.
244 * never scheduled, so the NULL check does that. */ 246 */
245 if (cancel_work_sync(&i2400m->wake_tx_ws) == 0 247 cancel_work_sync(&i2400m->wake_tx_ws);
246 && i2400m->wake_tx_skb != NULL) { 248
247 unsigned long flags; 249 spin_lock_irqsave(&i2400m->tx_lock, flags);
248 struct sk_buff *wake_tx_skb; 250 wake_tx_skb = i2400m->wake_tx_skb;
249 spin_lock_irqsave(&i2400m->tx_lock, flags); 251 i2400m->wake_tx_skb = NULL;
250 wake_tx_skb = i2400m->wake_tx_skb; /* compat help */ 252 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
251 i2400m->wake_tx_skb = NULL; /* compat help */ 253
252 spin_unlock_irqrestore(&i2400m->tx_lock, flags); 254 if (wake_tx_skb) {
253 i2400m_put(i2400m); 255 i2400m_put(i2400m);
254 kfree_skb(wake_tx_skb); 256 kfree_skb(wake_tx_skb);
255 } 257 }
258
256 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m); 259 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
257} 260}
258 261
@@ -288,7 +291,7 @@ int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
288 * and if pending, release those resources. */ 291 * and if pending, release those resources. */
289 result = 0; 292 result = 0;
290 spin_lock_irqsave(&i2400m->tx_lock, flags); 293 spin_lock_irqsave(&i2400m->tx_lock, flags);
291 if (!work_pending(&i2400m->wake_tx_ws)) { 294 if (!i2400m->wake_tx_skb) {
292 netif_stop_queue(net_dev); 295 netif_stop_queue(net_dev);
293 i2400m_get(i2400m); 296 i2400m_get(i2400m);
294 i2400m->wake_tx_skb = skb_get(skb); /* transfer ref count */ 297 i2400m->wake_tx_skb = skb_get(skb); /* transfer ref count */
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index d92b21a8e597..b3ab7b7becae 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -2181,9 +2181,10 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
2181 mod_delayed_work(system_wq, &priv->rf_kill, round_jiffies_relative(HZ)); 2181 mod_delayed_work(system_wq, &priv->rf_kill, round_jiffies_relative(HZ));
2182} 2182}
2183 2183
2184static void send_scan_event(void *data) 2184static void ipw2100_scan_event(struct work_struct *work)
2185{ 2185{
2186 struct ipw2100_priv *priv = data; 2186 struct ipw2100_priv *priv = container_of(work, struct ipw2100_priv,
2187 scan_event.work);
2187 union iwreq_data wrqu; 2188 union iwreq_data wrqu;
2188 2189
2189 wrqu.data.length = 0; 2190 wrqu.data.length = 0;
@@ -2191,18 +2192,6 @@ static void send_scan_event(void *data)
2191 wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL); 2192 wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL);
2192} 2193}
2193 2194
2194static void ipw2100_scan_event_later(struct work_struct *work)
2195{
2196 send_scan_event(container_of(work, struct ipw2100_priv,
2197 scan_event_later.work));
2198}
2199
2200static void ipw2100_scan_event_now(struct work_struct *work)
2201{
2202 send_scan_event(container_of(work, struct ipw2100_priv,
2203 scan_event_now));
2204}
2205
2206static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) 2195static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
2207{ 2196{
2208 IPW_DEBUG_SCAN("scan complete\n"); 2197 IPW_DEBUG_SCAN("scan complete\n");
@@ -2212,13 +2201,11 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
2212 2201
2213 /* Only userspace-requested scan completion events go out immediately */ 2202 /* Only userspace-requested scan completion events go out immediately */
2214 if (!priv->user_requested_scan) { 2203 if (!priv->user_requested_scan) {
2215 if (!delayed_work_pending(&priv->scan_event_later)) 2204 schedule_delayed_work(&priv->scan_event,
2216 schedule_delayed_work(&priv->scan_event_later, 2205 round_jiffies_relative(msecs_to_jiffies(4000)));
2217 round_jiffies_relative(msecs_to_jiffies(4000)));
2218 } else { 2206 } else {
2219 priv->user_requested_scan = 0; 2207 priv->user_requested_scan = 0;
2220 cancel_delayed_work(&priv->scan_event_later); 2208 mod_delayed_work(system_wq, &priv->scan_event, 0);
2221 schedule_work(&priv->scan_event_now);
2222 } 2209 }
2223} 2210}
2224 2211
@@ -4459,8 +4446,7 @@ static void ipw2100_kill_works(struct ipw2100_priv *priv)
4459 cancel_delayed_work_sync(&priv->wx_event_work); 4446 cancel_delayed_work_sync(&priv->wx_event_work);
4460 cancel_delayed_work_sync(&priv->hang_check); 4447 cancel_delayed_work_sync(&priv->hang_check);
4461 cancel_delayed_work_sync(&priv->rf_kill); 4448 cancel_delayed_work_sync(&priv->rf_kill);
4462 cancel_work_sync(&priv->scan_event_now); 4449 cancel_delayed_work_sync(&priv->scan_event);
4463 cancel_delayed_work_sync(&priv->scan_event_later);
4464} 4450}
4465 4451
4466static int ipw2100_tx_allocate(struct ipw2100_priv *priv) 4452static int ipw2100_tx_allocate(struct ipw2100_priv *priv)
@@ -6195,8 +6181,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6195 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work); 6181 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
6196 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check); 6182 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check);
6197 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill); 6183 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
6198 INIT_WORK(&priv->scan_event_now, ipw2100_scan_event_now); 6184 INIT_DELAYED_WORK(&priv->scan_event, ipw2100_scan_event);
6199 INIT_DELAYED_WORK(&priv->scan_event_later, ipw2100_scan_event_later);
6200 6185
6201 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 6186 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
6202 ipw2100_irq_tasklet, (unsigned long)priv); 6187 ipw2100_irq_tasklet, (unsigned long)priv);
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.h b/drivers/net/wireless/ipw2x00/ipw2100.h
index 5fe17cbab1f3..c6d78790cb0d 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.h
+++ b/drivers/net/wireless/ipw2x00/ipw2100.h
@@ -577,8 +577,7 @@ struct ipw2100_priv {
577 struct delayed_work wx_event_work; 577 struct delayed_work wx_event_work;
578 struct delayed_work hang_check; 578 struct delayed_work hang_check;
579 struct delayed_work rf_kill; 579 struct delayed_work rf_kill;
580 struct work_struct scan_event_now; 580 struct delayed_work scan_event;
581 struct delayed_work scan_event_later;
582 581
583 int user_requested_scan; 582 int user_requested_scan;
584 583
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 844f201b7b70..2c2d6db0536c 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -4480,18 +4480,11 @@ static void handle_scan_event(struct ipw_priv *priv)
4480{ 4480{
4481 /* Only userspace-requested scan completion events go out immediately */ 4481 /* Only userspace-requested scan completion events go out immediately */
4482 if (!priv->user_requested_scan) { 4482 if (!priv->user_requested_scan) {
4483 if (!delayed_work_pending(&priv->scan_event)) 4483 schedule_delayed_work(&priv->scan_event,
4484 schedule_delayed_work(&priv->scan_event, 4484 round_jiffies_relative(msecs_to_jiffies(4000)));
4485 round_jiffies_relative(msecs_to_jiffies(4000)));
4486 } else { 4485 } else {
4487 union iwreq_data wrqu;
4488
4489 priv->user_requested_scan = 0; 4486 priv->user_requested_scan = 0;
4490 cancel_delayed_work(&priv->scan_event); 4487 mod_delayed_work(system_wq, &priv->scan_event, 0);
4491
4492 wrqu.data.length = 0;
4493 wrqu.data.flags = 0;
4494 wireless_send_event(priv->net_dev, SIOCGIWSCAN, &wrqu, NULL);
4495 } 4488 }
4496} 4489}
4497 4490
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 5a1c1d0e5599..f2874c3392b4 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -1752,6 +1752,8 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)
1752static struct mmc_host *reset_host; 1752static struct mmc_host *reset_host;
1753static void sdio_card_reset_worker(struct work_struct *work) 1753static void sdio_card_reset_worker(struct work_struct *work)
1754{ 1754{
1755 struct mmc_host *target = reset_host;
1756
1755 /* The actual reset operation must be run outside of driver thread. 1757 /* The actual reset operation must be run outside of driver thread.
1756 * This is because mmc_remove_host() will cause the device to be 1758 * This is because mmc_remove_host() will cause the device to be
1757 * instantly destroyed, and the driver then needs to end its thread, 1759 * instantly destroyed, and the driver then needs to end its thread,
@@ -1761,10 +1763,10 @@ static void sdio_card_reset_worker(struct work_struct *work)
1761 */ 1763 */
1762 1764
1763 pr_err("Resetting card...\n"); 1765 pr_err("Resetting card...\n");
1764 mmc_remove_host(reset_host); 1766 mmc_remove_host(target);
1765 /* 20ms delay is based on experiment with sdhci controller */ 1767 /* 20ms delay is based on experiment with sdhci controller */
1766 mdelay(20); 1768 mdelay(20);
1767 mmc_add_host(reset_host); 1769 mmc_add_host(target);
1768} 1770}
1769static DECLARE_WORK(card_reset_work, sdio_card_reset_worker); 1771static DECLARE_WORK(card_reset_work, sdio_card_reset_worker);
1770 1772
@@ -1773,9 +1775,6 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
1773{ 1775{
1774 struct sdio_mmc_card *card = adapter->card; 1776 struct sdio_mmc_card *card = adapter->card;
1775 1777
1776 if (work_pending(&card_reset_work))
1777 return;
1778
1779 reset_host = card->func->card->host; 1778 reset_host = card->func->card->host;
1780 schedule_work(&card_reset_work); 1779 schedule_work(&card_reset_work);
1781} 1780}
diff --git a/drivers/net/wireless/ti/wl1251/ps.c b/drivers/net/wireless/ti/wl1251/ps.c
index db719f7d2692..b9e27b98bbc9 100644
--- a/drivers/net/wireless/ti/wl1251/ps.c
+++ b/drivers/net/wireless/ti/wl1251/ps.c
@@ -68,8 +68,7 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)
68 unsigned long timeout, start; 68 unsigned long timeout, start;
69 u32 elp_reg; 69 u32 elp_reg;
70 70
71 if (delayed_work_pending(&wl->elp_work)) 71 cancel_delayed_work(&wl->elp_work);
72 cancel_delayed_work(&wl->elp_work);
73 72
74 if (!wl->elp) 73 if (!wl->elp)
75 return 0; 74 return 0;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index f946ca7cb762..ebcb461bb2b0 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -4877,8 +4877,7 @@ static int __init light_init(struct ibm_init_struct *iibm)
4877static void light_exit(void) 4877static void light_exit(void)
4878{ 4878{
4879 led_classdev_unregister(&tpacpi_led_thinklight.led_classdev); 4879 led_classdev_unregister(&tpacpi_led_thinklight.led_classdev);
4880 if (work_pending(&tpacpi_led_thinklight.work)) 4880 flush_workqueue(tpacpi_wq);
4881 flush_workqueue(tpacpi_wq);
4882} 4881}
4883 4882
4884static int light_read(struct seq_file *m) 4883static int light_read(struct seq_file *m)
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
index 7ce3197087bb..dd6277eb5a38 100644
--- a/drivers/tty/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
@@ -179,8 +179,7 @@ static void max3100_work(struct work_struct *w);
179 179
180static void max3100_dowork(struct max3100_port *s) 180static void max3100_dowork(struct max3100_port *s)
181{ 181{
182 if (!s->force_end_work && !work_pending(&s->work) && 182 if (!s->force_end_work && !freezing(current) && !s->suspending)
183 !freezing(current) && !s->suspending)
184 queue_work(s->workqueue, &s->work); 183 queue_work(s->workqueue, &s->work);
185} 184}
186 185
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 4ef18e2e90cc..2d0d144add1b 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -1121,8 +1121,7 @@ static int exynos_dp_remove(struct platform_device *pdev)
1121 1121
1122 disable_irq(dp->irq); 1122 disable_irq(dp->irq);
1123 1123
1124 if (work_pending(&dp->hotplug_work)) 1124 flush_work(&dp->hotplug_work);
1125 flush_work(&dp->hotplug_work);
1126 1125
1127 if (pdev->dev.of_node) { 1126 if (pdev->dev.of_node) {
1128 if (dp->phy_addr) 1127 if (dp->phy_addr)
@@ -1144,8 +1143,7 @@ static int exynos_dp_suspend(struct device *dev)
1144 struct exynos_dp_platdata *pdata = dev->platform_data; 1143 struct exynos_dp_platdata *pdata = dev->platform_data;
1145 struct exynos_dp_device *dp = dev_get_drvdata(dev); 1144 struct exynos_dp_device *dp = dev_get_drvdata(dev);
1146 1145
1147 if (work_pending(&dp->hotplug_work)) 1146 flush_work(&dp->hotplug_work);
1148 flush_work(&dp->hotplug_work);
1149 1147
1150 if (dev->of_node) { 1148 if (dev->of_node) {
1151 if (dp->phy_addr) 1149 if (dp->phy_addr)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index f423c3ef4a82..550294d58a02 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -471,7 +471,6 @@ static LIST_HEAD(unoptimizing_list);
471 471
472static void kprobe_optimizer(struct work_struct *work); 472static void kprobe_optimizer(struct work_struct *work);
473static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer); 473static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
474static DECLARE_COMPLETION(optimizer_comp);
475#define OPTIMIZE_DELAY 5 474#define OPTIMIZE_DELAY 5
476 475
477/* 476/*
@@ -552,8 +551,7 @@ static __kprobes void do_free_cleaned_kprobes(struct list_head *free_list)
552/* Start optimizer after OPTIMIZE_DELAY passed */ 551/* Start optimizer after OPTIMIZE_DELAY passed */
553static __kprobes void kick_kprobe_optimizer(void) 552static __kprobes void kick_kprobe_optimizer(void)
554{ 553{
555 if (!delayed_work_pending(&optimizing_work)) 554 schedule_delayed_work(&optimizing_work, OPTIMIZE_DELAY);
556 schedule_delayed_work(&optimizing_work, OPTIMIZE_DELAY);
557} 555}
558 556
559/* Kprobe jump optimizer */ 557/* Kprobe jump optimizer */
@@ -592,16 +590,25 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
592 /* Step 5: Kick optimizer again if needed */ 590 /* Step 5: Kick optimizer again if needed */
593 if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) 591 if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
594 kick_kprobe_optimizer(); 592 kick_kprobe_optimizer();
595 else
596 /* Wake up all waiters */
597 complete_all(&optimizer_comp);
598} 593}
599 594
600/* Wait for completing optimization and unoptimization */ 595/* Wait for completing optimization and unoptimization */
601static __kprobes void wait_for_kprobe_optimizer(void) 596static __kprobes void wait_for_kprobe_optimizer(void)
602{ 597{
603 if (delayed_work_pending(&optimizing_work)) 598 mutex_lock(&kprobe_mutex);
604 wait_for_completion(&optimizer_comp); 599
600 while (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) {
601 mutex_unlock(&kprobe_mutex);
602
603 /* this will also make optimizing_work execute immmediately */
604 flush_delayed_work(&optimizing_work);
605 /* @optimizing_work might not have been queued yet, relax */
606 cpu_relax();
607
608 mutex_lock(&kprobe_mutex);
609 }
610
611 mutex_unlock(&kprobe_mutex);
605} 612}
606 613
607/* Optimize kprobe if p is ready to be optimized */ 614/* Optimize kprobe if p is ready to be optimized */
diff --git a/net/rfkill/input.c b/net/rfkill/input.c
index c9d931e7ffec..b85107b5ef62 100644
--- a/net/rfkill/input.c
+++ b/net/rfkill/input.c
@@ -148,11 +148,9 @@ static unsigned long rfkill_ratelimit(const unsigned long last)
148 148
149static void rfkill_schedule_ratelimited(void) 149static void rfkill_schedule_ratelimited(void)
150{ 150{
151 if (delayed_work_pending(&rfkill_op_work)) 151 if (schedule_delayed_work(&rfkill_op_work,
152 return; 152 rfkill_ratelimit(rfkill_last_scheduled)))
153 schedule_delayed_work(&rfkill_op_work, 153 rfkill_last_scheduled = jiffies;
154 rfkill_ratelimit(rfkill_last_scheduled));
155 rfkill_last_scheduled = jiffies;
156} 154}
157 155
158static void rfkill_schedule_global_op(enum rfkill_sched_op op) 156static void rfkill_schedule_global_op(enum rfkill_sched_op op)