workqueue: don't use [delayed_]work_pending()
Subsystems (30)
PATCH 3/25 sja1000: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from sja1000. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/can/sja1000/peak_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/can/sja1000/peak_pci.c +1 -2
@@ -339,8 +339,7 @@ static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s)*/ static void peak_pciec_start_led_work (struct peak_pciec_card *card) { -if (!delayed_work_pending (&card->led_work)) -schedule_delayed_work (&card->led_work,HZ ); +schedule_delayed_work (&card->led_work,HZ ); }/*
Signature · 1 line
1.8.0.2
PATCH 8/25 thinkpad_acpi: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from thinkpad_acpi. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/platform/x86/thinkpad_acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +1 -2
@@ -4877,8 +4877,7 @@ static int __init light_init(struct ibm_init_struct *iibm)static void light_exit (void ) {led_classdev_unregister (&tpacpi_led_thinklight.led_classdev); -if (work_pending (&tpacpi_led_thinklight.work)) -flush_workqueue (tpacpi_wq); +flush_workqueue (tpacpi_wq); }static int light_read (struct seq_file *m)
Signature · 1 line
1.8.0.2
PATCH 12/25 bluetooth/l2cap: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Reimplement l2cap_set_timer() such that it uses mod_delayed_work() or schedule_delayed_work() depending on a new param @override and let the users specify whether to override or not instead of using delayed_work_pending().
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
include/net/bluetooth/l2cap.h | 24 ++++++++++++++++-------- net/bluetooth/l2cap_core.c | 7 +++---- 2 files changed, 19 insertions(+), 12 deletions(-)
include/net/bluetooth/l2cap.h +16 -8
@@ -718,17 +718,25 @@ static inline void l2cap_chan_unlock(struct l2cap_chan *chan) }static inline void l2cap_set_timer (struct l2cap_chan *chan, -struct delayed_work *work,long timeout) +struct delayed_work *work,long timeout, +bool override) { +bool was_pending; +BT_DBG ("chan %p state %s timeout %ld" , chan,state_to_string (chan->state), timeout); -/* If delayed work cancelled do not hold(chan) -since it is already done with previous set_timer */ -if (!cancel_delayed_work (work)) -l2cap_chan_hold (chan); +/* @work should hold a reference to @chan */ +l2cap_chan_hold (chan); + +if (override) + was_pending =mod_delayed_work (system_wq, work, timeout); +else + was_pending = !schedule_delayed_work (work, timeout); -schedule_delayed_work (work, timeout); +/* if @work was already pending, lose the extra ref */ +if (was_pending) +l2cap_chan_put (chan); } static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
@@ -745,12 +753,12 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan,return ret; } -#define __set_chan_timer (c, t) l2cap_set_timer(c, &c->chan_timer, (t)) +#define __set_chan_timer (c, t) l2cap_set_timer(c, &c->chan_timer, (t), true)#define __clear_chan_timer (c) l2cap_clear_timer(c, &c->chan_timer)#define __clear_retrans_timer (c) l2cap_clear_timer(c, &c->retrans_timer)#define __clear_monitor_timer (c) l2cap_clear_timer(c, &c->monitor_timer)#define __set_ack_timer (c) l2cap_set_timer(c, &chan->ack_timer, \ - msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO), true);#define __clear_ack_timer (c) l2cap_clear_timer(c, &c->ack_timer)static inline int __seq_offset (struct l2cap_chan *chan,__u16 seq1,__u16 seq2)
net/bluetooth/l2cap_core.c +3 -4
@@ -246,10 +246,9 @@ static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err)static void __set_retrans_timer (struct l2cap_chan *chan) { -if (!delayed_work_pending (&chan->monitor_timer) && - chan->retrans_timeout) { +if (chan->retrans_timeout) {l2cap_set_timer (chan, &chan->retrans_timer, -msecs_to_jiffies (chan->retrans_timeout)); +msecs_to_jiffies (chan->retrans_timeout), false); } }
@@ -258,7 +257,7 @@ static void __set_monitor_timer(struct l2cap_chan *chan)__clear_retrans_timer (chan);if (chan->monitor_timeout) {l2cap_set_timer (chan, &chan->monitor_timer, -msecs_to_jiffies (chan->monitor_timeout)); +msecs_to_jiffies (chan->monitor_timeout), true); } }
Signature · 1 line
1.8.0.2
PATCH 16/25 PM / Domains: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from power domains. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/base/power/domain.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/power/domain.c +1 -2
@@ -433,8 +433,7 @@ static bool genpd_abort_poweroff(struct generic_pm_domain *genpd)*/ void genpd_queue_power_off_work (struct generic_pm_domain *genpd) { -if (!work_pending (&genpd->power_off_work)) -queue_work (pm_wq, &genpd->power_off_work); +queue_work (pm_wq, &genpd->power_off_work); }/**
Signature · 1 line
1.8.0.2
PATCH 17/25 wm97xx: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wm97xx. Instead of testing work_pending(), use the return value of queue_work() to decide whether to disable IRQ or not.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/input/touchscreen/wm97xx-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/wm97xx-core.c +1 -3
@@ -363,10 +363,8 @@ static irqreturn_t wm97xx_pen_interrupt(int irq, void *dev_id) {struct wm97xx *wm = dev_id; -if (!work_pending (&wm->pen_event_work)) { +if (queue_work (wm->ts_workq, &wm->pen_event_work)) wm->mach_ops->irq_enable (wm,0 ); -queue_work (wm->ts_workq, &wm->pen_event_work); - }return IRQ_HANDLED ; }
Signature · 1 line
1.8.0.2
PATCH 18/25 TMIO MMC: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from tmio mmc. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/mmc/host/tmio_mmc_pio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/host/tmio_mmc_pio.c +1 -2
@@ -573,8 +573,7 @@ static bool __tmio_mmc_card_detect_irq(struct tmio_mmc_host *host,tmio_mmc_ack_mmc_irqs (host,TMIO_STAT_CARD_INSERT |TMIO_STAT_CARD_REMOVE );if ((((ireg &TMIO_STAT_CARD_REMOVE ) && mmc->card) || - ((ireg &TMIO_STAT_CARD_INSERT ) && !mmc->card)) && - !work_pending (&mmc->detect.work)) + ((ireg &TMIO_STAT_CARD_INSERT ) && !mmc->card)))mmc_detect_change (host->mmc,msecs_to_jiffies (100 ));return true; }
Signature · 1 line
1.8.0.2
PATCH 1/1 workqueue: don't use [delayed_]work_pending()
Hello,
Given the current set of workqueue APIs, there are very few cases where [delayed_]work_pending() are actually necessary; however, it's seemingly somewhat popular for a few purposes including skipping queue/flush/cancel depending on the current state for optimization.
work_pending() could be slightly cheaper than performing the actual operation because it can skip atomic bitops assuming that the user is synchronizing against other workqueue operations properly; however, most paths with this type of optimization are siberia-cold for this level of optimization to matter - e.g. driver detach path or parameter update via sysfs - and it's easy to get it subtly wrong and introduce difficult-to-trigger race conditions. It just isn't worth it.
Other use cases include using work_pending() state to decide the state of previously scheduled async action. This too, unfortunately, seems easy to get wrong. Several users forgot that work_pending() becomes false *before* the work item starts execution and fails to synchronize with on-going execution. Unless one is specifically looking for those, they can be tricky to spot.
Overall, [delayed_]work_pending() seem to bring more troubles than benefits and not using them usually results in better code. This patchset removes [delayed_]work_pending() usages from various subsystems. A lot are straight-forward removal of unnecessary optimizations. Some fix bugs around work item handling. Others restructure code so that [delayed_]work_pending() isn't necessary.
After this patchset, there remain a handful of [delayed_]work_pending() users. Some of them legit. Some quite broken. Hopefully, they can be converted too and we can unexport these easy-to-misuse interface.
This patchset contains the following 25 patches.
0001-charger_manager-don-t-use-delayed_-work_pending.patch 0002-ab8500_charger-don-t-use-delayed_-work_pending.patch 0003-sja1000-don-t-use-delayed_-work_pending.patch 0004-ipw2x00-simplify-scan_event-handling.patch 0005-devfreq-don-t-use-delayed_-work_pending.patch 0006-libertas-don-t-use-delayed_-work_pending.patch 0007-mwifiex-don-t-use-delayed_-work_pending.patch 0008-thinkpad_acpi-don-t-use-delayed_-work_pending.patch 0009-wl1251-don-t-use-delayed_-work_pending.patch 0010-kprobes-fix-wait_for_kprobe_optimizer.patch 0011-pm-don-t-use-delayed_-work_pending.patch 0012-bluetooth-l2cap-don-t-use-delayed_-work_pending.patch 0013-sound-wm8350-don-t-use-delayed_-work_pending.patch 0014-rfkill-don-t-use-delayed_-work_pending.patch 0015-x86-mce-don-t-use-delayed_-work_pending.patch 0016-PM-Domains-don-t-use-delayed_-work_pending.patch 0017-wm97xx-don-t-use-delayed_-work_pending.patch 0018-TMIO-MMC-don-t-use-delayed_-work_pending.patch 0019-net-caif-don-t-use-delayed_-work_pending.patch 0020-wimax-i2400m-fix-i2400m-wake_tx_skb-handling.patch 0021-tty-max3100-don-t-use-delayed_-work_pending.patch 0022-usb-at91_udc-don-t-use-delayed_-work_pending.patch 0023-video-exynos-don-t-use-delayed_-work_pending.patch 0024-debugobjects-don-t-use-delayed_-work_pending.patch 0025-ipc-don-t-use-delayed_-work_pending.patch
And available in the following git branch.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git review-work_pending-cleanup
diffstat follows.
arch/x86/kernel/cpu/mcheck/mce.c | 10 ++-------- drivers/base/power/domain.c | 3 +-- drivers/devfreq/devfreq.c | 3 +-- drivers/input/touchscreen/wm97xx-core.c | 4 +--- drivers/mmc/host/tmio_mmc_pio.c | 3 +-- drivers/net/caif/caif_shmcore.c | 15 +++++---------- drivers/net/can/sja1000/peak_pci.c | 3 +-- drivers/net/wimax/i2400m/netdev.c | 31 +++++++++++++++++-------------- drivers/net/wireless/ipw2x00/ipw2100.c | 31 ++++++++----------------------- drivers/net/wireless/ipw2x00/ipw2100.h | 3 +-- drivers/net/wireless/ipw2x00/ipw2200.c | 13 +++---------- drivers/net/wireless/libertas/cfg.c | 2 +- drivers/net/wireless/libertas/if_sdio.c | 9 ++++----- drivers/net/wireless/mwifiex/sdio.c | 9 ++++----- drivers/net/wireless/ti/wl1251/ps.c | 3 +-- drivers/platform/x86/thinkpad_acpi.c | 3 +-- drivers/power/ab8500_charger.c | 13 ++++--------- drivers/power/charger-manager.c | 31 ++++++++++++++++--------------- drivers/tty/serial/max3100.c | 3 +-- drivers/usb/gadget/at91_udc.c | 3 +-- drivers/video/exynos/exynos_dp_core.c | 6 ++---- include/net/bluetooth/l2cap.h | 24 ++++++++++++++++-------- ipc/util.c | 3 +-- kernel/kprobes.c | 23 +++++++++++++++-------- kernel/power/autosleep.c | 2 +- kernel/power/qos.c | 9 +++------ lib/debugobjects.c | 7 +++---- net/bluetooth/l2cap_core.c | 7 +++---- net/rfkill/input.c | 8 +++----- sound/soc/codecs/wm8350.c | 10 ++++------ 30 files changed, 125 insertions(+), 169 deletions(-)
Thanks.
--
tejun
PATCH 1/25 charger_manager: don't use [delayed_]work_pending()
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests and rewrite _setup_polling() so that it uses mod_delayed_work() if the next polling interval is sooner than currently scheduled. queue_delayed_work() is used otherwise.
Only compile tested. I noticed that two work items - setup_polling and cm_monitor_work - schedule each other. It's a very unusual construct and I'm fairly sure it's racy. You can't break such circular dependency by calling cancel on each. I strongly recommend revising the mechanism.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/power/charger-manager.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/power/charger-manager.c +16 -15
@@ -675,15 +675,21 @@ static void _setup_polling(struct work_struct *work)WARN (cm_wq ==NULL ,"charger-manager: workqueue not initialized" ". try it later. %s\n" , __func__); +/* +* Use mod_delayed_work() iff the next polling interval should +* occur before the currently scheduled one. If @cm_monitor_work +* isn't active, the end result is the same, so no need to worry +* about stale @next_polling. +*/ _next_polling = jiffies + polling_jiffy; -if (!delayed_work_pending (&cm_monitor_work) || - (delayed_work_pending (&cm_monitor_work) && -time_after (next_polling, _next_polling))) { - next_polling = jiffies + polling_jiffy; +if (time_before (_next_polling, next_polling)) {mod_delayed_work (cm_wq, &cm_monitor_work, polling_jiffy); + next_polling = _next_polling; + }else { +if (queue_delayed_work (cm_wq, &cm_monitor_work, polling_jiffy)) + next_polling = _next_polling; } - out:mutex_unlock (&cm_list_mtx); }
@@ -757,8 +763,7 @@ static void misc_event_handler(struct charger_manager *cm,if (cm_suspended)device_set_wakeup_capable (cm->dev, true); -if (!delayed_work_pending (&cm_monitor_work) && -is_polling_required (cm) && cm->desc->polling_interval_ms) +if (is_polling_required (cm) && cm->desc->polling_interval_ms)schedule_work (&setup_polling);uevent_notify (cm, default_event_names[type]); }
@@ -1176,8 +1181,7 @@ static int charger_extcon_notifier(struct notifier_block *self,* when charger cable is attached. */ if (cable->attached &&is_polling_required (cable->cm)) { -if (work_pending (&setup_polling)) -cancel_work_sync (&setup_polling); +cancel_work_sync (&setup_polling);schedule_work (&setup_polling); }
@@ -1667,10 +1671,8 @@ static int charger_manager_remove(struct platform_device *pdev)list_del (&cm->entry);mutex_unlock (&cm_list_mtx); -if (work_pending (&setup_polling)) -cancel_work_sync (&setup_polling); -if (delayed_work_pending (&cm_monitor_work)) -cancel_delayed_work_sync (&cm_monitor_work); +cancel_work_sync (&setup_polling); +cancel_delayed_work_sync (&cm_monitor_work);for (i =0 ; i < desc->num_charger_regulators ; i++) {struct charger_regulator *charger
@@ -1739,8 +1741,7 @@ static int cm_suspend_prepare(struct device *dev) cm_suspended = true; } -if (delayed_work_pending (&cm->fullbatt_vchk_work)) -cancel_delayed_work (&cm->fullbatt_vchk_work); +cancel_delayed_work (&cm->fullbatt_vchk_work); cm->status_save_ext_pwr_inserted =is_ext_pwr_online (cm); cm->status_save_batt =is_batt_present (cm);
Signature · 1 line
1.8.0.2
PATCH 2/25 ab8500_charger: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from ab8500_charger. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/power/ab8500_charger.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/ab8500_charger.c +4 -9
@@ -1319,8 +1319,7 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger,dev_dbg (di->dev,"%s Disabled USB charging\n" , __func__);/* Cancel any pending Vbat check work */ -if (delayed_work_pending (&di->check_vbat_work)) -cancel_delayed_work (&di->check_vbat_work); +cancel_delayed_work (&di->check_vbat_work); }ab8500_power_supply_changed (di, &di->usb_chg.psy);
@@ -2460,11 +2459,8 @@ static int ab8500_charger_resume(struct platform_device *pdev)dev_err (di->dev,"Failed to kick WD!\n" );/* If not already pending start a new timer */ -if (!delayed_work_pending ( - &di->kick_wd_work)) { -queue_delayed_work (di->charger_wq, &di->kick_wd_work, -round_jiffies (WD_KICK_INTERVAL )); - } +queue_delayed_work (di->charger_wq, &di->kick_wd_work, +round_jiffies (WD_KICK_INTERVAL )); }/* If we still have a HW failure, schedule a new check */
@@ -2482,8 +2478,7 @@ static int ab8500_charger_suspend(struct platform_device *pdev,struct ab8500_charger *di =platform_get_drvdata (pdev);/* Cancel any pending HW failure check */ -if (delayed_work_pending (&di->check_hw_failure_work)) -cancel_delayed_work (&di->check_hw_failure_work); +cancel_delayed_work (&di->check_hw_failure_work);return 0 ; }
Signature · 1 line
1.8.0.2
PATCH 4/25 ipw2x00: simplify scan_event handling
In reply to Tejun Heo* Drop unnesssary delayd_work_pending() tests.
* Unify scan_event_{now|later} by using mod_delayed_work() w/ 0 delay for scan_event_now.
* Make ipw2200 scan_event handling match ipw2100 - use mod_delayed_work() w/ 0 delay for immediate scanning.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/wireless/ipw2x00/ipw2100.c | 31 ++++++++----------------------- drivers/net/wireless/ipw2x00/ipw2100.h | 3 +-- drivers/net/wireless/ipw2x00/ipw2200.c | 13 +++---------- 3 files changed, 12 insertions(+), 35 deletions(-)
drivers/net/wireless/ipw2x00/ipw2100.c +8 -23
@@ -2181,9 +2181,10 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)mod_delayed_work (system_wq, &priv->rf_kill,round_jiffies_relative (HZ )); } -static void send_scan_event (void *data) +static void ipw2100_scan_event (struct work_struct *work) { -struct ipw2100_priv *priv = data; + struct ipw2100_priv *priv = container_of(work, struct ipw2100_priv, + scan_event.work);union iwreq_data wrqu; wrqu.data.length =0 ;
@@ -2191,18 +2192,6 @@ static void send_scan_event(void *data)wireless_send_event (priv->net_dev,SIOCGIWSCAN , &wrqu,NULL ); } -static void ipw2100_scan_event_later (struct work_struct *work) -{ -send_scan_event (container_of(work ,struct ipw2100_priv , - scan_event_later.work)); -} - -static void ipw2100_scan_event_now (struct work_struct *work) -{ -send_scan_event (container_of(work ,struct ipw2100_priv , -scan_event_now )); -} -static void isr_scan_complete (struct ipw2100_priv *priv,u32 status) {IPW_DEBUG_SCAN ("scan complete\n" );
@@ -2212,13 +2201,11 @@ 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)) -schedule_delayed_work (&priv->scan_event_later, -round_jiffies_relative (msecs_to_jiffies (4000 ))); +schedule_delayed_work (&priv->scan_event, +round_jiffies_relative (msecs_to_jiffies (4000 ))); }else { priv->user_requested_scan =0 ; -cancel_delayed_work (&priv->scan_event_later); -schedule_work (&priv->scan_event_now); +mod_delayed_work (system_wq, &priv->scan_event,0 ); } }
@@ -4459,8 +4446,7 @@ static void ipw2100_kill_works(struct ipw2100_priv *priv)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); +cancel_delayed_work_sync (&priv->scan_event); }static int ipw2100_tx_allocate (struct ipw2100_priv *priv)
@@ -6195,8 +6181,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,INIT_DELAYED_WORK (&priv->wx_event_work, ipw2100_wx_event_work);INIT_DELAYED_WORK (&priv->hang_check, ipw2100_hang_check);INIT_DELAYED_WORK (&priv->rf_kill, ipw2100_rf_kill); -INIT_WORK (&priv->scan_event_now, ipw2100_scan_event_now); -INIT_DELAYED_WORK (&priv->scan_event_later, ipw2100_scan_event_later); +INIT_DELAYED_WORK (&priv->scan_event, ipw2100_scan_event);tasklet_init (&priv->irq_tasklet, (void (*)(unsigned long )) ipw2100_irq_tasklet, (unsigned long )priv);
drivers/net/wireless/ipw2x00/ipw2100.h +1 -2
@@ -577,8 +577,7 @@ struct ipw2100_priv {struct delayed_work wx_event_work;struct delayed_work hang_check;struct delayed_work rf_kill; -struct work_struct scan_event_now; -struct delayed_work scan_event_later; +struct delayed_work scan_event;int user_requested_scan;
drivers/net/wireless/ipw2x00/ipw2200.c +3 -10
@@ -4480,18 +4480,11 @@ static void handle_scan_event(struct ipw_priv *priv) {/* Only userspace-requested scan completion events go out immediately */ if (!priv->user_requested_scan) { -if (!delayed_work_pending (&priv->scan_event)) -schedule_delayed_work (&priv->scan_event, -round_jiffies_relative (msecs_to_jiffies (4000 ))); +schedule_delayed_work (&priv->scan_event, +round_jiffies_relative (msecs_to_jiffies (4000 ))); }else { -union iwreq_data wrqu; - priv->user_requested_scan =0 ; -cancel_delayed_work (&priv->scan_event); - - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -wireless_send_event (priv->net_dev,SIOCGIWSCAN , &wrqu,NULL ); +mod_delayed_work (system_wq, &priv->scan_event,0 ); } }
Signature · 1 line
1.8.0.2
PATCH 6/25 libertas: don't use [delayed_]work_pending()
In reply to Tejun Heo* delayed_work_pending() test in lbs_cfg_scan() is spurious as priv->scan_req can't be NULL w/ scan_work pending; otherwise, lbs_scan_worker() will segfault. Drop it. BTW, the synchronization around scan_work seems racy. There's nothing synchronizing accesses to scan related fields in lbs_private.
* Drop work_pending() test from if_sdio_reset_card(). As work_pending() becomes %false before if_sdio_reset_card_worker() starts executing, it doesn't really protect anything. reset_host may change between mmc_remove_host() and mmc_add_host(). Make if_sdio_reset_card_worker() cache the target mmc_host so that it isn't affected by if_sdio_reset_card() racing with it.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/wireless/libertas/cfg.c | 2 +- drivers/net/wireless/libertas/if_sdio.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/wireless/libertas/cfg.c +1 -1
@@ -814,7 +814,7 @@ static int lbs_cfg_scan(struct wiphy *wiphy,lbs_deb_enter (LBS_DEB_CFG80211 ); -if (priv->scan_req ||delayed_work_pending (&priv->scan_work)) { +if (priv->scan_req) {/* old scan request not yet processed */ ret = -EAGAIN ; goto out;
drivers/net/wireless/libertas/if_sdio.c +4 -5
@@ -1074,6 +1074,8 @@ static struct mmc_host *reset_host;static void if_sdio_reset_card_worker (struct work_struct *work) { +struct mmc_host *target = reset_host; +/* * The actual reset operation must be run outside of lbs_thread. This * is because mmc_remove_host() will cause the device to be instantly
@@ -1085,8 +1087,8 @@ static void if_sdio_reset_card_worker(struct work_struct *work)*/ pr_info ("Resetting card..." ); -mmc_remove_host (reset_host); -mmc_add_host (reset_host); +mmc_remove_host (target); +mmc_add_host (target); } static DECLARE_WORK(card_reset_work, if_sdio_reset_card_worker);
@@ -1094,9 +1096,6 @@ static void if_sdio_reset_card(struct lbs_private *priv) {struct if_sdio_card *card = priv->card; -if (work_pending (&card_reset_work)) -return ; - reset_host = card->func->card->host;schedule_work (&card_reset_work); }
Signature · 1 line
1.8.0.2
PATCH 7/25 mwifiex: don't use [delayed_]work_pending()
In reply to Tejun HeoDrop work_pending() test from mwifiex_sdio_card_reset(). As work_pending() becomes %false before sdio_card_reset_worker() starts executing, it doesn't really protect anything. reset_host may change between mmc_remove_host() and mmc_add_host(). Make sdio_card_reset_worker() cache the target mmc_host so that it isn't affected by mwifiex_sdio_card_reset() racing with it.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/wireless/mwifiex/sdio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/mwifiex/sdio.c +4 -5
@@ -1752,6 +1752,8 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)static struct mmc_host *reset_host;static void sdio_card_reset_worker (struct work_struct *work) { +struct mmc_host *target = reset_host; +/* The actual reset operation must be run outside of driver thread. * This is because mmc_remove_host() will cause the device to be * 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)*/ pr_err ("Resetting card...\n" ); -mmc_remove_host (reset_host); +mmc_remove_host (target);/* 20ms delay is based on experiment with sdhci controller */ mdelay (20 ); -mmc_add_host (reset_host); +mmc_add_host (target); } static DECLARE_WORK(card_reset_work, sdio_card_reset_worker);
@@ -1773,9 +1775,6 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter) {struct sdio_mmc_card *card = adapter->card; -if (work_pending (&card_reset_work)) -return ; - reset_host = card->func->card->host;schedule_work (&card_reset_work); }
Signature · 1 line
1.8.0.2
PATCH 9/25 wl1251: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wl1251. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/wireless/ti/wl1251/ps.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/ti/wl1251/ps.c +1 -2
@@ -68,8 +68,7 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)unsigned long timeout, start;u32 elp_reg; -if (delayed_work_pending (&wl->elp_work)) -cancel_delayed_work (&wl->elp_work); +cancel_delayed_work (&wl->elp_work);if (!wl->elp)return 0 ;
Signature · 1 line
1.8.0.2
PATCH 11/25 pm: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from pm autosleep and qos. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
kernel/power/autosleep.c | 2 +- kernel/power/qos.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-)
kernel/power/autosleep.c +1 -1
@@ -66,7 +66,7 @@ static DECLARE_WORK(suspend_work, try_to_suspend);void queue_up_suspend_work (void ) { -if (!work_pending (&suspend_work) && autosleep_state >PM_SUSPEND_ON ) +if (autosleep_state >PM_SUSPEND_ON )queue_work (autosleep_wq, &suspend_work); }
kernel/power/qos.c +3 -6
@@ -359,8 +359,7 @@ void pm_qos_update_request(struct pm_qos_request *req,return ; } -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work);if (new_value != req->node.prio) pm_qos_update_target(
@@ -386,8 +385,7 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value, "%s called for unknown object.", __func__))return ; -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work);if (new_value != req->node.prio) pm_qos_update_target(
@@ -416,8 +414,7 @@ void pm_qos_remove_request(struct pm_qos_request *req)return ; } -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work); pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, &req->node, PM_QOS_REMOVE_REQ,
Signature · 1 line
1.8.0.2
PATCH 14/25 rfkill: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from rfkill. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
net/rfkill/input.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/rfkill/input.c +3 -5
@@ -148,11 +148,9 @@ static unsigned long rfkill_ratelimit(const unsigned long last)static void rfkill_schedule_ratelimited (void ) { -if (delayed_work_pending (&rfkill_op_work)) -return ; -schedule_delayed_work (&rfkill_op_work, -rfkill_ratelimit (rfkill_last_scheduled)); - rfkill_last_scheduled = jiffies; +if (schedule_delayed_work (&rfkill_op_work, +rfkill_ratelimit (rfkill_last_scheduled))) + rfkill_last_scheduled = jiffies; }static void rfkill_schedule_global_op (enum rfkill_sched_op op)
Signature · 1 line
1.8.0.2
PATCH 10/25 kprobes: fix wait_for_kprobe_optimizer()
In reply to Tejun Heowait_for_kprobe_optimizer() seems largely broken. It uses optimizer_comp which is never re-initialized, so wait_for_kprobe_optimizer() will never wait for anything once kprobe_optimizer() finishes all pending jobs for the first time.
Also, aside from completion, delayed_work_pending() is %false once kprobe_optimizer() starts execution and wait_for_kprobe_optimizer() won't wait for it.
Reimplement it so that it flushes optimizing_work until [un]optimizing_lists are empty. Note that this also makes optimizing_work execute immediately if someone's waiting for it, which is the nicer behavior.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
kernel/kprobes.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
kernel/kprobes.c +15 -8
@@ -471,7 +471,6 @@ static LIST_HEAD(unoptimizing_list);static void kprobe_optimizer (struct work_struct *work); static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer); -static DECLARE_COMPLETION (optimizer_comp);#define OPTIMIZE_DELAY 5/*
@@ -552,8 +551,7 @@ static __kprobes void do_free_cleaned_kprobes(struct list_head *free_list)/* Start optimizer after OPTIMIZE_DELAY passed */ static __kprobes void kick_kprobe_optimizer (void ) { -if (!delayed_work_pending (&optimizing_work)) -schedule_delayed_work (&optimizing_work,OPTIMIZE_DELAY ); +schedule_delayed_work (&optimizing_work,OPTIMIZE_DELAY ); }/* Kprobe jump optimizer */
@@ -592,16 +590,25 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)/* Step 5: Kick optimizer again if needed */ if (!list_empty (&optimizing_list) || !list_empty (&unoptimizing_list))kick_kprobe_optimizer (); -else -/* Wake up all waiters */ -complete_all (&optimizer_comp); }/* Wait for completing optimization and unoptimization */ static __kprobes void wait_for_kprobe_optimizer (void ) { -if (delayed_work_pending (&optimizing_work)) -wait_for_completion (&optimizer_comp); +mutex_lock (&kprobe_mutex); + +while (!list_empty (&optimizing_list) || !list_empty (&unoptimizing_list)) { +mutex_unlock (&kprobe_mutex); + +/* this will also make optimizing_work execute immmediately */ +flush_delayed_work (&optimizing_work); +/* @optimizing_work might not have been queued yet, relax */ +cpu_relax (); + +mutex_lock (&kprobe_mutex); + } + +mutex_unlock (&kprobe_mutex); }/* Optimize kprobe if p is ready to be optimized */
Signature · 1 line
1.8.0.2
PATCH 13/25 sound/wm8350: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wm8350. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
sound/soc/codecs/wm8350.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
sound/soc/codecs/wm8350.c +4 -6
@@ -283,18 +283,16 @@ static int pga_event(struct snd_soc_dapm_widget *w, out->ramp =WM8350_RAMP_UP ; out->active =1 ; -if (!delayed_work_pending (&codec->dapm.delayed_work)) -schedule_delayed_work (&codec->dapm.delayed_work, -msecs_to_jiffies (1 )); +schedule_delayed_work (&codec->dapm.delayed_work, +msecs_to_jiffies (1 ));break ;case SND_SOC_DAPM_PRE_PMD : out->ramp =WM8350_RAMP_DOWN ; out->active =0 ; -if (!delayed_work_pending (&codec->dapm.delayed_work)) -schedule_delayed_work (&codec->dapm.delayed_work, -msecs_to_jiffies (1 )); +schedule_delayed_work (&codec->dapm.delayed_work, +msecs_to_jiffies (1 ));break ; }
Signature · 1 line
1.8.0.2
PATCH 21/25 tty/max3100: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from max3100. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/tty/serial/max3100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/max3100.c +1 -2
@@ -179,8 +179,7 @@ static void max3100_work(struct work_struct *w);static void max3100_dowork (struct max3100_port *s) { -if (!s->force_end_work && !work_pending (&s->work) && - !freezing (current) && !s->suspending) +if (!s->force_end_work && !freezing (current) && !s->suspending)queue_work (s->workqueue, &s->work); }
Signature · 1 line
1.8.0.2
PATCH 22/25 usb/at91_udc: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from at91_udc. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/usb/gadget/at91_udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/at91_udc.c +1 -2
@@ -1621,8 +1621,7 @@ static void at91_vbus_timer(unsigned long data)* bus such as i2c or spi which may sleep, so schedule some work * to read the vbus gpio */ -if (!work_pending (&udc->vbus_timer_work)) -schedule_work (&udc->vbus_timer_work); +schedule_work (&udc->vbus_timer_work); } static int at91_start(struct usb_gadget *gadget,
Signature · 1 line
1.8.0.2
PATCH 25/25 ipc: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from ipc. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
ipc/util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
ipc/util.c +1 -2
@@ -71,8 +71,7 @@ static int ipc_memory_callback(struct notifier_block *self,* activate the ipcns notification chain. * No need to keep several ipc work items on the queue. */ -if (!work_pending (&ipc_memory_wq)) -schedule_work (&ipc_memory_wq); +schedule_work (&ipc_memory_wq);break ;case MEM_GOING_ONLINE :case MEM_GOING_OFFLINE :
Signature · 1 line
1.8.0.2
PATCH 24/25 debugobjects: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from debugobjects. While at it, change @sched to bool and move kevent_up() test to later for brevity.
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
lib/debugobjects.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/debugobjects.c +3 -4
@@ -189,20 +189,19 @@ static void free_obj_work(struct work_struct *work)static void free_object (struct debug_obj *obj) {unsigned long flags; -int sched =0 ; +bool sched;raw_spin_lock_irqsave (&pool_lock, flags);/* * schedule work when the pool is filled and the cache is * initialized: */ -if (obj_pool_free >ODEBUG_POOL_SIZE && obj_cache) - sched =keventd_up () && !work_pending (&debug_obj_work); + sched = obj_pool_free >ODEBUG_POOL_SIZE && obj_cache;hlist_add_head (&obj->node, &obj_pool); obj_pool_free++; obj_pool_used--;raw_spin_unlock_irqrestore (&pool_lock, flags); -if (sched) +if (sched &&keventd_up ())schedule_work (&debug_obj_work); }
Signature · 1 line
1.8.0.2
PATCH 23/25 video/exynos: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from exynos_dp_core. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/video/exynos/exynos_dp_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/exynos/exynos_dp_core.c +2 -4
@@ -1121,8 +1121,7 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)disable_irq (dp->irq); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (pdev->dev.of_node) {if (dp->phy_addr)
@@ -1144,8 +1143,7 @@ static int exynos_dp_suspend(struct device *dev)struct exynos_dp_platdata *pdata = dev->platform_data;struct exynos_dp_device *dp =dev_get_drvdata (dev); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (dev->of_node) {if (dp->phy_addr)
Signature · 1 line
1.8.0.2
PATCH 20/25 wimax/i2400m: fix i2400m->wake_tx_skb handling
In reply to Tejun Heoi2400m_net_wake_tx() sets ->wake_tx_skb with the given skb if ->wake_tx_ws is not pending; however, i2400m_wake_tx_work() could have just started execution and haven't fetched -><wake_tx_skb yet. The previous packet will be leaked.
Update ->wake_tx_skb handling.
* i2400m_net_wake_tx() now tests whether the previous ->wake_tx_skb has been consumed by ->wake_tx_ws instead of testing work_pending().
* i2400m_net_wake_stop() is simplified similarly. It always puts ->wake_tx_skb if non-NULL.
* Spurious ->wake_tx_skb dereference outside critical section dropped from i2400m_wake_tx_work().
Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/wimax/i2400m/netdev.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/net/wimax/i2400m/netdev.c +17 -14
@@ -156,7 +156,7 @@ void i2400m_wake_tx_work(struct work_struct *ws) struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);struct net_device *net_dev = i2400m->wimax_dev.net_dev;struct device *dev =i2400m_dev (i2400m); -struct sk_buff *skb = i2400m->wake_tx_skb; +struct sk_buff *skb;unsigned long flags;spin_lock_irqsave (&i2400m->tx_lock, flags);
@@ -236,23 +236,26 @@ void i2400m_tx_prep_header(struct sk_buff *skb)void i2400m_net_wake_stop (struct i2400m *i2400m) {struct device *dev =i2400m_dev (i2400m); +struct sk_buff *wake_tx_skb; +unsigned long flags;d_fnstart (3 , dev,"(i2400m %p)\n" , i2400m); -/* See i2400m_hard_start_xmit(), references are taken there -* and here we release them if the work was still -* pending. Note we can't differentiate work not pending vs -* never scheduled, so the NULL check does that. */ -if (cancel_work_sync (&i2400m->wake_tx_ws) ==0 - && i2400m->wake_tx_skb !=NULL ) { -unsigned long flags; -struct sk_buff *wake_tx_skb; -spin_lock_irqsave (&i2400m->tx_lock, flags); - wake_tx_skb = i2400m->wake_tx_skb;/* compat help */ - i2400m->wake_tx_skb =NULL ;/* compat help */ -spin_unlock_irqrestore (&i2400m->tx_lock, flags); +/* +* See i2400m_hard_start_xmit(), references are taken there and +* here we release them if the packet was still pending. +*/ +cancel_work_sync (&i2400m->wake_tx_ws); + +spin_lock_irqsave (&i2400m->tx_lock, flags); + wake_tx_skb = i2400m->wake_tx_skb; + i2400m->wake_tx_skb =NULL ; +spin_unlock_irqrestore (&i2400m->tx_lock, flags); + +if (wake_tx_skb) {i2400m_put (i2400m);kfree_skb (wake_tx_skb); } +d_fnend (3 , dev,"(i2400m %p) = void\n" , i2400m); }
@@ -288,7 +291,7 @@ int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,* and if pending, release those resources. */ result =0 ;spin_lock_irqsave (&i2400m->tx_lock, flags); -if (!work_pending (&i2400m->wake_tx_ws)) { +if (!i2400m->wake_tx_skb) {netif_stop_queue (net_dev);i2400m_get (i2400m); i2400m->wake_tx_skb =skb_get (skb);/* transfer ref count */
Signature · 1 line
1.8.0.2
PATCH 19/25 net/caif: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from caif. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/net/caif/caif_shmcore.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/net/caif/caif_shmcore.c +5 -10
@@ -183,9 +183,7 @@ int caif_shmdrv_rx_cb(u32 mbx_msg, void *priv)spin_unlock_irqrestore (&pshm_drv->lock, flags);/* Schedule RX work queue. */ -if (!work_pending (&pshm_drv->shm_rx_work)) -queue_work (pshm_drv->pshm_rx_workqueue, - &pshm_drv->shm_rx_work); +queue_work (pshm_drv->pshm_rx_workqueue, &pshm_drv->shm_rx_work); }/* Check for emptied buffers. */
@@ -246,9 +244,8 @@ int caif_shmdrv_rx_cb(u32 mbx_msg, void *priv)/* Schedule the work queue. if required */ -if (!work_pending (&pshm_drv->shm_tx_work)) -queue_work (pshm_drv->pshm_tx_workqueue, - &pshm_drv->shm_tx_work); +queue_work (pshm_drv->pshm_tx_workqueue, + &pshm_drv->shm_tx_work); }else spin_unlock_irqrestore (&pshm_drv->lock, flags); }
@@ -374,8 +371,7 @@ static void shm_rx_work_func(struct work_struct *rx_work) }/* Schedule the work queue. if required */ -if (!work_pending (&pshm_drv->shm_tx_work)) -queue_work (pshm_drv->pshm_tx_workqueue, &pshm_drv->shm_tx_work); +queue_work (pshm_drv->pshm_tx_workqueue, &pshm_drv->shm_tx_work); }
@@ -528,8 +524,7 @@ static int shm_netdev_tx(struct sk_buff *skb, struct net_device *shm_netdev)skb_queue_tail (&pshm_drv->sk_qhead, skb);/* Schedule Tx work queue. for deferred processing of skbs*/ -if (!work_pending (&pshm_drv->shm_tx_work)) -queue_work (pshm_drv->pshm_tx_workqueue, &pshm_drv->shm_tx_work); +queue_work (pshm_drv->pshm_tx_workqueue, &pshm_drv->shm_tx_work);return 0 ; }
Signature · 1 line
1.8.0.2
PATCH 15/25 x86/mce: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from x86/mce. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
arch/x86/kernel/cpu/mcheck/mce.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +2 -8
@@ -514,8 +514,7 @@ static void mce_schedule_work(void) {if (!mce_ring_empty ()) {struct work_struct *work = &__get_cpu_var (mce_work); -if (!work_pending (work)) -schedule_work (work); +schedule_work (work); } }
@@ -1351,12 +1350,7 @@ int mce_notify_irq(void)/* wake processes polling /dev/mcelog */ wake_up_interruptible (&mce_chrdev_wait); -/* -* There is no risk of missing notifications because -* work_pending is always cleared before the function is -* executed. -*/ -if (mce_helper[0 ] && !work_pending (&mce_trigger_work)) +if (mce_helper[0 ])schedule_work (&mce_trigger_work);if (__ratelimit (&ratelimit))
Signature · 1 line
1.8.0.2
PATCH 5/25 devfreq: don't use [delayed_]work_pending()
In reply to Tejun HeoThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from devfreq. Only compile tested.
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Thanks.
drivers/devfreq/devfreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/devfreq/devfreq.c +1 -2
@@ -291,8 +291,7 @@ void devfreq_monitor_resume(struct devfreq *devfreq)if (!devfreq->stop_polling) goto out; -if (!delayed_work_pending (&devfreq->work) && - devfreq->profile->polling_ms) +if (devfreq->profile->polling_ms)queue_delayed_work (devfreq_wq, &devfreq->work,msecs_to_jiffies (devfreq->profile->polling_ms)); devfreq->stop_polling = false;
Signature · 1 line
1.8.0.2
Andrew Morton
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Tejun Heoipc/util.c static int ipc_memory_callback(struct notifier_block *self, · line 74
Quoted 7 lines · On Fri, 21 Dec 2012 17:57:15 -0800 Tejun Heo <[email protected]> wrote:
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
ipc/util.c +1
-2-if (!work_pending (&ipc_memory_wq)) -schedule_work (&ipc_memory_wq); +schedule_work (&ipc_memory_wq);
Well, the new code is a ton slower than the old code if the work is frequently pending, so some care is needed with such a conversion.
That's not an issue for the IPC callsite - memory offlining isn't frequent.
Quoted 5 lines
...
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Please merge this one yourself.
Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
Hello, Andrew.
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Fri, 21 Dec 2012 17:57:15 -0800 Tejun Heo <[email protected]> wrote:
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 6 lines
ipc/util.c static int ipc_memory_callback(struct notifier_block *self, · line 74
Quoted 3 lines
ipc/util.c +1
-2-if (!work_pending (&ipc_memory_wq)) -schedule_work (&ipc_memory_wq); +schedule_work (&ipc_memory_wq);Well, the new code is a ton slower than the old code if the work is frequently pending, so some care is needed with such a conversion.
Yeah, I mentioned it in the head message. it comes down to test_and_set_bit() vs. test_bit() and none of the current users seems to be hot enough for that to matter at all.
In very hot paths, such optimization *could* be valid. The problem is that [delayed_]work_pending() seem to be abused much more than they are put to any actual usefulness. Maybe we should rename them to something really ugly. I don't know.
Quoted 10 lines
That's not an issue for the IPC callsite - memory offlining isn't frequent.
Quoted 5 lines
...
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Please merge this one yourself.
Can I add your acked-by?
Thanks.
Signature · 1 line
tejun
RE: [PATCH 23/25] video/exynos: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 10 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
exynos_dp_core. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Kukjin Kim <[email protected]>
Quoted 4 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Cc'ed Jingoo and Florian.
Now the exynos dp driver are being handled by Jingoo so let's waiting for his opinion to take this by himself or not.
- Kukjin Kim
Quoted 33 lines
Thanks.
drivers/video/exynos/exynos_dp_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/video/exynos/exynos_dp_core.c +1
-2@@ -1121,8 +1121,7 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev) disable_irq(dp->irq); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (pdev->dev.of_node) {drivers/video/exynos/exynos_dp_core.c +1
-3if (dp->phy_addr)@@ -1144,8 +1143,7 @@ static int exynos_dp_suspend(struct device *dev)struct exynos_dp_platdata *pdata = dev->platform_data;struct exynos_dp_device *dp =dev_get_drvdata (dev); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (dev->of_node) {if (dp->phy_addr) --1.8.0.2
Re: [PATCH 21/25] tty/max3100: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 4 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 8 lines
Remove unnecessary pending tests from max3100. Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Jiri Slaby <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Please, feel free to take it through your tree:
David Miller
maintainerRe: [PATCH 03/25] sja1000: don't use [delayed_]work_pending()
In reply to Tejun HeoFrom: Tejun Heo <[email protected]>
Date: Fri, 21 Dec 2012 17:56:53 -0800
Quoted 6 lines
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from sja1000. Only compile tested.
Quoted 7 lines
Signed-off-by Tejun Heo <[email protected]>Cc Wolfgang Grandegger <[email protected]>Cc "David S. Miller" <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
I would suggest just taking it via the workqueue tree, thanks Tejun.
Borislav Petkov
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 16 lines · Tejun Heo
Hello, Andrew.
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Fri, 21 Dec 2012 17:57:15 -0800 Tejun Heo <[email protected]> wrote:
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 6 lines
ipc/util.c static int ipc_memory_callback(struct notifier_block *self, · line 74
Quoted 3 lines
ipc/util.c +1
-2-if (!work_pending (&ipc_memory_wq)) -schedule_work (&ipc_memory_wq); +schedule_work (&ipc_memory_wq);Well, the new code is a ton slower than the old code if the work is frequently pending, so some care is needed with such a conversion.
Quoted 8 lines
Yeah, I mentioned it in the head message. it comes down to
test_and_set_bit()vs.test_bit()and none of the current users seems to be hot enough for that to matter at all.In very hot paths, such optimization *could* be valid. The problem is that [delayed_]work_pending() seem to be abused much more than they are put to any actual usefulness. Maybe we should rename them to something really ugly. I don't know.
Hmm, we're also disabling local interrupts for no reason, if there's no work pending (this is queue_work_on()):
2d1a: 9c pushfq
2d1b: 41 5c pop %r12
2d1d: fa cli
2d1e: e8 00 00 00 00 callq 2d23 <queue_work_on+0x33>
2d23: f0 0f ba 2b 00 lock btsl $0x0,(%rbx)so there's IRQ disable + locked operation in schedule_work vs a simple test_bit which doesn't even require the LOCK prefix.
Now you say those paths are not fast paths, but the reverse of this optimization is also true: what happens if people start using schedule_work() in fast paths without checking whether work is pending? A useless IRQ disable + locked operation + IRQ enable.
I don't know but this could hurt in some situations, I'm thinking of RT folk especially here.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 11/25] pm: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Can you please say why they are buggy?
Quoted 9 lines
Remove unnecessary pending tests from pm autosleep and qos. Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
I can take it. I will send a pull request with fixes later in the cycle (maybe even before -rc2).
Thanks,
Rafael
Quoted 52 lines
kernel/power/autosleep.c | 2 +- kernel/power/qos.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-)kernel/power/autosleep.c +1
-1@@ -66,7 +66,7 @@ static DECLARE_WORK(suspend_work, try_to_suspend);void queue_up_suspend_work (void ) { -if (!work_pending (&suspend_work) && autosleep_state >PM_SUSPEND_ON ) +if (autosleep_state >PM_SUSPEND_ON )queue_work (autosleep_wq, &suspend_work); }kernel/power/qos.c +3
-6@@ -359,8 +359,7 @@ void pm_qos_update_request(struct pm_qos_request *req,return ; } -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work);if (new_value != req->node.prio) pm_qos_update_target(@@ -386,8 +385,7 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value, "%s called for unknown object.", __func__))return ; -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work);if (new_value != req->node.prio) pm_qos_update_target(@@ -416,8 +414,7 @@ void pm_qos_remove_request(struct pm_qos_request *req)return ; } -if (delayed_work_pending (&req->work)) -cancel_delayed_work_sync (&req->work); +cancel_delayed_work_sync (&req->work); pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, &req->node, PM_QOS_REMOVE_REQ,
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH 16/25] PM / Domains: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Is the particular one you're removing from domain.c buggy?
Quoted 2 lines
Remove unnecessary pending tests from power domains. Only compile tested.
I can take this one too.
Thanks,
Rafael
Quoted 27 lines
Signed-off-by Tejun Heo <[email protected]>Cc Rafael J. Wysocki <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
drivers/base/power/domain.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/base/power/domain.c +1
-2@@ -433,8 +433,7 @@ static bool genpd_abort_poweroff(struct generic_pm_domain *genpd)*/ void genpd_queue_power_off_work (struct generic_pm_domain *genpd) { -if (!work_pending (&genpd->power_off_work)) -queue_work (pm_wq, &genpd->power_off_work); +queue_work (pm_wq, &genpd->power_off_work); }/**
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH 09/25] wl1251: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 6 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wl1251. Only compile tested.
Quoted 8 lines
Signed-off-by Tejun Heo <[email protected]>Cc Luciano Coelho <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
It's probably easier if you take it via your tree. This driver doesn't get patches very often, so I doubt there will be any conflicts.
Thank you!
--
Luca.
RE: [PATCH 20/25] wimax/i2400m: fix i2400m->wake_tx_skb handling
In reply to Tejun HeoQuoted 1 line
From: Tejun Heo [mailto:[email protected]] On Behalf Of Tejun Heo
0m: fix i2400m->wake_tx_skb handling
Quoted 1 line
...
Quoted 2 lines
Only compile tested.
I don't have access to hardware to test this--might want to contact Dan Williams, as he has been more actively using it.
Johannes Berg
maintainerRe: [PATCH 14/25] rfkill: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 6 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from rfkill. Only compile tested.
Looks fine to me, feel free to route through your tree -- nobody changes rfkill much (famous last words...) :-)
johannes
RE: [PATCH 07/25] mwifiex: don't use [delayed_]work_pending()
In reply to Tejun HeoHi Tejun,
Thanks for the patch.
Quoted 7 lines
Drop
work_pending()test frommwifiex_sdio_card_reset(). Aswork_pending()becomes %false beforesdio_card_reset_worker()starts executing, it doesn't really protect anything.reset_hostmay change betweenmmc_remove_host()andmmc_add_host(). Makesdio_card_reset_worker()cache the targetmmc_hostso that it isn't affected bymwifiex_sdio_card_reset()racing with it.
Quoted 5 lines
Only compile tested.
Quoted 3 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
If you are taking other patches in this series through your tree, please take this one too.
Thanks,
Bing
Quoted 44 lines
Thanks.
drivers/net/wireless/mwifiex/sdio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/wireless/mwifiex/sdio.c +4
-6@@ -1752,6 +1752,8 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)static struct mmc_host *reset_host;static void sdio_card_reset_worker (struct work_struct *work) { +struct mmc_host *target = reset_host; +/* The actual reset operation must be run outside of driver thread. * This is because mmc_remove_host() will cause the device to be * 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)*/ pr_err ("Resetting card...\n" ); -mmc_remove_host (reset_host); +mmc_remove_host (target);/* 20ms delay is based on experiment with sdhci controller */ mdelay (20 ); -mmc_add_host (reset_host); +mmc_add_host (target); } static DECLARE_WORK(card_reset_work, sdio_card_reset_worker);@@ -1773,9 +1775,6 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter) {struct sdio_mmc_card *card = adapter->card; -if (work_pending (&card_reset_work)) -return ; - reset_host = card->func->card->host;schedule_work (&card_reset_work); } --1.8.0.2
Re: [PATCH 08/25] thinkpad_acpi: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 11 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
thinkpad_acpi. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Henrique de Moraes Holschuh <ibm-acpi-N3TV7GIv+o9fyO9Q7EP/[email protected]>
Quoted 3 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
It will not clash with anything I know of, so feel free to route it through the workqueue tree.
Signature · 11 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d
Dmitry Torokhov
maintainerRe: [PATCH 17/25] wm97xx: don't use [delayed_]work_pending()
In reply to Tejun HeoHi Tejun,
Quoted 29 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wm97xx. Instead of testing
work_pending(), use the return value ofqueue_work()to decide whether to disable IRQ or not.Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Mark Brown <[email protected]>Cc Liam Girdwood <[email protected]>Cc Dmitry Torokhov <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
drivers/input/touchscreen/wm97xx-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/input/touchscreen/wm97xx-core.c +0
-0
drivers/input/touchscreen/wm97xx-core.c static irqreturn_t wm97xx_pen_interrupt(int irq, void *dev_id) · line 368
Quoted 9 lines
drivers/input/touchscreen/wm97xx-core.c +1
-3@@ -363,10 +363,8 @@ static irqreturn_t wm97xx_pen_interrupt(int irq, void *dev_id) {struct wm97xx *wm = dev_id; -if (!work_pending (&wm->pen_event_work)) { +if (queue_work (wm->ts_workq, &wm->pen_event_work)) wm->mach_ops->irq_enable (wm,0 ); -queue_work (wm->ts_workq, &wm->pen_event_work); - }
This is not 100% equivalent transformation as now we schedule first and disable IRQ later... Anyway, I think the driver shoudl be converted to threaded IRQ instead. Mark, does the patch below make any sense to you?
Thanks.
Signature · 14 lines
Dmitry Input: wm97xx - switch to using threaded IRQ Instead of manually disabling and enabling interrupts and scheduling work to access the device, let's use threaded oneshot interrupt handler. It simplifies things. Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/touchscreen/wm97xx-core.c | 42 +++++-------------------------- include/linux/wm97xx.h | 1 - 2 files changed, 7 insertions(+), 36 deletions(-)
drivers/input/touchscreen/wm97xx-core.c +7 -35
@@ -289,11 +289,12 @@ void wm97xx_set_suspend_mode(struct wm97xx *wm, u16 mode)EXPORT_SYMBOL_GPL (wm97xx_set_suspend_mode);/* -* Handle a pen down interrupt. +* Codec PENDOWN irq handler +* */ -static void wm97xx_pen_irq_worker (struct work_struct *work) +static irqreturn_t wm97xx_pen_interrupt (int irq,void *dev_id) { - struct wm97xx *wm = container_of(work, struct wm97xx, pen_event_work); +struct wm97xx *wm = dev_id;int pen_was_down = wm->pen_is_down;/* do we need to enable the touch panel reader */
@@ -347,27 +348,6 @@ static void wm97xx_pen_irq_worker(struct work_struct *work)if (!wm->pen_is_down && wm->mach_ops->acc_enabled) wm->mach_ops->acc_pen_up (wm); - wm->mach_ops->irq_enable (wm,1 ); -} - -/* -* Codec PENDOWN irq handler -* -* We have to disable the codec interrupt in the handler because it -* can take up to 1ms to clear the interrupt source. We schedule a task -* in a work queue to do the actual interaction with the chip. The -* interrupt is then enabled again in the slow handler when the source -* has been cleared. -*/ -static irqreturn_t wm97xx_pen_interrupt (int irq,void *dev_id) -{ -struct wm97xx *wm = dev_id; - -if (!work_pending (&wm->pen_event_work)) { - wm->mach_ops->irq_enable (wm,0 ); -queue_work (wm->ts_workq, &wm->pen_event_work); - } -return IRQ_HANDLED ; }
@@ -378,12 +358,9 @@ static int wm97xx_init_pen_irq(struct wm97xx *wm) {u16 reg; -/* If an interrupt is supplied an IRQ enable operation must also be -* provided. */ -BUG_ON (!wm->mach_ops->irq_enable); - -if (request_irq (wm->pen_irq, wm97xx_pen_interrupt,IRQF_SHARED , -"wm97xx-pen" , wm)) { +if (request_threaded_irq (wm->pen_irq,NULL , wm97xx_pen_interrupt, +IRQF_SHARED |IRQF_ONESHOT , +"wm97xx-pen" , wm)) {dev_err (wm->dev,"Failed to register pen down interrupt, polling" ); wm->pen_irq =0 ;
@@ -502,7 +479,6 @@ static int wm97xx_ts_input_open(struct input_dev *idev) wm->codec->dig_enable (wm,1 );INIT_DELAYED_WORK (&wm->ts_reader, wm97xx_ts_reader); -INIT_WORK (&wm->pen_event_work, wm97xx_pen_irq_worker); wm->ts_reader_min_interval =HZ >=100 ?HZ /100 :1 ;if (wm->ts_reader_min_interval <1 )
@@ -553,10 +529,6 @@ static void wm97xx_ts_input_close(struct input_dev *idev) wm->pen_is_down =0 ; -/* Balance out interrupt disables/enables */ -if (cancel_work_sync (&wm->pen_event_work)) - wm->mach_ops->irq_enable (wm,1 ); -/* ts_reader rearms itself so we need to explicitly stop it * before we destroy the workqueue. */
include/linux/wm97xx.h +0 -1
@@ -280,7 +280,6 @@ struct wm97xx {unsigned long ts_reader_min_interval;/* Minimum interval */ unsigned int pen_irq;/* Pen IRQ number in use */ struct workqueue_struct *ts_workq; -struct work_struct pen_event_work;u16 acc_slot;/* AC97 slot used for acc touch data */ u16 acc_rate;/* acc touch data rate */ unsigned pen_is_down:1; /* Pen is down */
Mark Brown
AppliedRe: [PATCH 13/25] sound/wm8350: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Applied, thanks.
Re: [PATCH 17/25] wm97xx: don't use [delayed_]work_pending()
In reply to Dmitry TorokhovQuoted 3 lines · Dmitry Torokhov
This is not 100% equivalent transformation as now we schedule first and disable IRQ later... Anyway, I think the driver shoudl be converted to threaded IRQ instead. Mark, does the patch below make any sense to you?
I'm a bit nervous about the fact that currently both the pen down IRQ and the coordinate read are pushed through a single workqueue so are serialised but after your patch they'll be split into the IRQ thread and the workqueue. It *should* be fine but I'd have to sit there and study it to convince myself that it's safe.
Re: [PATCH 17/25] wm97xx: don't use [delayed_]work_pending()
In reply to Dmitry TorokhovHello, Dmitry.
Quoted 3 lines · Dmitry Torokhov
This is not 100% equivalent transformation as now we schedule first and disable IRQ later... Anyway, I think the driver shoudl be converted to threaded IRQ instead. Mark, does the patch below make any sense to you?
Yeah, I think the conversion is actually broken. There isn't anything which prevents work item execution racing against irq disabling. I agree the right thing to do is using threaded irq handler.
Thanks!
Signature · 1 line
tejun
Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Borislav PetkovHello, Borislav.
Quoted 4 lines · Borislav Petkov
Now you say those paths are not fast paths, but the reverse of this optimization is also true: what happens if people start using
schedule_work()in fast paths without checking whether work is pending? A useless IRQ disable + locked operation + IRQ enable.
That's a really strange argument. If we extend from that, we have to optimize cold paths to prevent fast paths copy from them, which sounds really silly to me.
If one looks at something happening in a path as cold as memory hotplug and thinks about optimizing a coupld memory accesses, the person's priorities need serious reconsideration. I think approaches like that are actively harmful. They lead to unnecessary (and thus difficult to comprehend) convolutions which don't really help anything while deteoriorating code base.
I don't think we have cases where this actually matters but it could be that we can add work_pending() tests to queue_work_on(). I *think* that shouldn't break work scheduling semantics. Not completely sure tho. Need to think about it more.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
Hello, again.
Quoted 4 lines · Tejun Heo
I don't think we have cases where this actually matters but it could be that we can add
work_pending()tests toqueue_work_on(). I *think* that shouldn't break work scheduling semantics. Not completely sure tho. Need to think about it more.
I was confused a bit there. We can't. Nothing guarantees that the queuer sees the cleared PENDING before the work item starts execution, and I think ipc memory hotplug could also be broken from that. It's highly unlikely to actually happen and there may be external locking which prevents the race from actually happening, but there's nothing synchronizing queueing and the execution of the work item. Looking at that part of code only, it's possible that it fails to queue the work item after a memory hotplug event even though the previous queueing already started execution and processed a couple notifiers.
And you can see why you don't want this type of tricky micro optimizations unless it's absolutely necessary and carefully considered. Cold paths get much less attention and testing. Adding micro optimizations to them is just a bad idea.
Thanks.
Signature · 1 line
tejun
Borislav Petkov
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 6 lines · Tejun Heo
If one looks at something happening in a path as cold as memory hotplug and thinks about optimizing a coupld memory accesses, the person's priorities need serious reconsideration. I think approaches like that are actively harmful. They lead to unnecessary (and thus difficult to comprehend) convolutions which don't really help anything while deteoriorating code base.
Maybe I'm not expressing myself clearly enough so let me try again: all I'm saying is, I don't like the idea of needlessly toggling interrupts and having a locked operation just to understand that there's work pending.
Basically, with the amount of bloat we're adding to the kernel, the couple of instructions we're adding here and there and think they won't harm us, tends to crop up with time until we're too damn slow to do anything.
Now, you're saying that optimizing cold paths is something that calls for serious reconsideration of a person's priorities, and I'm saying just don't do anything in code that's not necessary. Fullstop. If this is leading to convolutions, then the design is suboptimal and needs adjustment. If [delayed_]work_pending is being abused, then fix it or add a new primitive which only checks for pending work and doesn't unconditionally toggle interrupts.
Quoted 4 lines
I don't think we have cases where this actually matters but it could be that we can add
work_pending()tests toqueue_work_on(). I *think* that shouldn't break work scheduling semantics. Not completely sure tho. Need to think about it more.
Yes, something like that.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
Hello, Borislav.
Quoted 4 lines · Borislav Petkov
Basically, with the amount of bloat we're adding to the kernel, the couple of instructions we're adding here and there and think they won't harm us, tends to crop up with time until we're too damn slow to do anything.
Yeah, I think we need them for the operations to hold w/o outer synchronization. If you can think of ways to optimize them, please be my guest.
Quoted 3 lines
Now, you're saying that optimizing cold paths is something that calls for serious reconsideration of a person's priorities, and I'm saying just don't do anything in code that's not necessary. Fullstop. If this
Not doing anything that's not necessary is an extreme and not necessary what you want in cold paths. If doing something extra makes your code much simpler and more maintainable and the path is cold enough for the extra to not matter, then that's the right trade-off.
Quoted 4 lines
is leading to convolutions, then the design is suboptimal and needs adjustment. If [delayed_]work_pending is being abused, then fix it or add a new primitive which only checks for pending work and doesn't unconditionally toggle interrupts.
"only checks for pending work" in a way which is race-free and usable from any context is a tricky thing to do.
Quoted 6 lines
Quoted 4 lines
I don't think we have cases where this actually matters but it could be that we can add
work_pending()tests toqueue_work_on(). I *think* that shouldn't break work scheduling semantics. Not completely sure tho. Need to think about it more.Yes, something like that.
And that's broken. It seems trivial but it really isn't and trying to optimize things like that in cold paths is just a bad idea. Not enough people will pay attention to them and they will stay subtly broken for a very long time. So, having "not doing anything in code which isn't necessary in code" as priority in cold paths is likely to hurt you. A better one would be "doing straight-forward and simple thing with acceptable overhead".
Thanks.
Signature · 1 line
tejun
Borislav Petkov
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
Quoted 7 lines · Tejun Heo
And that's broken. It seems trivial but it really isn't and trying to optimize things like that in cold paths is just a bad idea. Not enough people will pay attention to them and they will stay subtly broken for a very long time. So, having "not doing anything in code which isn't necessary in code" as priority in cold paths is likely to hurt you. A better one would be "doing straight-forward and simple thing with acceptable overhead".
Ok, understood. I have only one question: how do you make sure schedule_work() is used only in cold paths?
Btw, there's __cancel_delayed_work() which is not used anywhere and it could be deleted AFAICT.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Borislav Petkov
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 3 lines · Tejun Heo
I was confused a bit there. We can't. Nothing guarantees that the queuer sees the cleared PENDING before the work item starts execution, and I think ipc memory hotplug could also be broken from that.
Stupid question: why not clear PENDING after execution is done? I'm looking at process_one_work() here.
Quoted 7 lines
It's highly unlikely to actually happen and there may be external locking which prevents the race from actually happening, but there's nothing synchronizing queueing and the execution of the work item. Looking at that part of code only, it's possible that it fails to queue the work item after a memory hotplug event even though the previous queueing already started execution and processed a couple notifiers.
Maybe failure to queue could be signalled with a proper return value from __queue_work()?
Btw, I'm afraid I don't understand the "memory hotplug event" aspect and how that can influence the queueing - all it does it is list_add_tail, basically.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 18/25] TMIO MMC: don't use [delayed_]work_pending()
In reply to Tejun HeoHi Tejun
Quoted 5 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from tmio mmc. Only compile tested.
Thanks for the patch. It looks good to me. What happens below is upon mmc card detection IRQs, of which there are typically several due to pin debouncing, a delayed work is scheduled to verify a possibly new card state (plugged in or removed). So, the code below checks, that after the first of those interrupts the work is already scheduled and doesn't schedule it again. IIUC, this is indeed unneeded, since queue_delayed_work_on() only has any effect if the work isn't queued yet. Ah, there's a nitpick - you can remove one pair of parenthesis;-) Otherwise, I guess, this is an
and Chris can take it (preferably, after the correction) via his queue. If you give me a bit more time I can also test this, but it really looks pretty obvious. Maybe Chris will prefer you to take this via your queue - that's up to you two to decide.
Thanks
Guennadi
Quoted 31 lines
Signed-off-by Tejun Heo <[email protected]>Cc Guennadi Liakhovetski <[email protected]>Cc Ian Molton <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
drivers/mmc/host/tmio_mmc_pio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mmc/host/tmio_mmc_pio.c +1
-2@@ -573,8 +573,7 @@ static bool __tmio_mmc_card_detect_irq(struct tmio_mmc_host *host,tmio_mmc_ack_mmc_irqs (host,TMIO_STAT_CARD_INSERT |TMIO_STAT_CARD_REMOVE );if ((((ireg &TMIO_STAT_CARD_REMOVE ) && mmc->card) || - ((ireg &TMIO_STAT_CARD_INSERT ) && !mmc->card)) && - !work_pending (&mmc->detect.work)) + ((ireg &TMIO_STAT_CARD_INSERT ) && !mmc->card)))mmc_detect_change (host->mmc,msecs_to_jiffies (100 ));return true; }Signature · 1 line
1.8.0.2
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Borislav PetkovHello, Borislav.
Quoted 2 lines · Borislav Petkov
Ok, understood. I have only one question: how do you make sure
schedule_work()is used only in cold paths?
Hot and cold are relative terms and unless someone is doing things like invoking queue_work() from high-frequency interrupt handler, the level of overhead from queue_work() isn't likely to matter. The best way to deal with such hot paths would differ depending on the specifics of each hot path - ie. bouncing to workqueue from IRQ handler would be better handled by threaded IRQ handlers.
At this point, especially given how all of work_pending() users are way too cold for any of this to matter, I don't think we need to worry about this.
Quoted 2 lines
Btw, there's
__cancel_delayed_work()which is not used anywhere and it could be deleted AFAICT.
Yeah, there are several interfaces which are being deprecated. They'll be gone in a few cycles.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Borislav PetkovHello,
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Tejun Heo
I was confused a bit there. We can't. Nothing guarantees that the queuer sees the cleared PENDING before the work item starts execution, and I think ipc memory hotplug could also be broken from that.
Stupid question: why not clear PENDING after execution is done? I'm looking at
process_one_work()here.
The behavior is primarily because we want to enable workqueue users to guarantee that a full work item execution happens at least once after certain event happens. ie. Let's say there's a work item which processes data generated by a device. If it's IRQ handler calls queue_work() after getting notified of new data segment by the device, it would want to guarantee that whole work item execution would happen afterwards. If you clear PENDING after execution, the event may overlap with the end of the previous execution and the new data won't be processed.
Quoted 10 lines
Quoted 7 lines
It's highly unlikely to actually happen and there may be external locking which prevents the race from actually happening, but there's nothing synchronizing queueing and the execution of the work item. Looking at that part of code only, it's possible that it fails to queue the work item after a memory hotplug event even though the previous queueing already started execution and processed a couple notifiers.
Maybe failure to queue could be signalled with a proper return value from
__queue_work()?
It already does that but it's not about the return value. You simply cannot know whether to proceed with queueing or not with test_bit() alone.
Quoted 3 lines
Btw, I'm afraid I don't understand the "memory hotplug event" aspect and how that can influence the queueing - all it does it is
list_add_tail, basically.
It doesn't have anything to do with memory hotplug event itself. It's a generic memory access ordering / synchronization issue. There just isn't anything preventing test_bit() from seeing PENDING bit from before clearing.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 10/25] kprobes: fix wait_for_kprobe_optimizer()
In reply to Tejun HeoQuoted 4 lines · Tejun Heo
wait_for_kprobe_optimizer()seems largely broken. It usesoptimizer_compwhich is never re-initialized, sowait_for_kprobe_optimizer()will never wait for anything oncekprobe_optimizer()finishes all pending jobs for the first time.
Thank you for fixing that!
I must misunderstand that the DECLARE_COMPLETION() macro.
Quoted 8 lines
Also, aside from completion,
delayed_work_pending()is %false oncekprobe_optimizer()starts execution andwait_for_kprobe_optimizer()won't wait for it.Reimplement it so that it flushes
optimizing_workuntil [un]optimizing_lists are empty. Note that this also makesoptimizing_workexecute immediately if someone's waiting for it, which is the nicer behavior.
I think your enhancement is reasonable and GOOD for me.
Thanks again!
Quoted 71 lines
Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Ananth N Mavinakayanahalli <[email protected]>Cc Anil S Keshavamurthy <[email protected]>Cc "David S. Miller" <[email protected]>Cc Masami Hiramatsu <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
kernel/kprobes.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)kernel/kprobes.c +15
-8@@ -471,7 +471,6 @@ static LIST_HEAD(unoptimizing_list);static void kprobe_optimizer (struct work_struct *work); static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer); -static DECLARE_COMPLETION (optimizer_comp);#define OPTIMIZE_DELAY 5/* @@ -552,8 +551,7 @@ static __kprobes void do_free_cleaned_kprobes(struct list_head *free_list)/* Start optimizer after OPTIMIZE_DELAY passed */ static __kprobes void kick_kprobe_optimizer (void ) { -if (!delayed_work_pending (&optimizing_work)) -schedule_delayed_work (&optimizing_work,OPTIMIZE_DELAY ); +schedule_delayed_work (&optimizing_work,OPTIMIZE_DELAY ); }/* Kprobe jump optimizer */ @@ -592,16 +590,25 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)/* Step 5: Kick optimizer again if needed */ if (!list_empty (&optimizing_list) || !list_empty (&unoptimizing_list))kick_kprobe_optimizer (); -else -/* Wake up all waiters */ -complete_all (&optimizer_comp); }/* Wait for completing optimization and unoptimization */ static __kprobes void wait_for_kprobe_optimizer (void ) { -if (delayed_work_pending (&optimizing_work)) -wait_for_completion (&optimizer_comp); +mutex_lock (&kprobe_mutex); + +while (!list_empty (&optimizing_list) || !list_empty (&unoptimizing_list)) { +mutex_unlock (&kprobe_mutex); + +/* this will also make optimizing_work execute immmediately */ +flush_delayed_work (&optimizing_work); +/* @optimizing_work might not have been queued yet, relax */ +cpu_relax (); + +mutex_lock (&kprobe_mutex); + } + +mutex_unlock (&kprobe_mutex); }/* Optimize kprobe if p is ready to be optimized */
Signature · 4 lines
Masami HIRAMATSU IT Management Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Borislav Petkov
maintainerRe: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 9 lines · Tejun Heo
The behavior is primarily because we want to enable workqueue users to guarantee that a full work item execution happens at least once after certain event happens. ie. Let's say there's a work item which processes data generated by a device. If it's IRQ handler calls
queue_work()after getting notified of new data segment by the device, it would want to guarantee that whole work item execution would happen afterwards. If you clear PENDING after execution, the event may overlap with the end of the previous execution and the new data won't be processed.
Oh, ok, I didn't realize we did some sort of a one-shot queueing - I thought users of wq are supposed to be polling PENDING and when it is cleared, they queue. But come to think of it, we can't be doing that in an IRQ handler.
[ … ]
Quoted 4 lines
It doesn't have anything to do with memory hotplug event itself. It's a generic memory access ordering / synchronization issue. There just isn't anything preventing
test_bit()from seeing PENDING bit from before clearing.
That's true. So is it that the whole PENDING bit testing was actually the wrong sync primitive to use in most cases and we actually really needed to disable interrupts around testing of that bit?
Which would make your patches actually bugfixes.
/me goes and rereads 0/25 announcement mail.
Yes, it sounds like [delayed_]work_pending() needs to go or at least needs a big fat comment over it explaining that it is a special, cheaper alternative to be used *only* in conjunction with other synchronization.
Ok, thanks Tejun, for taking the time and explaining it again to me.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 15/25] x86/mce: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 24 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from x86/mce. Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Tony Luck <[email protected]>Cc Borislav Petkov <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
arch/x86/kernel/cpu/mcheck/mce.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)arch/x86/kernel/cpu/mcheck/mce.c +0
-0
arch/x86/kernel/cpu/mcheck/mce.c static void mce_schedule_work(void) · line 517
Quoted 6 lines
arch/x86/kernel/cpu/mcheck/mce.c +1
-2@@ -514,8 +514,7 @@ static void mce_schedule_work(void) {if (!mce_ring_empty ()) {struct work_struct *work = &__get_cpu_var (mce_work); -if (!work_pending (work)) -schedule_work (work); +schedule_work (work);
Right, just a nit. You could remove the local variable and have the function simply be:
static void mce_schedule_work(void)
{
if (!mce_ring_empty())
schedule_work(&__get_cpu_var(mce_work));
}before you send it upstream.
Also, the workqueue stuff is used on Intel boxes to poke mcelog when there's an MCE to be reported to userspace so if Tony wants to give it a run...
I'm fine with this being routed through your tree:
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 25/25] ipc: don't use [delayed_]work_pending()
In reply to Borislav PetkovHello, Borislav.
Quoted 8 lines · Borislav Petkov
Quoted 4 lines
It doesn't have anything to do with memory hotplug event itself. It's a generic memory access ordering / synchronization issue. There just isn't anything preventing
test_bit()from seeing PENDING bit from before clearing.That's true. So is it that the whole PENDING bit testing was actually the wrong sync primitive to use in most cases and we actually really needed to disable interrupts around testing of that bit?
The IRQ disabling is for synchronization with other workqueue operations. Once PENDING is set, other workqueue operations may busy-wait for the work item to be put on the appropriate queue so that further operations can happen (e.g. flush / cancel). So, if you have to be atomic locally w.r.t. IRQs.
Memory ordering issue is the one which makes using test_bit() in itself inadequate for gating the queue operation. It could be all we need is throwing in a smp_mb() before test_bit() to guarantee that either clear PENDING is visible or all updates upto that point is visible to the coming work item execution. Not sure whether that would be worthwhile tho. The only case that may help is, I think, if an already pending work item is queued very frequently from multiple CPUs, which is unlikely and, if exists, indicates larger problems.
Quoted 1 line
Which would make your patches actually bugfixes.
Yes, why I'm talking about making [delayed_]work_pending() go away or at least make it very ugly to use.
Quoted 7 lines
/me goes and rereads 0/25 announcement mail.
Yes, it sounds like [delayed_]work_pending() needs to go or at least needs a big fat comment over it explaining that it is a special, cheaper alternative to be used *only* in conjunction with other synchronization.
Ok, thanks Tejun, for taking the time and explaining it again to me.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 11/25] pm: don't use [delayed_]work_pending()
In reply to Rafael J. WysockiHello, Rafael.
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Can you please say why they are buggy?
Usually one of the following two reasons.
* The user gets confused and fails to handle !PENDING && currently executing properly.
* work_pending() doesn't have any memory barrier and the caller assumes work_pending() is somehow properly synchronized by itself.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 16/25] PM / Domains: don't use [delayed_]work_pending()
In reply to Rafael J. WysockiHello, Rafael.
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Is the particular one you're removing from
domain.cbuggy?
It's a bit difficult to tell without understanding the code base but from quick glancing it looks like it could be. The queueing and actual excution don't grab the same lock, so there doesn't seem to be anything work_pending() returning %true for a work item which already started executing. Even if the bug is there, it's likely to be very difficult to trigger tho, so I wouldn't consider it an urgent fix.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 16/25] PM / Domains: don't use [delayed_]work_pending()
Quoted 8 lines · Tejun Heo
Hello, Rafael.
Quoted 5 lines · Rafael J. Wysocki
Quoted 3 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 8 lines
Quoted 1 line
Is the particular one you're removing from
domain.cbuggy?It's a bit difficult to tell without understanding the code base but from quick glancing it looks like it could be. The queueing and actual excution don't grab the same lock, so there doesn't seem to be anything
work_pending()returning %true for a work item which already started executing. Even if the bug is there, it's likely to be very difficult to trigger tho, so I wouldn't consider it an urgent fix.
OK, so I'd generally prefer changelogs like this:
"There's no need to test whether a (delayed) work item is pending before queueing, flushing or cancelling it, so remove work_pending() tests used in those cases."
If that's fine with you, I'll queue up [16/25] and [11/25] for v3.9 with the above as the changelog.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH 16/25] PM / Domains: don't use [delayed_]work_pending()
Hello,
Quoted 8 lines · Rafael J. Wysocki
OK, so I'd generally prefer changelogs like this:
"There's no need to test whether a (delayed) work item is pending before queueing, flushing or cancelling it, so remove
work_pending()tests used in those cases."If that's fine with you, I'll queue up [16/25] and [11/25] for v3.9 with the above as the changelog.
Sure thing. Please go ahead.
Thanks.
Signature · 1 line
tejun
Jingoo Han
Acked-byRe: [PATCH 23/25] video/exynos: don't use [delayed_]work_pending()
In reply to Kukjin KimOn Saturday, December 22, 2012 12:06 PM, Kukjin Kim wrote
Quoted 6 lines
Quoted 5 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 7 lines
Quoted 5 lines
Remove unnecessary pending tests from
exynos_dp_core. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Kukjin Kim <[email protected]>Acked-by Kukjin Kim <[email protected]>
I tested this patch with Exynos5250.
Also, taking it through the workqueue tree would be better.
Best regards,
Jingoo Han
Quoted 45 lines
Quoted 5 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Cc'ed Jingoo and Florian.
Now the exynos dp driver are being handled by Jingoo so let's waiting for his opinion to take this by himself or not.
- Kukjin Kim
Quoted 33 lines
Thanks.
drivers/video/exynos/exynos_dp_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/video/exynos/exynos_dp_core.c +1
-2@@ -1121,8 +1121,7 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev) disable_irq(dp->irq); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (pdev->dev.of_node) {drivers/video/exynos/exynos_dp_core.c +1
-3if (dp->phy_addr)@@ -1144,8 +1143,7 @@ static int exynos_dp_suspend(struct device *dev)struct exynos_dp_platdata *pdata = dev->platform_data;struct exynos_dp_device *dp =dev_get_drvdata (dev); -if (work_pending (&dp->hotplug_work)) -flush_work (&dp->hotplug_work); +flush_work (&dp->hotplug_work);if (dev->of_node) {if (dp->phy_addr) --1.8.0.2
Tejun Heo
AppliedRe: [PATCH 03/25] sja1000: don't use [delayed_]work_pending()
In reply to David MillerQuoted 17 lines · David Miller
From: Tejun Heo <[email protected]>
Date: Fri, 21 Dec 2012 17:56:53 -0800Quoted 6 lines
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from sja1000. Only compile tested.
Quoted 7 lines
Signed-off-by Tejun Heo <[email protected]>Cc Wolfgang Grandegger <[email protected]>Cc "David S. Miller" <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Quoted 1 line
I would suggest just taking it via the workqueue tree, thanks Tejun.
Applied to wq/for-3.9-cleanups w/ your Acked-by added.
Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 07/25] mwifiex: don't use [delayed_]work_pending()
In reply to Bing ZhaoQuoted 17 lines · Bing Zhao
Hi Tejun,
Thanks for the patch.
Quoted 7 lines
Drop
work_pending()test frommwifiex_sdio_card_reset(). Aswork_pending()becomes %false beforesdio_card_reset_worker()starts executing, it doesn't really protect anything.reset_hostmay change betweenmmc_remove_host()andmmc_add_host(). Makesdio_card_reset_worker()cache the targetmmc_hostso that it isn't affected bymwifiex_sdio_card_reset()racing with it.Quoted 5 lines
Only compile tested.
Quoted 7 lines
Acked-by Bing Zhao <[email protected]>Quoted 3 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.If you are taking other patches in this series through your tree, please take this one too.
Applied to wq/for-3.9-cleanups.
Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 08/25] thinkpad_acpi: don't use [delayed_]work_pending()
In reply to Henrique de Moraes HolschuhQuoted 13 lines · Henrique de Moraes Holschuh
Quoted 11 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
thinkpad_acpi. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Henrique de Moraes Holschuh <[email protected]>
Quoted 8 lines
Quoted 3 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.It will not clash with anything I know of, so feel free to route it through the workqueue tree.
Applied to wq/for-3.9-cleanups. Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 09/25] wl1251: don't use [delayed_]work_pending()
In reply to Luciano CoelhoQuoted 14 lines · Luciano Coelho
Quoted 13 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from wl1251. Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Luciano Coelho <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Quoted 8 lines
Quoted 1 line
Thanks.
It's probably easier if you take it via your tree. This driver doesn't get patches very often, so I doubt there will be any conflicts.
Thank you!
Acked-by Luciano Coelho <[email protected]>
Applied to wq/for-3.9-cleanups. Thanks.
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 14/25] rfkill: don't use [delayed_]work_pending()
In reply to Johannes BergQuoted 10 lines · Johannes Berg
Quoted 6 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from rfkill. Only compile tested.
Looks fine to me, feel free to route through your tree -- nobody changes rfkill much (famous last words...) :-)
Applied to wq/for-3.9-cleanups w/ your Acked-by added. Thanks.
Signature · 1 line
tejun
PATCH v2 15/25 x86/mce: don't use [delayed_]work_pending()
In reply to Borislav PetkovThere's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from x86/mce. Only compile tested.
v2: Local var work removed from mce_schedule_work() as suggested by
Borislav.
---
Applied to wq/for-3.9-cleanups. Thanks.
Thanks.
arch/x86/kernel/cpu/mcheck/mce.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +3 -11
@@ -512,11 +512,8 @@ int mce_available(struct cpuinfo_x86 *c)static void mce_schedule_work (void ) { -if (!mce_ring_empty ()) { -struct work_struct *work = &__get_cpu_var (mce_work); -if (!work_pending (work)) -schedule_work (work); - } +if (!mce_ring_empty ()) +schedule_work (&__get_cpu_var (mce_work)); } DEFINE_PER_CPU(struct irq_work, mce_irq_work);
@@ -1351,12 +1348,7 @@ int mce_notify_irq(void)/* wake processes polling /dev/mcelog */ wake_up_interruptible (&mce_chrdev_wait); -/* -* There is no risk of missing notifications because -* work_pending is always cleared before the function is -* executed. -*/ -if (mce_helper[0 ] && !work_pending (&mce_trigger_work)) +if (mce_helper[0 ])schedule_work (&mce_trigger_work);if (__ratelimit (&ratelimit))
Tejun Heo
AppliedRe: [PATCH 21/25] tty/max3100: don't use [delayed_]work_pending()
In reply to Greg Kroah-HartmanQuoted 14 lines · Greg Kroah-Hartman
Quoted 4 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Quoted 8 lines
Remove unnecessary pending tests from max3100. Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Jiri Slaby <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Quoted 3 lines
Please, feel free to take it through your tree:
Applied to wq/for-3.9-cleanups. Thanks.
Signature · 1 line
tejun
'Tejun Heo'
AppliedRe: [PATCH 23/25] video/exynos: don't use [delayed_]work_pending()
In reply to Jingoo HanQuoted 13 lines · Jingoo Han
On Saturday, December 22, 2012 12:06 PM, Kukjin Kim wrote
Quoted 12 lines
Quoted 10 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
exynos_dp_core. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Kukjin Kim <[email protected]>
Quoted 6 lines
Quoted 1 line
Acked-by Kukjin Kim <[email protected]>Acked-by Jingoo Han <[email protected]>I tested this patch with Exynos5250.
Also, taking it through the workqueue tree would be better.
Applied to wq/for-3.9-cleanups. Thanks!
Signature · 1 line
tejun
Re: [PATCH 12/25] bluetooth/l2cap: don't use [delayed_]work_pending()
In reply to Tejun HeoHi Tejun,
Quoted 82 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Reimplement
l2cap_set_timer()such that it usesmod_delayed_work()orschedule_delayed_work()depending on a new param @override and let the users specify whether to override or not instead of usingdelayed_work_pending().Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Marcel Holtmann <[email protected]>Cc Gustavo Padovan <[email protected]>Cc Johan Hedberg <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
include/net/bluetooth/l2cap.h | 24 ++++++++++++++++-------- net/bluetooth/l2cap_core.c | 7 +++---- 2 files changed, 19 insertions(+), 12 deletions(-)include/net/bluetooth/l2cap.h +16
-8@@ -718,17 +718,25 @@ static inline void l2cap_chan_unlock(struct l2cap_chan *chan) }static inline void l2cap_set_timer (struct l2cap_chan *chan, -struct delayed_work *work,long timeout) +struct delayed_work *work,long timeout, +bool override) { +bool was_pending; +BT_DBG ("chan %p state %s timeout %ld" , chan,state_to_string (chan->state), timeout); -/* If delayed work cancelled do not hold(chan) -since it is already done with previous set_timer */ -if (!cancel_delayed_work (work)) -l2cap_chan_hold (chan); +/* @work should hold a reference to @chan */ +l2cap_chan_hold (chan); + +if (override) + was_pending =mod_delayed_work (system_wq, work, timeout); +else + was_pending = !schedule_delayed_work (work, timeout); -schedule_delayed_work (work, timeout); +/* if @work was already pending, lose the extra ref */ +if (was_pending) +l2cap_chan_put (chan); } static inline bool l2cap_clear_timer(struct l2cap_chan *chan,@@ -745,12 +753,12 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan,return ret; } -#define __set_chan_timer (c, t) l2cap_set_timer(c, &c->chan_timer, (t)) +#define __set_chan_timer (c, t) l2cap_set_timer(c, &c->chan_timer, (t), true)#define __clear_chan_timer (c) l2cap_clear_timer(c, &c->chan_timer)#define __clear_retrans_timer (c) l2cap_clear_timer(c, &c->retrans_timer)#define __clear_monitor_timer (c) l2cap_clear_timer(c, &c->monitor_timer)#define __set_ack_timer (c) l2cap_set_timer(c, &chan->ack_timer, \ - msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO), true);#define __clear_ack_timer (c) l2cap_clear_timer(c, &c->ack_timer)static inline int __seq_offset (struct l2cap_chan *chan,__u16 seq1,__u16 seq2)net/bluetooth/l2cap_core.c +0
-0
net/bluetooth/l2cap_core.c static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err) · line 251
Quoted 9 lines
net/bluetooth/l2cap_core.c +2
-3@@ -246,10 +246,9 @@ static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err)static void __set_retrans_timer (struct l2cap_chan *chan) { -if (!delayed_work_pending (&chan->monitor_timer) && - chan->retrans_timeout) { +if (chan->retrans_timeout) {l2cap_set_timer (chan, &chan->retrans_timer, -msecs_to_jiffies (chan->retrans_timeout)); +msecs_to_jiffies (chan->retrans_timeout), false);
Did you notice we are talking about two different works here? delayed_work_pending() is checking the monitor_timer while l2cap_set_timer is setting the retrans_timer. We can't run one of them while the is running. This mean you can just get rid of the override flag and simplify this patch a lot.
Gustavo
Re: [PATCH 20/25] wimax/i2400m: fix i2400m->wake_tx_skb handling
In reply to Tejun HeoQuoted 13 lines · Tejun Heo
i2400m_net_wake_tx()sets ->wake_tx_skb with the given skb if ->wake_tx_ws is not pending; however,i2400m_wake_tx_work()could have just started execution and haven't fetched -><wake_tx_skb yet. The previous packet will be leaked.Update ->wake_tx_skb handling.
*
i2400m_net_wake_tx()now tests whether the previous ->wake_tx_skb has been consumed by ->wake_tx_ws instead of testingwork_pending().*
i2400m_net_wake_stop()is simplified similarly. It always puts ->wake_tx_skb if non-NULL.
Quoted 6 lines
* Spurious ->wake_tx_skb dereference outside critical section dropped from
i2400m_wake_tx_work().Only compile tested.
Signed-off-by Tejun Heo <[email protected]>
No regressions in a quick connection check to Clear and browsing a bunch of pages.
Dan
Quoted 73 lines
---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
drivers/net/wimax/i2400m/netdev.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)drivers/net/wimax/i2400m/netdev.c +17
-14@@ -156,7 +156,7 @@ void i2400m_wake_tx_work(struct work_struct *ws) struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);struct net_device *net_dev = i2400m->wimax_dev.net_dev;struct device *dev =i2400m_dev (i2400m); -struct sk_buff *skb = i2400m->wake_tx_skb; +struct sk_buff *skb;unsigned long flags;spin_lock_irqsave (&i2400m->tx_lock, flags);@@ -236,23 +236,26 @@ void i2400m_tx_prep_header(struct sk_buff *skb)void i2400m_net_wake_stop (struct i2400m *i2400m) {struct device *dev =i2400m_dev (i2400m); +struct sk_buff *wake_tx_skb; +unsigned long flags;d_fnstart (3 , dev,"(i2400m %p)\n" , i2400m); -/* See i2400m_hard_start_xmit(), references are taken there -* and here we release them if the work was still -* pending. Note we can't differentiate work not pending vs -* never scheduled, so the NULL check does that. */ -if (cancel_work_sync (&i2400m->wake_tx_ws) ==0 - && i2400m->wake_tx_skb !=NULL ) { -unsigned long flags; -struct sk_buff *wake_tx_skb; -spin_lock_irqsave (&i2400m->tx_lock, flags); - wake_tx_skb = i2400m->wake_tx_skb;/* compat help */ - i2400m->wake_tx_skb =NULL ;/* compat help */ -spin_unlock_irqrestore (&i2400m->tx_lock, flags); +/* +* See i2400m_hard_start_xmit(), references are taken there and +* here we release them if the packet was still pending. +*/ +cancel_work_sync (&i2400m->wake_tx_ws); + +spin_lock_irqsave (&i2400m->tx_lock, flags); + wake_tx_skb = i2400m->wake_tx_skb; + i2400m->wake_tx_skb =NULL ; +spin_unlock_irqrestore (&i2400m->tx_lock, flags); + +if (wake_tx_skb) {i2400m_put (i2400m);kfree_skb (wake_tx_skb); } +d_fnend (3 , dev,"(i2400m %p) = void\n" , i2400m); }@@ -288,7 +291,7 @@ int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,* and if pending, release those resources. */ result =0 ;spin_lock_irqsave (&i2400m->tx_lock, flags); -if (!work_pending (&i2400m->wake_tx_ws)) { +if (!i2400m->wake_tx_skb) {netif_stop_queue (net_dev);i2400m_get (i2400m); i2400m->wake_tx_skb =skb_get (skb);/* transfer ref count */
Re: [PATCH 01/25] charger_manager: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 14 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests and rewrite
_setup_polling()so that it usesmod_delayed_work()if the next polling interval is sooner than currently scheduled.queue_delayed_work()is used otherwise.Only compile tested. I noticed that two work items -
setup_pollingandcm_monitor_work- schedule each other. It's a very unusual construct and I'm fairly sure it's racy. You can't break such circular dependency by calling cancel on each. I strongly recommend revising the mechanism.
Quoted 8 lines
Signed-off-by Tejun Heo <[email protected]>Cc Anton Vorontsov <[email protected]>Cc David Woodhouse <[email protected]>Cc Donggeun Kim <[email protected]>Cc MyungJoo Ham <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Charger manager is a fast moving target, so it is prone to conflict; it is better if I take it via battery-2.6.git tree. It is merged, thanks a lot!
Anton
Arun MURTHY
Acked-byRE: [PATCH 02/25] ab8500_charger: don't use [delayed_]work_pending()
In reply to a message not in the archiveQuoted 10 lines
Quoted 10 lines
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
ab8500_charger. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Srinidhi Kasagar <[email protected]>Cc Linus Walleij <[email protected]>
Thanks and Regards,
Arun R Murthy
------------------
Re: [PATCH 22/25] usb/at91_udc: don't use [delayed_]work_pending()
In reply to Tejun HeoOn 12/22/2012 02:57 AM, Tejun Heo :
Quoted 9 lines
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
at91_udc. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Andrew Victor <[email protected]>Cc Nicolas Ferre <[email protected]>
Quoted 27 lines
Cc Jean-Christophe Plagniol-Villard <[email protected]>Cc Felipe Balbi <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.Thanks.
drivers/usb/gadget/at91_udc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/usb/gadget/at91_udc.c +1
-2@@ -1621,8 +1621,7 @@ static void at91_vbus_timer(unsigned long data)* bus such as i2c or spi which may sleep, so schedule some work * to read the vbus gpio */ -if (!work_pending (&udc->vbus_timer_work)) -schedule_work (&udc->vbus_timer_work); +schedule_work (&udc->vbus_timer_work); } static int at91_start(struct usb_gadget *gadget,
Signature · 1 line
Nicolas Ferre
Re: [PATCH 02/25] ab8500_charger: don't use [delayed_]work_pending()
In reply to Tejun HeoQuoted 10 lines · Tejun Heo
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy.
Remove unnecessary pending tests from
ab8500_charger. Only compile tested.Signed-off-by Tejun Heo <[email protected]>Cc Srinidhi Kasagar <[email protected]>Cc Linus Walleij <[email protected]>
Works like a charm for us, thanks!
Yours,
Linus Walleij
Re: [PATCH 04/25] ipw2x00: simplify scan_event handling
In reply to Tejun HeoHello, Tejun,
Quoted 8 lines · Tejun Heo
* Drop unnesssary
delayd_work_pending()tests.* Unify scan_event_{now|later} by using
mod_delayed_work()w/ 0 delay forscan_event_now.* Make ipw2200
scan_eventhandling match ipw2100 - usemod_delayed_work()w/ 0 delay for immediate scanning.
Quoted 8 lines
Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Stanislav Yakovlev <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Please, feel free to take it through your tree.
Thanks!
Stanislav.
Re: [PATCH 10/25] kprobes: fix wait_for_kprobe_optimizer()
In reply to Masami HiramatsuQuoted 18 lines · Masami Hiramatsu
Quoted 4 lines · Tejun Heo
wait_for_kprobe_optimizer()seems largely broken. It usesoptimizer_compwhich is never re-initialized, sowait_for_kprobe_optimizer()will never wait for anything oncekprobe_optimizer()finishes all pending jobs for the first time.Thank you for fixing that!
I must misunderstand that theDECLARE_COMPLETION()macro.Quoted 8 lines
Also, aside from completion,
delayed_work_pending()is %false oncekprobe_optimizer()starts execution andwait_for_kprobe_optimizer()won't wait for it.Reimplement it so that it flushes
optimizing_workuntil [un]optimizing_lists are empty. Note that this also makesoptimizing_workexecute immediately if someone's waiting for it, which is the nicer behavior.
Quoted 5 lines
I think your enhancement is reasonable and GOOD for me.
Thanks again!
Acked-by Masami Hiramatsu <[email protected]>
Can I take it through workqueue branch w/ other patches?
Thanks!
Signature · 1 line
tejun
Re: Re: [PATCH 10/25] kprobes: fix wait_for_kprobe_optimizer()
Quoted 19 lines · Tejun Heo
Quoted 18 lines · Masami Hiramatsu
Quoted 4 lines · Tejun Heo
wait_for_kprobe_optimizer()seems largely broken. It usesoptimizer_compwhich is never re-initialized, sowait_for_kprobe_optimizer()will never wait for anything oncekprobe_optimizer()finishes all pending jobs for the first time.Thank you for fixing that!
I must misunderstand that theDECLARE_COMPLETION()macro.Quoted 8 lines
Also, aside from completion,
delayed_work_pending()is %false oncekprobe_optimizer()starts execution andwait_for_kprobe_optimizer()won't wait for it.Reimplement it so that it flushes
optimizing_workuntil [un]optimizing_lists are empty. Note that this also makesoptimizing_workexecute immediately if someone's waiting for it, which is the nicer behavior.
Quoted 7 lines
Quoted 5 lines
I think your enhancement is reasonable and GOOD for me.
Thanks again!
Acked-by Masami Hiramatsu <[email protected]>Can I take it through workqueue branch w/ other patches?
Yes, of course. I think it is not a critical bug, so I can wait for other patches.
Thank you,
Signature · 4 lines
Masami HIRAMATSU IT Management Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Tejun Heo
AppliedRe: [PATCH 04/25] ipw2x00: simplify scan_event handling
In reply to Stanislav YakovlevQuoted 20 lines · Stanislav Yakovlev
Hello, Tejun,
Quoted 8 lines · Tejun Heo
* Drop unnesssary
delayd_work_pending()tests.* Unify scan_event_{now|later} by using
mod_delayed_work()w/ 0 delay forscan_event_now.* Make ipw2200
scan_eventhandling match ipw2100 - usemod_delayed_work()w/ 0 delay for immediate scanning.Quoted 8 lines
Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Cc Stanislav Yakovlev <[email protected]>---
Please let me know how this patch should be routed. I can take it through the workqueue tree if necessary.
Quoted 3 lines
Please, feel free to take it through your tree.
Queued to wq/for-3.9-cleanups. Thanks!
Signature · 1 line
tejun
Tejun Heo
AppliedRe: Re: [PATCH 10/25] kprobes: fix wait_for_kprobe_optimizer()
In reply to Masami HiramatsuQuoted 6 lines · Masami Hiramatsu
Quoted 3 lines
Quoted 1 line
Acked-by Masami Hiramatsu <[email protected]>Can I take it through workqueue branch w/ other patches?
Yes, of course. I think it is not a critical bug, so I can wait for other patches.
Applied to wq/for-3.9-cleanups.
Thanks!
Signature · 1 line
tejun
Tejun Heo
AppliedRe: [PATCH 20/25] wimax/i2400m: fix i2400m->wake_tx_skb handling
In reply to Dan WilliamsQuoted 17 lines · Dan Williams
Quoted 16 lines · Tejun Heo
i2400m_net_wake_tx()sets ->wake_tx_skb with the given skb if ->wake_tx_ws is not pending; however,i2400m_wake_tx_work()could have just started execution and haven't fetched -><wake_tx_skb yet. The previous packet will be leaked.Update ->wake_tx_skb handling.
*
i2400m_net_wake_tx()now tests whether the previous ->wake_tx_skb has been consumed by ->wake_tx_ws instead of testingwork_pending().*
i2400m_net_wake_stop()is simplified similarly. It always puts ->wake_tx_skb if non-NULL.* Spurious ->wake_tx_skb dereference outside critical section dropped from
i2400m_wake_tx_work().
Quoted 8 lines
Quoted 3 lines
Only compile tested.
Signed-off-by Tejun Heo <[email protected]>Acked-by Dan Williams <[email protected]>No regressions in a quick connection check to Clear and browsing a bunch of pages.
Applied to wq/for-3.9-cleanups.
Thanks!
Signature · 1 line
tejun
Dmitry Torokhov
maintainerRe: [PATCH 17/25] wm97xx: don't use [delayed_]work_pending()
In reply to Mark BrownQuoted 11 lines · Mark Brown
Quoted 3 lines · Dmitry Torokhov
This is not 100% equivalent transformation as now we schedule first and disable IRQ later... Anyway, I think the driver shoudl be converted to threaded IRQ instead. Mark, does the patch below make any sense to you?
I'm a bit nervous about the fact that currently both the pen down IRQ and the coordinate read are pushed through a single workqueue so are serialised but after your patch they'll be split into the IRQ thread and the workqueue. It *should* be fine but I'd have to sit there and study it to convince myself that it's safe.
Mark,
Did yo have a chance to review the patch?
Thanks!
Signature · 1 line
Dmitry
Re: [PATCH 17/25] wm97xx: don't use [delayed_]work_pending()
Quoted 8 lines · Dmitry Torokhov
Quoted 5 lines · Mark Brown
I'm a bit nervous about the fact that currently both the pen down IRQ and the coordinate read are pushed through a single workqueue so are serialised but after your patch they'll be split into the IRQ thread and the workqueue. It *should* be fine but I'd have to sit there and study it to convince myself that it's safe.
Quoted 5 lines
Mark,
Did yo have a chance to review the patch?
Thanks!
Sort of. I'd be much happier keeping them serialised, it's too much work on legacy code to convince myself otherwise.