{"push_id":667746650,"size":10,"distinct_size":10,"ref":"refs/heads/mr2","head":"2e0981d652e2fac50f4b1f3cd4e712933a2ede74","before":"e413724b070421853a47d7969ae68e7dd2181c1e","commits":[{"sha":"1654a8cb0be3a3a96db222df230354dec68999c2","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"msm: bam_dmux: Use power efficient workqueues for\"\n\nThis reverts commit 7245b95168d74b6fc1f85637d8ece9f05741a676.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/1654a8cb0be3a3a96db222df230354dec68999c2"},{"sha":"9cfa8b6c2ca441679f15e87ab11042fab3aeb679","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"ASoC: jack: Use power efficient workqueue\"\n\nThis reverts commit ea41a72c7cc6686ae8a0dea4930537ad8dd36ad9.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/9cfa8b6c2ca441679f15e87ab11042fab3aeb679"},{"sha":"a0ad4baadea01069a70342569bba3a3335ff01e4","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"regulator: core: Use the power efficient workqueue for delayed powerdown\"\n\nThis reverts commit 9a5917b91e474484a3893cea87b7fabd6176cefc.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/a0ad4baadea01069a70342569bba3a3335ff01e4"},{"sha":"2a444d9d565bfba5a66c130824455c6f9a613ea3","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"block: queue work on power efficient wq\"\n\nThis reverts commit 3d0e7576035967e99c59c8d91d3781e1036fd358.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/2a444d9d565bfba5a66c130824455c6f9a613ea3"},{"sha":"1ade7ba539e9cfe91c0697a54569a368038012f4","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"workqueue: Add system wide power_efficient workqueues\"\n\nThis reverts commit ee35704cb92b777d5ffa48c3f53d4183899446ed.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/1ade7ba539e9cfe91c0697a54569a368038012f4"},{"sha":"37645f6aad7c73429b0a8a72508ef6d595c9712d","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"Revert \"workqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues\"\n\nThis reverts commit 70deaa26c82730af94fb3cac1d5575b7c8b03733.","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/37645f6aad7c73429b0a8a72508ef6d595c9712d"},{"sha":"f509da00e0847b35b3b731b06be8fabc41de12c7","author":{"email":"42480b5f4d505650064e5081b85d867a03559887@gmail.com","name":"Francisco Franco"},"message":"mm: push readahead to 512kB.\n\nSigned-off-by: Francisco Franco <franciscofranco.1990@gmail.com>","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/f509da00e0847b35b3b731b06be8fabc41de12c7"},{"sha":"3581026130699611d576531f94d29284841431ba","author":{"email":"ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com","name":"Dan Carpenter"},"message":"workqueue: Backport from upstream\n\nworkqueue: change BUG_ON() to WARN_ON()\n\nThis BUG_ON() can be triggered if you call schedule_work() before\ncalling INIT_WORK().  It is a bug definitely, but it's nicer to just\nprint a stack trace and return.\n\nReported-by: Matt Renzelmann <mjr@cs.wisc.edu>\nSigned-off-by: Dan Carpenter <dan.carpenter@oracle.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: Catch more locking problems with flush_work()\n\nIf a workqueue is flushed with flush_work() lockdep checking can\nbe circumvented. For example:\n\n static DEFINE_MUTEX(mutex);\n\n static void my_work(struct work_struct *w)\n {\n         mutex_lock(&mutex);\n         mutex_unlock(&mutex);\n }\n\n static DECLARE_WORK(work, my_work);\n\n static int __init start_test_module(void)\n {\n         schedule_work(&work);\n         return 0;\n }\n module_init(start_test_module);\n\n static void __exit stop_test_module(void)\n {\n         mutex_lock(&mutex);\n         flush_work(&work);\n         mutex_unlock(&mutex);\n }\n module_exit(stop_test_module);\n\nwould not always print a warning when flush_work() was called.\nIn this trivial example nothing could go wrong since we are\nguaranteed module_init() and module_exit() don't run concurrently,\nbut if the work item is schedule asynchronously we could have a\nscenario where the work item is running just at the time flush_work()\nis called resulting in a classic ABBA locking problem.\n\nAdd a lockdep hint by acquiring and releasing the work item\nlockdep_map in flush_work() so that we always catch this\npotential deadlock scenario.\n\nSigned-off-by: Stephen Boyd <sboyd@codeaurora.org>\nReviewed-by: Yong Zhang <yong.zhang0@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nlockdep: fix oops in processing workqueue\n\nUnder memory load, on x86_64, with lockdep enabled, the workqueue's\nprocess_one_work() has been seen to oops in __lock_acquire(), barfing\non a 0xffffffff00000000 pointer in the lockdep_map's class_cache[].\n\nBecause it's permissible to free a work_struct from its callout function,\nthe map used is an onstack copy of the map given in the work_struct: and\nthat copy is made without any locking.\n\nSurprisingly, gcc (4.5.1 in Hugh's case) uses \"rep movsl\" rather than\n\"rep movsq\" for that structure copy: which might race with a workqueue\nuser's wait_on_work() doing lock_map_acquire() on the source of the\ncopy, putting a pointer into the class_cache[], but only in time for\nthe top half of that pointer to be copied to the destination map.\n\nBoom when process_one_work() subsequently does lock_map_acquire()\non its onstack copy of the lockdep_map.\n\nFix this, and a similar instance in call_timer_fn(), with a\nlockdep_copy_map() function which additionally NULLs the class_cache[].\n\nNote: this oops was actually seen on 3.4-next, where flush_work() newly\ndoes the racing lock_map_acquire(); but Tejun points out that 3.4 and\nearlier are already vulnerable to the same through wait_on_work().\n\n* Patch orginally from Peter.  Hugh modified it a bit and wrote the\n  description.\n\nSigned-off-by: Peter Zijlstra <peterz@infradead.org>\nReported-by: Hugh Dickins <hughd@google.com>\nLKML-Reference: <alpine.LSU.2.00.1205070951170.1544@eggly.anvils>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: perform cpu down operations from low priority cpu_notifier()\n\nCurrently, all workqueue cpu hotplug operations run off\nCPU_PRI_WORKQUEUE which is higher than normal notifiers.  This is to\nensure that workqueue is up and running while bringing up a CPU before\nother notifiers try to use workqueue on the CPU.\n\nPer-cpu workqueues are supposed to remain working and bound to the CPU\nfor normal CPU_DOWN_PREPARE notifiers.  This holds mostly true even\nwith workqueue offlining running with higher priority because\nworkqueue CPU_DOWN_PREPARE only creates a bound trustee thread which\nruns the per-cpu workqueue without concurrency management without\nexplicitly detaching the existing workers.\n\nHowever, if the trustee needs to create new workers, it creates\nunbound workers which may wander off to other CPUs while\nCPU_DOWN_PREPARE notifiers are in progress.  Furthermore, if the CPU\ndown is cancelled, the per-CPU workqueue may end up with workers which\naren't bound to the CPU.\n\nWhile reliably reproducible with a convoluted artificial test-case\ninvolving scheduling and flushing CPU burning work items from CPU down\nnotifiers, this isn't very likely to happen in the wild, and, even\nwhen it happens, the effects are likely to be hidden by the following\nsuccessful CPU down.\n\nFix it by using different priorities for up and down notifiers - high\npriority for up operations and low priority for down operations.\n\nWorkqueue cpu hotplug operations will soon go through further cleanup.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: stable@vger.kernel.org\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: drop CPU_DYING notifier operation\n\nWorkqueue used CPU_DYING notification to mark GCWQ_DISASSOCIATED.\nThis was necessary because workqueue's CPU_DOWN_PREPARE happened\nbefore other DOWN_PREPARE notifiers and workqueue needed to stay\nassociated across the rest of DOWN_PREPARE.\n\nAfter the previous patch, workqueue's DOWN_PREPARE happens after\nothers and can set GCWQ_DISASSOCIATED directly.  Drop CPU_DYING and\nlet the trustee set GCWQ_DISASSOCIATED after disabling concurrency\nmanagement.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: ROGUE workers are UNBOUND workers\n\nCurrently, WORKER_UNBOUND is used to mark workers for the unbound\nglobal_cwq and WORKER_ROGUE is used to mark workers for disassociated\nper-cpu global_cwqs.  Both are used to make the marked worker skip\nconcurrency management and the only place they make any difference is\nin worker_enter_idle() where WORKER_ROGUE is used to skip scheduling\nidle timer, which can easily be replaced with trustee state testing.\n\nThis patch replaces WORKER_ROGUE with WORKER_UNBOUND and drops\nWORKER_ROGUE.  This is to prepare for removing trustee and handling\ndisassociated global_cwqs as unbound.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: use mutex for global_cwq manager exclusion\n\nPOOL_MANAGING_WORKERS is used to ensure that at most one worker takes\nthe manager role at any given time on a given global_cwq.  Trustee\nlater hitched on it to assume manager adding blocking wait for the\nbit.  As trustee already needed a custom wait mechanism, waiting for\nMANAGING_WORKERS was rolled into the same mechanism.\n\nTrustee is scheduled to be removed.  This patch separates out\nMANAGING_WORKERS wait into per-pool mutex.  Workers use\nmutex_trylock() to test for manager role and trustee uses mutex_lock()\nto claim manager roles.\n\ngcwq_claim/release_management() helpers are added to grab and release\nmanager roles of all pools on a global_cwq.  gcwq_claim_management()\nalways grabs pool manager mutexes in ascending pool index order and\nuses pool index as lockdep subclass.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: drop @bind from create_worker()\n\nCurrently, create_worker()'s callers are responsible for deciding\nwhether the newly created worker should be bound to the associated CPU\nand create_worker() sets WORKER_UNBOUND only for the workers for the\nunbound global_cwq.  Creation during normal operation is always via\nmaybe_create_worker() and @bind is true.  For workers created during\nhotplug, @bind is false.\n\nNormal operation path is planned to be used even while the CPU is\ngoing through hotplug operations or offline and this static decision\nwon't work.\n\nDrop @bind from create_worker() and decide whether to bind by looking\nat GCWQ_DISASSOCIATED.  create_worker() will also set WORKER_UNBOUND\nautmatically if disassociated.  To avoid flipping GCWQ_DISASSOCIATED\nwhile create_worker() is in progress, the flag is now allowed to be\nchanged only while holding all manager_mutexes on the global_cwq.\n\nThis requires that GCWQ_DISASSOCIATED is not cleared behind trustee's\nback.  CPU_ONLINE no longer clears DISASSOCIATED before flushing\ntrustee, which clears DISASSOCIATED before rebinding remaining workers\nif asked to release.  For cases where trustee isn't around, CPU_ONLINE\nclears DISASSOCIATED after flushing trustee.  Also, now, first_idle\nhas UNBOUND set on creation which is explicitly cleared by CPU_ONLINE\nwhile binding it.  These convolutions will soon be removed by further\nsimplification of CPU hotplug path.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: reimplement CPU online rebinding to handle idle workers\n\nCurrently, if there are left workers when a CPU is being brough back\nonline, the trustee kills all idle workers and scheduled rebind_work\nso that they re-bind to the CPU after the currently executing work is\nfinished.  This works for busy workers because concurrency management\ndoesn't try to wake up them from scheduler callbacks, which require\nthe target task to be on the local run queue.  The busy worker bumps\nconcurrency counter appropriately as it clears WORKER_UNBOUND from the\nrebind work item and it's bound to the CPU before returning to the\nidle state.\n\nTo reduce CPU on/offlining overhead (as many embedded systems use it\nfor powersaving) and simplify the code path, workqueue is planned to\nbe modified to retain idle workers across CPU on/offlining.  This\npatch reimplements CPU online rebinding such that it can also handle\nidle workers.\n\nAs noted earlier, due to the local wakeup requirement, rebinding idle\nworkers is tricky.  All idle workers must be re-bound before scheduler\ncallbacks are enabled.  This is achieved by interlocking idle\nre-binding.  Idle workers are requested to re-bind and then hold until\nall idle re-binding is complete so that no bound worker starts\nexecuting work item.  Only after all idle workers are re-bound and\nparked, CPU_ONLINE proceeds to release them and queue rebind work item\nto busy workers thus guaranteeing scheduler callbacks aren't invoked\nuntil all idle workers are ready.\n\nworker_rebind_fn() is renamed to busy_worker_rebind_fn() and\nidle_worker_rebind() for idle workers is added.  Rebinding logic is\nmoved to rebind_workers() and now called from CPU_ONLINE after\nflushing trustee.  While at it, add CPU sanity check in\nworker_thread().\n\nNote that now a worker may become idle or the manager between trustee\nrelease and rebinding during CPU_ONLINE.  As the previous patch\nupdated create_worker() so that it can be used by regular manager\nwhile unbound and this patch implements idle re-binding, this is safe.\n\nThis prepares for removal of trustee and keeping idle workers across\nCPU hotplugs.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: don't butcher idle workers on an offline CPU\n\nCurrently, during CPU offlining, after all pending work items are\ndrained, the trustee butchers all workers.  Also, on CPU onlining\nfailure, workqueue_cpu_callback() ensures that the first idle worker\nis destroyed.  Combined, these guarantee that an offline CPU doesn't\nhave any worker for it once all the lingering work items are finished.\n\nThis guarantee isn't really necessary and makes CPU on/offlining more\nexpensive than needs to be, especially for platforms which use CPU\nhotplug for powersaving.\n\nThis patch lets offline CPUs removes idle worker butchering from the\ntrustee and let a CPU which failed onlining keep the created first\nworker.  The first worker is created if the CPU doesn't have any\nduring CPU_DOWN_PREPARE and started right away.  If onlining succeeds,\nthe rebind_workers() call in CPU_ONLINE will rebind it like any other\nworkers.  If onlining fails, the worker is left alone till the next\ntry.\n\nThis makes CPU hotplugs cheaper by allowing global_cwqs to keep\nworkers across them and simplifies code.\n\nNote that trustee doesn't re-arm idle timer when it's done and thus\nthe disassociated global_cwq will keep all workers until it comes back\nonline.  This will be improved by further patches.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: remove CPU offline trustee\n\nWith the previous changes, a disassociated global_cwq now can run as\nan unbound one on its own - it can create workers as necessary to\ndrain remaining works after the CPU has been brought down and manage\nthe number of workers using the usual idle timer mechanism making\ntrustee completely redundant except for the actual unbinding\noperation.\n\nThis patch removes the trustee and let a disassociated global_cwq\nmanage itself.  Unbinding is moved to a work item (for CPU affinity)\nwhich is scheduled and flushed from CPU_DONW_PREPARE.\n\nThis patch moves nr_running clearing outside gcwq and manager locks to\nsimplify the code.  As nr_running is unused at the point, this is\nsafe.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: simplify CPU hotplug code\n\nWith trustee gone, CPU hotplug code can be simplified.\n\n* gcwq_claim/release_management() now grab and release gcwq lock too\n  respectively and gained _and_lock and _and_unlock postfixes.\n\n* All CPU hotplug logic was implemented in workqueue_cpu_callback()\n  which was called by workqueue_cpu_up/down_callback() for the correct\n  priority.  This was because up and down paths shared a lot of logic,\n  which is no longer true.  Remove workqueue_cpu_callback() and move\n  all hotplug logic into the two actual callbacks.\n\nThis patch doesn't make any functional changes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: \"Rafael J. Wysocki\" <rjw@sisk.pl>\n\nworkqueue: fix spurious CPU locality WARN from process_one_work()\n\n25511a4776 \"workqueue: reimplement CPU online rebinding to handle idle\nworkers\" added CPU locality sanity check in process_one_work().  It\ntriggers if a worker is executing on a different CPU without UNBOUND\nor REBIND set.\n\nThis works for all normal workers but rescuers can trigger this\nspuriously when they're serving the unbound or a disassociated\nglobal_cwq - rescuers don't have either flag set and thus its\ngcwq->cpu can be a different value including %WORK_CPU_UNBOUND.\n\nFix it by additionally testing %GCWQ_DISASSOCIATED.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReported-by: \"Paul E. McKenney\" <paulmck@linux.vnet.ibm.com>\nLKML-Refence: <20120721213656.GA7783@linux.vnet.ibm.com>\n\nworkqueue: reorder queueing functions so that _on() variants are on top\n\nCurrently, queue/schedule[_delayed]_work_on() are located below the\ncounterpart without the _on postifx even though the latter is usually\nimplemented using the former.  Swap them.\n\nThis is cleanup and doesn't cause any functional difference.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: make queueing functions return bool\n\nAll queueing functions return 1 on success, 0 if the work item was\nalready pending.  Update them to return bool instead.  This signifies\nbetter that they don't return 0 / -errno.\n\nThis is cleanup and doesn't cause any functional difference.\n\nWhile at it, fix comment opening for schedule_work_on().\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: add missing smp_wmb() in process_one_work()\n\nWORK_STRUCT_PENDING is used to claim ownership of a work item and\nprocess_one_work() releases it before starting execution.  When\nsomeone else grabs PENDING, all pre-release updates to the work item\nshould be visible and all updates made by the new owner should happen\nafterwards.\n\nGrabbing PENDING uses test_and_set_bit() and thus has a full barrier;\nhowever, clearing doesn't have a matching wmb.  Given the preceding\nspin_unlock and use of clear_bit, I don't believe this can be a\nproblem on an actual machine and there hasn't been any related report\nbut it still is theretically possible for clear_pending to permeate\nupwards and happen before work->entry update.\n\nAdd an explicit smp_wmb() before work_clear_pending().\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Oleg Nesterov <oleg@redhat.com>\nCc: stable@vger.kernel.org\n\nworkqueue: disable irq while manipulating PENDING\n\nQueueing operations use WORK_STRUCT_PENDING_BIT to synchronize access\nto the target work item.  They first try to claim the bit and proceed\nwith queueing only after that succeeds and there's a window between\nPENDING being set and the actual queueing where the task can be\ninterrupted or preempted.\n\nThere's also a similar window in process_one_work() when clearing\nPENDING.  A work item is dequeued, gcwq->lock is released and then\nPENDING is cleared and the worker might get interrupted or preempted\nbetween releasing gcwq->lock and clearing PENDING.\n\ncancel[_delayed]_work_sync() tries to claim or steal PENDING.  The\nfunction assumes that a work item with PENDING is either queued or in\nthe process of being [de]queued.  In the latter case, it busy-loops\nuntil either the work item loses PENDING or is queued.  If canceling\ncoincides with the above described interrupts or preemptions, the\ncanceling task will busy-loop while the queueing or executing task is\npreempted.\n\nThis patch keeps irq disabled across claiming PENDING and actual\nqueueing and moves PENDING clearing in process_one_work() inside\ngcwq->lock so that busy looping from PENDING && !queued doesn't wait\nfor interrupted/preempted tasks.  Note that, in process_one_work(),\nsetting last CPU and clearing PENDING got merged into single\noperation.\n\nThis removes possible long busy-loops and will allow using\ntry_to_grab_pending() from bh and irq contexts.\n\nv2: __queue_work() was testing preempt_count() to ensure that the\n    caller has disabled preemption.  This triggers spuriously if\n    !CONFIG_PREEMPT_COUNT.  Use preemptible() instead.  Reported by\n    Fengguang Wu.\n\nv3: Disable irq instead of preemption.  IRQ will be disabled while\n    grabbing gcwq->lock later anyway and this allows using\n    try_to_grab_pending() from bh and irq contexts.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Oleg Nesterov <oleg@redhat.com>\nCc: Fengguang Wu <fengguang.wu@intel.com>\n\nworkqueue: set delayed_work->timer function on initialization\n\ndelayed_work->timer.function is currently initialized during\nqueue_delayed_work_on().  Export delayed_work_timer_fn() and set\ndelayed_work timer function during delayed_work initialization\ntogether with other fields.\n\nThis ensures the timer function is always valid on an initialized\ndelayed_work.  This is to help mod_delayed_work() implementation.\n\nTo detect delayed_work users which diddle with the internal timer,\ntrigger WARN if timer function doesn't match on queue.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: unify local CPU queueing handling\n\nQueueing functions have been using different methods to determine the\nlocal CPU.\n\n* queue_work() superflously uses get/put_cpu() to acquire and hold the\n  local CPU across queue_work_on().\n\n* delayed_work_timer_fn() uses smp_processor_id().\n\n* queue_delayed_work() calls queue_delayed_work_on() with -1 @cpu\n  which is interpreted as the local CPU.\n\n* flush_delayed_work[_sync]() were using raw_smp_processor_id().\n\n* __queue_work() interprets %WORK_CPU_UNBOUND as local CPU if the\n  target workqueue is bound one but nobody uses this.\n\nThis patch converts all functions to uniformly use %WORK_CPU_UNBOUND\nto indicate local CPU and use the local binding feature of\n__queue_work().  unlikely() is dropped from %WORK_CPU_UNBOUND handling\nin __queue_work().\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: fix zero @delay handling of queue_delayed_work_on()\n\nIf @delay is zero and the dealyed_work is idle, queue_delayed_work()\nqueues it for immediate execution; however, queue_delayed_work_on()\nlacks this logic and always goes through timer regardless of @delay.\n\nThis patch moves 0 @delay handling logic from queue_delayed_work() to\nqueue_delayed_work_on() so that both functions behave the same.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: move try_to_grab_pending() upwards\n\ntry_to_grab_pending() will be used by to-be-implemented\nmod_delayed_work[_on]().  Move try_to_grab_pending() and related\nfunctions above queueing functions.\n\nThis patch only moves functions around.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: introduce WORK_OFFQ_FLAG_*\n\nLow WORK_STRUCT_FLAG_BITS bits of work_struct->data contain\nWORK_STRUCT_FLAG_* and flush color.  If the work item is queued, the\nrest point to the cpu_workqueue with WORK_STRUCT_CWQ set; otherwise,\nWORK_STRUCT_CWQ is clear and the bits contain the last CPU number -\neither a real CPU number or one of WORK_CPU_*.\n\nScheduled addition of mod_delayed_work[_on]() requires an additional\nflag, which is used only while a work item is off queue.  There are\nmore than enough bits to represent off-queue CPU number on both 32 and\n64bits.  This patch introduces WORK_OFFQ_FLAG_* which occupy the lower\npart of the @work->data high bits while off queue.  This patch doesn't\ndefine any actual OFFQ flag yet.\n\nOff-queue CPU number is now shifted by WORK_OFFQ_CPU_SHIFT, which adds\nthe number of bits used by OFFQ flags to WORK_STRUCT_FLAG_SHIFT, to\nmake room for OFFQ flags.\n\nTo avoid shift width warning with large WORK_OFFQ_FLAG_BITS, ulong\ncast is added to WORK_STRUCT_NO_CPU and, just in case, BUILD_BUG_ON()\nto check that there are enough bits to accomodate off-queue CPU number\nis added.\n\nThis patch doesn't make any functional difference.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: factor out __queue_delayed_work() from queue_delayed_work_on()\n\nThis is to prepare for mod_delayed_work[_on]() and doesn't cause any\nfunctional difference.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: reorganize try_to_grab_pending() and __cancel_timer_work()\n\n* Use bool @is_dwork instead of @timer and let try_to_grab_pending()\n  use to_delayed_work() to determine the delayed_work address.\n\n* Move timer handling from __cancel_work_timer() to\n  try_to_grab_pending().\n\n* Make try_to_grab_pending() use -EAGAIN instead of -1 for\n  busy-looping and drop the ret local variable.\n\n* Add proper function comment to try_to_grab_pending().\n\nThis makes the code a bit easier to understand and will ease further\nchanges.  This patch doesn't make any functional change.\n\nv2: Use @is_dwork instead of @timer.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: mark a work item being canceled as such\n\nThere can be two reasons try_to_grab_pending() can fail with -EAGAIN.\nOne is when someone else is queueing or deqeueing the work item.  With\nthe previous patches, it is guaranteed that PENDING and queued state\nwill soon agree making it safe to busy-retry in this case.\n\nThe other is if multiple __cancel_work_timer() invocations are racing\none another.  __cancel_work_timer() grabs PENDING and then waits for\nrunning instances of the target work item on all CPUs while holding\nPENDING and !queued.  try_to_grab_pending() invoked from another task\nwill keep returning -EAGAIN while the current owner is waiting.\n\nNot distinguishing the two cases is okay because __cancel_work_timer()\nis the only user of try_to_grab_pending() and it invokes\nwait_on_work() whenever grabbing fails.  For the first case, busy\nlooping should be fine but wait_on_work() doesn't cause any critical\nproblem.  For the latter case, the new contender usually waits for the\nsame condition as the current owner, so no unnecessarily extended\nbusy-looping happens.  Combined, these make __cancel_work_timer()\ntechnically correct even without irq protection while grabbing PENDING\nor distinguishing the two different cases.\n\nWhile the current code is technically correct, not distinguishing the\ntwo cases makes it difficult to use try_to_grab_pending() for other\npurposes than canceling because it's impossible to tell whether it's\nsafe to busy-retry grabbing.\n\nThis patch adds a mechanism to mark a work item being canceled.\ntry_to_grab_pending() now disables irq on success and returns -EAGAIN\nto indicate that grabbing failed but PENDING and queued states are\ngonna agree soon and it's safe to busy-loop.  It returns -ENOENT if\nthe work item is being canceled and it may stay PENDING && !queued for\narbitrary amount of time.\n\n__cancel_work_timer() is modified to mark the work canceling with\nWORK_OFFQ_CANCELING after grabbing PENDING, thus making\ntry_to_grab_pending() fail with -ENOENT instead of -EAGAIN.  Also, it\ninvokes wait_on_work() iff grabbing failed with -ENOENT.  This isn't\nnecessary for correctness but makes it consistent with other future\nusers of try_to_grab_pending().\n\nv2: try_to_grab_pending() was testing preempt_count() to ensure that\n    the caller has disabled preemption.  This triggers spuriously if\n    !CONFIG_PREEMPT_COUNT.  Use preemptible() instead.  Reported by\n    Fengguang Wu.\n\nv3: Updated so that try_to_grab_pending() disables irq on success\n    rather than requiring preemption disabled by the caller.  This\n    makes busy-looping easier and will allow try_to_grap_pending() to\n    be used from bh/irq contexts.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Fengguang Wu <fengguang.wu@intel.com>\n\nworkqueue: implement mod_delayed_work[_on]()\n\nWorkqueue was lacking a mechanism to modify the timeout of an already\npending delayed_work.  delayed_work users have been working around\nthis using several methods - using an explicit timer + work item,\nmessing directly with delayed_work->timer, and canceling before\nre-queueing, all of which are error-prone and/or ugly.\n\nThis patch implements mod_delayed_work[_on]() which behaves similarly\nto mod_timer() - if the delayed_work is idle, it's queued with the\ngiven delay; otherwise, its timeout is modified to the new value.\nZero @delay guarantees immediate execution.\n\nv2: Updated to reflect try_to_grab_pending() changes.  Now safe to be\n    called from bh context.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\nCc: Andrew Morton <akpm@linux-foundation.org>\nCc: Ingo Molnar <mingo@redhat.com>\n\nworkqueue: fix CPU binding of flush_delayed_work[_sync]()\n\ndelayed_work encodes the workqueue to use and the last CPU in\ndelayed_work->work.data while it's on timer.  The target CPU is\nimplicitly recorded as the CPU the timer is queued on and\ndelayed_work_timer_fn() queues delayed_work->work to the CPU it is\nrunning on.\n\nUnfortunately, this leaves flush_delayed_work[_sync]() no way to find\nout which CPU the delayed_work was queued for when they try to\nre-queue after killing the timer.  Currently, it chooses the local CPU\nflush is running on.  This can unexpectedly move a delayed_work queued\non a specific CPU to another CPU and lead to subtle errors.\n\nThere isn't much point in trying to save several bytes in struct\ndelayed_work, which is already close to a hundred bytes on 64bit with\nall debug options turned off.  This patch adds delayed_work->cpu to\nremember the CPU it's queued for.\n\nNote that if the timer is migrated during CPU down, the work item\ncould be queued to the downed global_cwq after this change.  As a\ndetached global_cwq behaves like an unbound one, this doesn't change\nmuch for the delayed_work.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\nCc: Ingo Molnar <mingo@redhat.com>\nCc: Andrew Morton <akpm@linux-foundation.org>\n\nworkqueue: add missing wmb() in clear_work_data()\n\nAny operation which clears PENDING should be preceded by a wmb to\nguarantee that the next PENDING owner sees all the changes made before\nPENDING release.\n\nThere are only two places where PENDING is cleared -\nset_work_cpu_and_clear_pending() and clear_work_data().  The caller of\nthe former already does smp_wmb() but the latter doesn't have any.\n\nMove the wmb above set_work_cpu_and_clear_pending() into it and add\none to clear_work_data().\n\nThere hasn't been any report related to this issue, and, given how\nclear_work_data() is used, it is extremely unlikely to have caused any\nactual problems on any architecture.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Oleg Nesterov <oleg@redhat.com>\n\nworkqueue: use enum value to set array size of pools in gcwq\n\nCommit 3270476a6c0ce322354df8679652f060d66526dc ('workqueue: reimplement\nWQ_HIGHPRI using a separate worker_pool') introduce separate worker_pool\nfor HIGHPRI. Although there is NR_WORKER_POOLS enum value which represent\nsize of pools, definition of worker_pool in gcwq doesn't use it.\nUsing it makes code robust and prevent future mistakes.\nSo change code to use this enum value.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: correct req_cpu in trace_workqueue_queue_work()\n\nWhen we do tracing workqueue_queue_work(), it records requested cpu.\nBut, if !(@wq->flag & WQ_UNBOUND) and @cpu is WORK_CPU_UNBOUND,\nrequested cpu is changed as local cpu.\nIn case of @wq->flag & WQ_UNBOUND, above change is not occured,\ntherefore it is reasonable to correct it.\n\nUse temporary local variable for storing requested cpu.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: change value of lcpu in __queue_delayed_work_on()\n\nWe assign cpu id into work struct's data field in __queue_delayed_work_on().\nIn current implementation, when work is come in first time,\ncurrent running cpu id is assigned.\nIf we do __queue_delayed_work_on() with CPU A on CPU B,\n__queue_work() invoked in delayed_work_timer_fn() go into\nthe following sub-optimal path in case of WQ_NON_REENTRANT.\n\n\tgcwq = get_gcwq(cpu);\n\tif (wq->flags & WQ_NON_REENTRANT &&\n\t\t(last_gcwq = get_work_gcwq(work)) && last_gcwq != gcwq) {\n\nChange lcpu to @cpu and rechange lcpu to local cpu if lcpu is WORK_CPU_UNBOUND.\nIt is sufficient to prevent to go into sub-optimal path.\n\ntj: Slightly rephrased the comment.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: introduce system_highpri_wq\n\nCommit 3270476a6c0ce322354df8679652f060d66526dc ('workqueue: reimplement\nWQ_HIGHPRI using a separate worker_pool') introduce separate worker pool\nfor HIGHPRI. When we handle busyworkers for gcwq, it can be normal worker\nor highpri worker. But, we don't consider this difference in rebind_workers(),\nwe use just system_wq for highpri worker. It makes mismatch between\ncwq->pool and worker->pool.\n\nIt doesn't make error in current implementation, but possible in the future.\nNow, we introduce system_highpri_wq to use proper cwq for highpri workers\nin rebind_workers(). Following patch fix this issue properly.\n\ntj: Even apart from rebinding, having system_highpri_wq generally\n    makes sense.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: use system_highpri_wq for highpri workers in rebind_workers()\n\nIn rebind_workers(), we do inserting a work to rebind to cpu for busy workers.\nCurrently, in this case, we use only system_wq. This makes a possible\nerror situation as there is mismatch between cwq->pool and worker->pool.\n\nTo prevent this, we should use system_highpri_wq for highpri worker\nto match theses. This implements it.\n\ntj: Rephrased comment a bit.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: use system_highpri_wq for unbind_work\n\nTo speed cpu down processing up, use system_highpri_wq.\nAs scheduling priority of workers on it is higher than system_wq and\nit is not contended by other normal works on this cpu, work on it\nis processed faster than system_wq.\n\ntj: CPU up/downs care quite a bit about latency these days.  This\n    shouldn't hurt anything and makes sense.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: fix checkpatch issues\n\nFixed some checkpatch warnings.\n\ntj: adapted to wq/for-3.7 and massaged pr_xxx() format strings a bit.\n\nSigned-off-by: Valentin Ilie <valentin.ilie@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nLKML-Reference: <1345326762-21747-1-git-send-email-valentin.ilie@gmail.com>\n\nworkqueue: make all workqueues non-reentrant\n\nBy default, each per-cpu part of a bound workqueue operates separately\nand a work item may be executing concurrently on different CPUs.  The\nbehavior avoids some cross-cpu traffic but leads to subtle weirdities\nand not-so-subtle contortions in the API.\n\n* There's no sane usefulness in allowing a single work item to be\n  executed concurrently on multiple CPUs.  People just get the\n  behavior unintentionally and get surprised after learning about it.\n  Most either explicitly synchronize or use non-reentrant/ordered\n  workqueue but this is error-prone.\n\n* flush_work() can't wait for multiple instances of the same work item\n  on different CPUs.  If a work item is executing on cpu0 and then\n  queued on cpu1, flush_work() can only wait for the one on cpu1.\n\n  Unfortunately, work items can easily cross CPU boundaries\n  unintentionally when the queueing thread gets migrated.  This means\n  that if multiple queuers compete, flush_work() can't even guarantee\n  that the instance queued right before it is finished before\n  returning.\n\n* flush_work_sync() was added to work around some of the deficiencies\n  of flush_work().  In addition to the usual flushing, it ensures that\n  all currently executing instances are finished before returning.\n  This operation is expensive as it has to walk all CPUs and at the\n  same time fails to address competing queuer case.\n\n  Incorrectly using flush_work() when flush_work_sync() is necessary\n  is an easy error to make and can lead to bugs which are difficult to\n  reproduce.\n\n* Similar problems exist for flush_delayed_work[_sync]().\n\nOther than the cross-cpu access concern, there's no benefit in\nallowing parallel execution and it's plain silly to have this level of\ncontortion for workqueue which is widely used from core code to\nextremely obscure drivers.\n\nThis patch makes all workqueues non-reentrant.  If a work item is\nexecuting on a different CPU when queueing is requested, it is always\nqueued to that CPU.  This guarantees that any given work item can be\nexecuting on one CPU at maximum and if a work item is queued and\nexecuting, both are on the same CPU.\n\nThe only behavior change which may affect workqueue users negatively\nis that non-reentrancy overrides the affinity specified by\nqueue_work_on().  On a reentrant workqueue, the affinity specified by\nqueue_work_on() is always followed.  Now, if the work item is\nexecuting on one of the CPUs, the work item will be queued there\nregardless of the requested affinity.  I've reviewed all workqueue\nusers which request explicit affinity, and, fortunately, none seems to\nbe crazy enough to exploit parallel execution of the same work item.\n\nThis adds an additional busy_hash lookup if the work item was\npreviously queued on a different CPU.  This shouldn't be noticeable\nunder any sane workload.  Work item queueing isn't a very\nhigh-frequency operation and they don't jump across CPUs all the time.\nIn a micro benchmark to exaggerate this difference - measuring the\ntime it takes for two work items to repeatedly jump between two CPUs a\nnumber (10M) of times with busy_hash table densely populated, the\ndifference was around 3%.\n\nWhile the overhead is measureable, it is only visible in pathological\ncases and the difference isn't huge.  This change brings much needed\nsanity to workqueue and makes its behavior consistent with timer.  I\nthink this is the right tradeoff to make.\n\nThis enables significant simplification of workqueue API.\nSimplification patches will follow.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: gut flush[_delayed]_work_sync()\n\nNow that all workqueues are non-reentrant, flush[_delayed]_work_sync()\nare equivalent to flush[_delayed]_work().  Drop the separate\nimplementation and make them thin wrappers around\nflush[_delayed]_work().\n\n* start_flush_work() no longer takes @wait_executing as the only left\n  user - flush_work() - always sets it to %true.\n\n* __cancel_work_timer() uses flush_work() instead of wait_on_work().\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: gut system_nrt[_freezable]_wq()\n\nNow that all workqueues are non-reentrant, system[_freezable]_wq() are\nequivalent to system_nrt[_freezable]_wq().  Replace the latter with\nwrappers around system[_freezable]_wq().  The wrapping goes through\ninline functions so that __deprecated can be added easily.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: cosmetic whitespace updates for macro definitions\n\nConsistently use the last tab position for '\\' line continuation in\ncomplex macro definitions.  This is to help the following patches.\n\nThis patch is cosmetic.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: use hotcpu_notifier() for workqueue_cpu_down_callback()\n\nworkqueue_cpu_down_callback() is used only if HOTPLUG_CPU=y, so\nhotcpu_notifier() fits better than cpu_notifier().\n\nWhen HOTPLUG_CPU=y, hotcpu_notifier() and cpu_notifier() are the same.\n\nWhen HOTPLUG_CPU=n, if we use cpu_notifier(),\nworkqueue_cpu_down_callback() will be called during boot to do\nnothing, and the memory of workqueue_cpu_down_callback() and\ngcwq_unbind_fn() will be discarded after boot.\n\nIf we use hotcpu_notifier(), we can avoid the no-op call of\nworkqueue_cpu_down_callback() and the memory of\nworkqueue_cpu_down_callback() and gcwq_unbind_fn() will be discard at\nbuild time:\n\n$ ls -l kernel/workqueue.o.cpu_notifier kernel/workqueue.o.hotcpu_notifier\n-rw-rw-r-- 1 laijs laijs 484080 Sep 15 11:31 kernel/workqueue.o.cpu_notifier\n-rw-rw-r-- 1 laijs laijs 478240 Sep 15 11:31 kernel/workqueue.o.hotcpu_notifier\n\n$ size kernel/workqueue.o.cpu_notifier kernel/workqueue.o.hotcpu_notifier\n   text\t   data\t    bss\t    dec\t    hex\tfilename\n  18513\t   2387\t   1221\t  22121\t   5669\tkernel/workqueue.o.cpu_notifier\n  18082\t   2355\t   1221\t  21658\t   549a\tkernel/workqueue.o.hotcpu_notifier\n\ntj: Updated description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: reimplement cancel_delayed_work() using try_to_grab_pending()\n\ncancel_delayed_work() can't be called from IRQ handlers due to its use\nof del_timer_sync() and can't cancel work items which are already\ntransferred from timer to worklist.\n\nAlso, unlike other flush and cancel functions, a canceled delayed_work\nwould still point to the last associated cpu_workqueue.  If the\nworkqueue is destroyed afterwards and the work item is re-used on a\ndifferent workqueue, the queueing code can oops trying to dereference\nalready freed cpu_workqueue.\n\nThis patch reimplements cancel_delayed_work() using\ntry_to_grab_pending() and set_work_cpu_and_clear_pending().  This\nallows the function to be called from IRQ handlers and makes its\nbehavior consistent with other flush / cancel functions.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\nCc: Ingo Molnar <mingo@redhat.com>\nCc: Andrew Morton <akpm@linux-foundation.org>\n\nworkqueue: UNBOUND -> REBIND morphing in rebind_workers() should be atomic\n\nThe compiler may compile the following code into TWO write/modify\ninstructions.\n\n\tworker->flags &= ~WORKER_UNBOUND;\n\tworker->flags |= WORKER_REBIND;\n\nso the other CPU may temporarily see worker->flags which doesn't have\neither WORKER_UNBOUND or WORKER_REBIND set and perform local wakeup\nprematurely.\n\nFix it by using single explicit assignment via ACCESS_ONCE().\n\nBecause idle workers have another WORKER_NOT_RUNNING flag, this bug\ndoesn't exist for them; however, update it to use the same pattern for\nconsistency.\n\ntj: Applied the change to idle workers too and updated comments and\n    patch description a bit.\n\nChange-Id: I9b95f51d146c40c31ba028668d6f412bd74c6026\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: stable@vger.kernel.org\n\nworkqueue: move WORKER_REBIND clearing in rebind_workers() to the end of the function\n\nThis doesn't make any functional difference and is purely to help the\nnext patch to be simpler.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: fix possible deadlock in idle worker rebinding\n\nCurrently, rebind_workers() and idle_worker_rebind() are two-way\ninterlocked.  rebind_workers() waits for idle workers to finish\nrebinding and rebound idle workers wait for rebind_workers() to finish\nrebinding busy workers before proceeding.\n\nUnfortunately, this isn't enough.  The second wait from idle workers\nis implemented as follows.\n\n\twait_event(gcwq->rebind_hold, !(worker->flags & WORKER_REBIND));\n\nrebind_workers() clears WORKER_REBIND, wakes up the idle workers and\nthen returns.  If CPU hotplug cycle happens again before one of the\nidle workers finishes the above wait_event(), rebind_workers() will\nrepeat the first part of the handshake - set WORKER_REBIND again and\nwait for the idle worker to finish rebinding - and this leads to\ndeadlock because the idle worker would be waiting for WORKER_REBIND to\nclear.\n\nThis is fixed by adding another interlocking step at the end -\nrebind_workers() now waits for all the idle workers to finish the\nabove WORKER_REBIND wait before returning.  This ensures that all\nrebinding steps are complete on all idle workers before the next\nhotplug cycle can happen.\n\nThis problem was diagnosed by Lai Jiangshan who also posted a patch to\nfix the issue, upon which this patch is based.\n\nThis is the minimal fix and further patches are scheduled for the next\nmerge window to simplify the CPU hotplug path.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nOriginal-patch-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nLKML-Reference: <1346516916-1991-3-git-send-email-laijs@cn.fujitsu.com>\n\nworkqueue: restore POOL_MANAGING_WORKERS\n\nThis patch restores POOL_MANAGING_WORKERS which was replaced by\npool->manager_mutex by 6037315269 \"workqueue: use mutex for global_cwq\nmanager exclusion\".\n\nThere's a subtle idle worker depletion bug across CPU hotplug events\nand we need to distinguish an actual manager and CPU hotplug\npreventing management.  POOL_MANAGING_WORKERS will be used for the\nformer and manager_mutex the later.\n\nThis patch just lays POOL_MANAGING_WORKERS on top of the existing\nmanager_mutex and doesn't introduce any synchronization changes.  The\nnext patch will update it.\n\nNote that this patch fixes a non-critical anomaly where\ntoo_many_workers() may return %true spuriously while CPU hotplug is in\nprogress.  While the issue could schedule idle timer spuriously, it\ndidn't trigger any actual misbehavior.\n\ntj: Rewrote patch description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: fix possible idle worker depletion across CPU hotplug\n\nTo simplify both normal and CPU hotplug paths, worker management is\nprevented while CPU hoplug is in progress.  This is achieved by CPU\nhotplug holding the same exclusion mechanism used by workers to ensure\nthere's only one manager per pool.\n\nIf someone else seems to be performing the manager role, workers\nproceed to execute work items.  CPU hotplug using the same mechanism\ncan lead to idle worker depletion because all workers could proceed to\nexecute work items while CPU hotplug is in progress and CPU hotplug\nitself wouldn't actually perform the worker management duty - it\ndoesn't guarantee that there's an idle worker left when it releases\nmanagement.\n\nThis idle worker depletion, under extreme circumstances, can break\nforward-progress guarantee and thus lead to deadlock.\n\nThis patch fixes the bug by using separate mechanisms for manager\nexclusion among workers and hotplug exclusion.  For manager exclusion,\nPOOL_MANAGING_WORKERS which was restored by the previous patch is\nused.  pool->manager_mutex is now only used for exclusion between the\nelected manager and CPU hotplug.  The elected manager won't proceed\nwithout holding pool->manager_mutex.\n\nThis ensures that the worker which won the manager position can't skip\nmanaging while CPU hotplug is in progress.  It will block on\nmanager_mutex and perform management after CPU hotplug is complete.\n\nNote that hotplug may happen while waiting for manager_mutex.  A\nmanager isn't either on idle or busy list and thus the hoplug code\ncan't unbind/rebind it.  Make the manager handle its own un/rebinding.\n\ntj: Updated comment and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: always clear WORKER_REBIND in busy_worker_rebind_fn()\n\nbusy_worker_rebind_fn() didn't clear WORKER_REBIND if rebinding failed\n(CPU is down again).  This used to be okay because the flag wasn't\nused for anything else.\n\nHowever, after 25511a477 \"workqueue: reimplement CPU online rebinding\nto handle idle workers\", WORKER_REBIND is also used to command idle\nworkers to rebind.  If not cleared, the worker may confuse the next\nCPU_UP cycle by having REBIND spuriously set or oops / get stuck by\nprematurely calling idle_worker_rebind().\n\n  WARNING: at /work/os/wq/kernel/workqueue.c:1323 worker_thread+0x4cd/0x5\n 00()\n  Hardware name: Bochs\n  Modules linked in: test_wq(O-)\n  Pid: 33, comm: kworker/1:1 Tainted: G           O 3.6.0-rc1-work+ #3\n  Call Trace:\n   [<ffffffff8109039f>] warn_slowpath_common+0x7f/0xc0\n   [<ffffffff810903fa>] warn_slowpath_null+0x1a/0x20\n   [<ffffffff810b3f1d>] worker_thread+0x4cd/0x500\n   [<ffffffff810bc16e>] kthread+0xbe/0xd0\n   [<ffffffff81bd2664>] kernel_thread_helper+0x4/0x10\n  ---[ end trace e977cf20f4661968 ]---\n  BUG: unable to handle kernel NULL pointer dereference at           (null)\n  IP: [<ffffffff810b3db0>] worker_thread+0x360/0x500\n  PGD 0\n  Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC\n  Modules linked in: test_wq(O-)\n  CPU 0\n  Pid: 33, comm: kworker/1:1 Tainted: G        W  O 3.6.0-rc1-work+ #3 Bochs Bochs\n  RIP: 0010:[<ffffffff810b3db0>]  [<ffffffff810b3db0>] worker_thread+0x360/0x500\n  RSP: 0018:ffff88001e1c9de0  EFLAGS: 00010086\n  RAX: 0000000000000000 RBX: ffff88001e633e00 RCX: 0000000000004140\n  RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009\n  RBP: ffff88001e1c9ea0 R08: 0000000000000000 R09: 0000000000000001\n  R10: 0000000000000002 R11: 0000000000000000 R12: ffff88001fc8d580\n  R13: ffff88001fc8d590 R14: ffff88001e633e20 R15: ffff88001e1c6900\n  FS:  0000000000000000(0000) GS:ffff88001fc00000(0000) knlGS:0000000000000000\n  CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b\n  CR2: 0000000000000000 CR3: 00000000130e8000 CR4: 00000000000006f0\n  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000\n  DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400\n  Process kworker/1:1 (pid: 33, threadinfo ffff88001e1c8000, task ffff88001e1c6900)\n  Stack:\n   ffff880000000000 ffff88001e1c9e40 0000000000000001 ffff88001e1c8010\n   ffff88001e519c78 ffff88001e1c9e58 ffff88001e1c6900 ffff88001e1c6900\n   ffff88001e1c6900 ffff88001e1c6900 ffff88001fc8d340 ffff88001fc8d340\n  Call Trace:\n   [<ffffffff810bc16e>] kthread+0xbe/0xd0\n   [<ffffffff81bd2664>] kernel_thread_helper+0x4/0x10\n  Code: b1 00 f6 43 48 02 0f 85 91 01 00 00 48 8b 43 38 48 89 df 48 8b 00 48 89 45 90 e8 ac f0 ff ff 3c 01 0f 85 60 01 00 00 48 8b 53 50 <8b> 02 83 e8 01 85 c0 89 02 0f 84 3b 01 00 00 48 8b 43 38 48 8b\n  RIP  [<ffffffff810b3db0>] worker_thread+0x360/0x500\n   RSP <ffff88001e1c9de0>\n  CR2: 0000000000000000\n\nThere was no reason to keep WORKER_REBIND on failure in the first\nplace - WORKER_UNBOUND is guaranteed to be set in such cases\npreventing incorrectly activating concurrency management.  Always\nclear WORKER_REBIND.\n\ntj: Updated comment and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: reimplement idle worker rebinding\n\nCurrently rebind_workers() uses rebinds idle workers synchronously\nbefore proceeding to requesting busy workers to rebind.  This is\nnecessary because all workers on @worker_pool->idle_list must be bound\nbefore concurrency management local wake-ups from the busy workers\ntake place.\n\nUnfortunately, the synchronous idle rebinding is quite complicated.\nThis patch reimplements idle rebinding to simplify the code path.\n\nRather than trying to make all idle workers bound before rebinding\nbusy workers, we simply remove all to-be-bound idle workers from the\nidle list and let them add themselves back after completing rebinding\n(successful or not).\n\nAs only workers which finished rebinding can on on the idle worker\nlist, the idle worker list is guaranteed to have only bound workers\nunless CPU went down again and local wake-ups are safe.\n\nAfter the change, @worker_pool->nr_idle may deviate than the actual\nnumber of idle workers on @worker_pool->idle_list.  More specifically,\nnr_idle may be non-zero while ->idle_list is empty.  All users of\n->nr_idle and ->idle_list are audited.  The only affected one is\ntoo_many_workers() which is updated to check %false if ->idle_list is\nempty regardless of ->nr_idle.\n\nAfter this patch, rebind_workers() no longer performs the nasty\nidle-rebind retries which require temporary release of gcwq->lock, and\nboth unbinding and rebinding are atomic w.r.t. global_cwq->lock.\n\nworker->idle_rebind and global_cwq->rebind_hold are now unnecessary\nand removed along with the definition of struct idle_rebind.\n\nChanged from V1:\n\t1) remove unlikely from too_many_workers(), ->idle_list can be empty\n\t   anytime, even before this patch, no reason to use unlikely.\n\t2) fix a small rebasing mistake.\n\t   (which is from rebasing the orignal fixing patch to for-next)\n\t3) add a lot of comments.\n\t4) clear WORKER_REBIND unconditionaly in idle_worker_rebind()\n\ntj: Updated comments and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: WORKER_REBIND is no longer necessary for busy rebinding\n\nBecause the old unbind/rebinding implementation wasn't atomic w.r.t.\nGCWQ_DISASSOCIATED manipulation which is protected by\nglobal_cwq->lock, we had to use two flags, WORKER_UNBOUND and\nWORKER_REBIND, to avoid incorrectly losing all NOT_RUNNING bits with\nback-to-back CPU hotplug operations; otherwise, completion of\nrebinding while another unbinding is in progress could clear UNBIND\nprematurely.\n\nNow that both unbind/rebinding are atomic w.r.t. GCWQ_DISASSOCIATED,\nthere's no need to use two flags.  Just one is enough.  Don't use\nWORKER_REBIND for busy rebinding.\n\ntj: Updated description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: WORKER_REBIND is no longer necessary for idle rebinding\n\nNow both worker destruction and idle rebinding remove the worker from\nidle list while it's still idle, so list_empty(&worker->entry) can be\nused to test whether either is pending and WORKER_DIE to distinguish\nbetween the two instead making WORKER_REBIND unnecessary.\n\nUse list_empty(&worker->entry) to determine whether destruction or\nrebinding is pending.  This simplifies worker state transitions.\n\nWORKER_REBIND is not needed anymore.  Remove it.\n\ntj: Updated comments and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: rename manager_mutex to assoc_mutex\n\nNow that manager_mutex's role has changed from synchronizing manager\nrole to excluding hotplug against manager, the name is misleading.\n\nAs it is protecting the CPU-association of the gcwq now, rename it to\nassoc_mutex.\n\nThis patch is pure rename and doesn't introduce any functional change.\n\ntj: Updated comments and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: use __cpuinit instead of __devinit for cpu callbacks\n\nFor workqueue hotplug callbacks, it makes less sense to use __devinit\nwhich discards the memory after boot if !HOTPLUG.  __cpuinit, which\ndiscards the memory after boot if !HOTPLUG_CPU fits better.\n\ntj: Updated description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: fix possible stall on try_to_grab_pending() of a delayed work item\n\nCurrently, when try_to_grab_pending() grabs a delayed work item, it\nleaves its linked work items alone on the delayed_works.  The linked\nwork items are always NO_COLOR and will cause future\ncwq_activate_first_delayed() increase cwq->nr_active incorrectly, and\nmay cause the whole cwq to stall.  For example,\n\nstate: cwq->max_active = 1, cwq->nr_active = 1\n       one work in cwq->pool, many in cwq->delayed_works.\n\nstep1: try_to_grab_pending() removes a work item from delayed_works\n       but leaves its NO_COLOR linked work items on it.\n\nstep2: Later on, cwq_activate_first_delayed() activates the linked\n       work item increasing ->nr_active.\n\nstep3: cwq->nr_active = 1, but all activated work items of the cwq are\n       NO_COLOR.  When they finish, cwq->nr_active will not be\n       decreased due to NO_COLOR, and no further work items will be\n       activated from cwq->delayed_works. the cwq stalls.\n\nFix it by ensuring the target work item is activated before stealing\nPENDING in try_to_grab_pending().  This ensures that all the linked\nwork items are activated without incorrectly bumping cwq->nr_active.\n\ntj: Updated comment and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: stable@kernel.org\n\nworkqueue: reimplement work_on_cpu() using system_wq\n\nThe existing work_on_cpu() implementation is hugely inefficient.  It\ncreates a new kthread, execute that single function and then let the\nkthread die on each invocation.\n\nNow that system_wq can handle concurrent executions, there's no\nadvantage of doing this.  Reimplement work_on_cpu() using system_wq\nwhich makes it simpler and way more efficient.\n\nstable: While this isn't a fix in itself, it's needed to fix a\n        workqueue related bug in cpufreq/powernow-k8.  AFAICS, this\n        shouldn't break other existing users.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nAcked-by: Jiri Kosina <jkosina@suse.cz>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\nCc: Bjorn Helgaas <bhelgaas@google.com>\nCc: Len Brown <lenb@kernel.org>\nCc: Rafael J. Wysocki <rjw@sisk.pl>\nCc: stable@vger.kernel.org\n\nworkqueue: introduce cwq_set_max_active() helper for thaw_workqueues()\n\nUsing a helper instead of open code makes thaw_workqueues() clearer.\nThe helper will also be used by the next patch.\n\ntj: Slight update to comment and description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: use cwq_set_max_active() helper for workqueue_set_max_active()\n\nworkqueue_set_max_active() may increase ->max_active without\nactivating delayed works and may make the activation order differ from\nthe queueing order.  Both aren't strictly bugs but the resulting\nbehavior could be a bit odd.\n\nTo make things more consistent, use cwq_set_max_active() helper which\nimmediately makes use of the newly increased max_mactive if there are\ndelayed work items and also keeps the activation order.\n\ntj: Slight update to description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: remove spurious WARN_ON_ONCE(in_irq()) from try_to_grab_pending()\n\ne0aecdd874 (\"workqueue: use irqsafe timer for delayed_work\") made\ntry_to_grab_pending() safe to use from irq context but forgot to\nremove WARN_ON_ONCE(in_irq()).  Remove it.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReported-by: Fengguang Wu <fengguang.wu@intel.com>\n\nworkqueue: cancel_delayed_work() should return %false if work item is idle\n\n57b30ae77b (\"workqueue: reimplement cancel_delayed_work() using\ntry_to_grab_pending()\") made cancel_delayed_work() always return %true\nunless someone else is also trying to cancel the work item, which is\nbroken - if the target work item is idle, the return value should be\n%false.\n\ntry_to_grab_pending() indicates that the target work item was idle by\nzero return value.  Use it for return.  Note that this brings\ncancel_delayed_work() in line with __cancel_work_timer() in return\nvalue handling.\n\nSigned-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nLKML-Reference: <444a6439-b1a4-4740-9e7e-bc37267cfe73@default>\n\nworkqueue: exit rescuer_thread() as TASK_RUNNING\n\nA rescue thread exiting TASK_INTERRUPTIBLE can lead to a task scheduling\noff, never to be seen again.  In the case where this occurred, an exiting\nthread hit reiserfs homebrew conditional resched while holding a mutex,\nbringing the box to its knees.\n\nPID: 18105  TASK: ffff8807fd412180  CPU: 5   COMMAND: \"kdmflush\"\n #0 [ffff8808157e7670] schedule at ffffffff8143f489\n #1 [ffff8808157e77b8] reiserfs_get_block at ffffffffa038ab2d [reiserfs]\n #2 [ffff8808157e79a8] __block_write_begin at ffffffff8117fb14\n #3 [ffff8808157e7a98] reiserfs_write_begin at ffffffffa0388695 [reiserfs]\n #4 [ffff8808157e7ad8] generic_perform_write at ffffffff810ee9e2\n #5 [ffff8808157e7b58] generic_file_buffered_write at ffffffff810eeb41\n #6 [ffff8808157e7ba8] __generic_file_aio_write at ffffffff810f1a3a\n #7 [ffff8808157e7c58] generic_file_aio_write at ffffffff810f1c88\n #8 [ffff8808157e7cc8] do_sync_write at ffffffff8114f850\n #9 [ffff8808157e7dd8] do_acct_process at ffffffff810a268f\n    [exception RIP: kernel_thread_helper]\n    RIP: ffffffff8144a5c0  RSP: ffff8808157e7f58  RFLAGS: 00000202\n    RAX: 0000000000000000  RBX: 0000000000000000  RCX: 0000000000000000\n    RDX: 0000000000000000  RSI: ffffffff8107af60  RDI: ffff8803ee491d18\n    RBP: 0000000000000000   R8: 0000000000000000   R9: 0000000000000000\n    R10: 0000000000000000  R11: 0000000000000000  R12: 0000000000000000\n    R13: 0000000000000000  R14: 0000000000000000  R15: 0000000000000000\n    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018\n\nSigned-off-by: Mike Galbraith <mgalbraith@suse.de>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: stable@vger.kernel.org\n\nworkqueue: mod_delayed_work_on() shouldn't queue timer on 0 delay\n\n8376fe22c7 (\"workqueue: implement mod_delayed_work[_on]()\")\nimplemented mod_delayed_work[_on]() using the improved\ntry_to_grab_pending().  The function is later used, among others, to\nreplace [__]candel_delayed_work() + queue_delayed_work() combinations.\n\nUnfortunately, a delayed_work item w/ zero @delay is handled slightly\ndifferently by mod_delayed_work_on() compared to\nqueue_delayed_work_on().  The latter skips timer altogether and\ndirectly queues it using queue_work_on() while the former schedules\ntimer which will expire on the closest tick.  This means, when @delay\nis zero, that [__]cancel_delayed_work() + queue_delayed_work_on()\nmakes the target item immediately executable while\nmod_delayed_work_on() may induce delay of upto a full tick.\n\nThis somewhat subtle difference breaks some of the converted users.\ne.g. block queue plugging uses delayed_work for deferred processing\nand uses mod_delayed_work_on() when the queue needs to be immediately\nunplugged.  The above problem manifested as noticeably higher number\nof context switches under certain circumstances.\n\nThe difference in behavior was caused by missing special case handling\nfor 0 delay in mod_delayed_work_on() compared to\nqueue_delayed_work_on().  Joonsoo Kim posted a patch to add it -\n(\"workqueue: optimize mod_delayed_work_on() when @delay == 0\")[1].\nThe patch was queued for 3.8 but it was described as optimization and\nI missed that it was a correctness issue.\n\nAs both queue_delayed_work_on() and mod_delayed_work_on() use\n__queue_delayed_work() for queueing, it seems that the better approach\nis to move the 0 delay special handling to the function instead of\nduplicating it in mod_delayed_work_on().\n\nFix the problem by moving 0 delay special case handling from\nqueue_delayed_work_on() to __queue_delayed_work().  This replaces\nJoonsoo's patch.\n\n[1] http://thread.gmane.org/gmane.linux.kernel/1379011/focus=1379012\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReported-and-tested-by: Anders Kaseorg <andersk@MIT.EDU>\nReported-and-tested-by: Zlatko Calusic <zlatko.calusic@iskon.hr>\nLKML-Reference: <alpine.DEB.2.00.1211280953350.26602@dr-wily.mit.edu>\nLKML-Reference: <50A78AA9.5040904@iskon.hr>\nCc: Joonsoo Kim <js1304@gmail.com>\n\nworkqueue: trivial fix for return statement in work_busy()\n\nReturn type of work_busy() is unsigned int.\nThere is return statement returning boolean value, 'false' in work_busy().\nIt is not problem, because 'false' may be treated '0'.\nHowever, fixing it would make code robust.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: add WARN_ON_ONCE() on CPU number to wq_worker_waking_up()\n\nRecently, workqueue code has gone through some changes and we found\nsome bugs related to concurrency management operations happening on\nthe wrong CPU.  When a worker is concurrency managed\n(!WORKER_NOT_RUNNIG), it should be bound to its associated cpu and\nwoken up to that cpu.  Add WARN_ON_ONCE() to verify this.\n\nSigned-off-by: Joonsoo Kim <js1304@gmail.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nworkqueue: convert BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s\n\n8852aac25e (\"workqueue: mod_delayed_work_on() shouldn't queue timer on\n0 delay\") unexpectedly uncovered a very nasty abuse of delayed_work in\nmegaraid - it allocated work_struct, casted it to delayed_work and\nthen pass that into queue_delayed_work().\n\nPreviously, this was okay because 0 @delay short-circuited to\nqueue_work() before doing anything with delayed_work.  8852aac25e\nmoved 0 @delay test into __queue_delayed_work() after sanity check on\ndelayed_work making megaraid trigger BUG_ON().\n\nAlthough megaraid is already fixed by c1d390d8e6 (\"megaraid: fix\nBUG_ON() from incorrect use of delayed work\"), this patch converts\nBUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s so that such\nabusers, if there are more, trigger warning but don't crash the\nmachine.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Xiaotian Feng <xtfeng@gmail.com>\n\nwq\n\nChange-Id: Ia3c507777a995f32bf6b40dc8318203e53134229\nSigned-off-by: franciscofranco <franciscofranco.1990@gmail.com>","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/3581026130699611d576531f94d29284841431ba"},{"sha":"013a7925b06d73a616b68391ad0def13427860a7","author":{"email":"546b05909706652891a87f7bfe385ae147f61f91@kernel.org","name":"Tejun Heo"},"message":"workqueue: fix hang involving racing cancel[_delayed]_work_sync()'s for PREEMPT_NONE\n\ncommit 8603e1b30027f943cc9c1eef2b291d42c3347af1 upstream.\n\ncancel[_delayed]_work_sync() are implemented using\n__cancel_work_timer() which grabs the PENDING bit using\ntry_to_grab_pending() and then flushes the work item with PENDING set\nto prevent the on-going execution of the work item from requeueing\nitself.\n\ntry_to_grab_pending() can always grab PENDING bit without blocking\nexcept when someone else is doing the above flushing during\ncancelation.  In that case, try_to_grab_pending() returns -ENOENT.  In\nthis case, __cancel_work_timer() currently invokes flush_work().  The\nassumption is that the completion of the work item is what the other\ncanceling task would be waiting for too and thus waiting for the same\ncondition and retrying should allow forward progress without excessive\nbusy looping\n\nUnfortunately, this doesn't work if preemption is disabled or the\nlatter task has real time priority.  Let's say task A just got woken\nup from flush_work() by the completion of the target work item.  If,\nbefore task A starts executing, task B gets scheduled and invokes\n__cancel_work_timer() on the same work item, its try_to_grab_pending()\nwill return -ENOENT as the work item is still being canceled by task A\nand flush_work() will also immediately return false as the work item\nis no longer executing.  This puts task B in a busy loop possibly\npreventing task A from executing and clearing the canceling state on\nthe work item leading to a hang.\n\ntask A\t\t\ttask B\t\t\tworker\n\n\t\t\t\t\t\texecuting work\n__cancel_work_timer()\n  try_to_grab_pending()\n  set work CANCELING\n  flush_work()\n    block for work completion\n\t\t\t\t\t\tcompletion, wakes up A\n\t\t\t__cancel_work_timer()\n\t\t\twhile (forever) {\n\t\t\t  try_to_grab_pending()\n\t\t\t    -ENOENT as work is being canceled\n\t\t\t  flush_work()\n\t\t\t    false as work is no longer executing\n\t\t\t}\n\nThis patch removes the possible hang by updating __cancel_work_timer()\nto explicitly wait for clearing of CANCELING rather than invoking\nflush_work() after try_to_grab_pending() fails with -ENOENT.\n\nLink: http://lkml.kernel.org/g/20150206171156.GA8942@axis.com\n\nv3: bit_waitqueue() can't be used for work items defined in vmalloc\n    area.  Switched to custom wake function which matches the target\n    work item and exclusive wait and wakeup.\n\nv2: v1 used wake_up() on bit_waitqueue() which leads to NULL deref if\n    the target bit waitqueue has wait_bit_queue's on it.  Use\n    DEFINE_WAIT_BIT() and __wake_up_bit() instead.  Reported by Tomeu\n    Vizoso.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReported-by: Rabin Vincent <rabin.vincent@axis.com>\nCc: Tomeu Vizoso <tomeu.vizoso@gmail.com>\nTested-by: Jesper Nilsson <jesper.nilsson@axis.com>\nTested-by: Rabin Vincent <rabin.vincent@axis.com>\nSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>\nSigned-off-by: franciscofranco <franciscofranco.1990@gmail.com>","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/013a7925b06d73a616b68391ad0def13427860a7"},{"sha":"2e0981d652e2fac50f4b1f3cd4e712933a2ede74","author":{"email":"9ad507151583dfb9c8407be7c1eefeaf5bf91965@gmail.com","name":"shivamk11"},"message":"phantom_defconfig: Disable unneeded stuff","distinct":true,"url":"https://api.github.com/repos/shivamk11/android_kernel_xiaomi_cancro/commits/2e0981d652e2fac50f4b1f3cd4e712933a2ede74"}]}