{"push_id":1467749898,"size":9,"distinct_size":9,"ref":"refs/heads/stable","head":"dbcd8e3757b985cdb658d795f187d22642d079c0","before":"f1ade79e45ec06666f6401e00b7afe9bcd58cbda","commits":[{"sha":"430e437008303b3340cc3b0dc3d824037f7c9d71","author":{"name":"Alex Saiko","email":"7beb632b26f8bed29fb02d734696091dae659aec@gmail.com"},"message":"kbuild: breakfast: Support standalone compilation\n\nChangelog:\n- Correct return_address() usage with ARM_UNWIND enabled,\n- Disable deprecated swp{b} API on current platform,\n- Squash all the compiler headers into compiler-gcc.h,\n- Update compiler API to the upstreamed version,\n- Remove GCC wrapper,\n- Add 'ccache' flag to main Makefile,\n- Add optimization flags to main Makefiles,\n- Restructure and upstream Makefiles to improve code complementarity,\n- Fix the code using GCC-6.2.1 check,\n- Correct hammerhead_defconfig according to Breakfast requirements,\n- Create breakfastcaf default configuration,\n- Improve mutex API usage,\n- Add unevictable pages accounting to LMK,\n- Cleanup devfreq implementation,\n- Increase maximum panel framerate to 63fps,\n- Use module to export msm_thermal configuration to sysfs,\n- Same for scheduler features (gentle_fair_sleepers and arch_power),\n- Disable software CRC and export the variable to sysfs,\n- Lock the initial TCP window size to 64K,\n- Use optimized int_sqrt() implementation,\n- Disable add_random on SSD-like storage,\n- Export TARGET_TTL to iptables,\n- Fix a deadlock in cmdbatch timer,\n- Add ZEN i/o scheduler and use it by default,\n- Implement Budget Fair Scheduler v7r8 and EQM addon,\n- Remove '+' symbol from localversion,\n- Force SELinux Permissive mode,\n- Increase char/random thresholds,\n- Improve cpu-boost logic,\n- Return back CONFIG_SWAP in cyanogenmod_hammerhead_defconfig,\n- Set vm_swappiness value to 40,\n- Add a rule to main .gitignore to ignore 'patch' stuff,\n- Revert 'hammerhead: Enable partial update' patch,\n- Fix entropy depleting by using get_atrandom_bytes(),\n- Make defconfig beautiful,\n- Change the init level of msm-pm debug counters,\n- Add a NULL check of next event time in lpm_levels module,\n- Add eventimer migration framework,\n- Prevent overflow in cpuidle driver,\n- Use high priority WQs in DM drivers,\n- Fix the compiler's bad optimization in RW fs block,\n- Set slub_max_order to 0,\n- Remove spinlock usage in __kpss_mux_set_sel,\n- Enable spinlock debugging,\n- Correct KPSS hardware configuration;\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/430e437008303b3340cc3b0dc3d824037f7c9d71"},{"sha":"98b8cb07ee57a1bef760433fef0e6dc0d50efa8b","author":{"name":"Paul Reioux","email":"2df5ea7ea0deee0a93b94b0ea4649d185b73c84a@gmail.com"},"message":"ASoC: wcd9320: Export volume controls to sysfs\n\nA simple sound volume controller for WCD9320 (Taiko) devices.\nOriginally written by Paul Reioux (faux123), fixed by Aaron Segaert\n(flar2) and completed by me.\n\nFeature list:\n- Speaker volume gain\n- Headphones volume gain\n- Camera/in-call microphones sensetive gain\n\nThanks to @robcore for his enthusiasm about this driver.\n\n[als]: Removed PowerAMP gain as it is broken on LP+ ROMs.\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Flar2 <asegaert@gmail.com>\nSigned-off-by: Paul Reioux <reioux@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/98b8cb07ee57a1bef760433fef0e6dc0d50efa8b"},{"sha":"6f98eb2dfc011b38c53b954b3a8bd8b03e54c2aa","author":{"name":"Savoca","email":"d8e760ef6a7aeade4459e0b4824d86044527f6a2@gmail.com"},"message":"msm: mdss: Add KCAL Color Control driver\n\nAn advanced color control interface by @savoca,\nthat uses PCC calls to interfere the MDP5 video layer.\n\nWe already have a generic Cyanogen PCC color interface,\nthat was introduced in a593140 , but it is too simple.\n\nI've also ported the KCAL-CM_PCC synchronization patch (2e5895b)\nfrom Flar2's tree, that improves the compatibility between\nthe interfaces.\n\nFeature list:\n- RGB Controls\n- Screen invertion\n- Saturation intensity\n- Grayscale mode\n- Screen hue\n- Screen contrast\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Savoca <adeddo27@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/6f98eb2dfc011b38c53b954b3a8bd8b03e54c2aa"},{"sha":"3ac033c1203696faf75d6472cc22fb1816ac14e4","author":{"name":"flar2","email":"54baee86d9719f38bf07b54ac189c5126488f211@gmail.com"},"message":"backlight: lm3630: Export min_brightness variable\n\nA simple backlight dimmer with gradual brightness control.\n\nIt uses lm3630_set_brightness() call to change the minimum brightness\nof the lm3630 backlight panel.\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: franciscofranco <franciscofranco.1990@gmail.com>\nSigned-off-by: flar2 <asegaert@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/3ac033c1203696faf75d6472cc22fb1816ac14e4"},{"sha":"de6698967630df5ca2ba4e6310ba392dec13be7b","author":{"name":"Jean-Pierre Rasquin","email":"4ef8a2555692077f234eb620510f1de72b709988@gmail.com"},"message":"msm: Force fast charge for BQ24192 charger driver\n\nInitial charge controller adaptation for BQ24192 charger.\nAuthor of the original concept - Chad Froebel <chadfroebel@gmail.com>,\nported to Nexus 5 and extended - Jean-Pierre Rasquin <yank555.lu@gmail.com>,\ncleaned and finalized - Alex Saiko <solcmdr@gmail.com>.\n\nSysFS interface :\n\n * /sys/kernel/fast_charge/force_fast_charge (rw)\n *\n *   0 - disabled (default)\n *   1 - substitute AC to USB\n *   2 - use custom mA configured through sysfs interface (see below)\n *\n * /sys/kernel/fast_charge/ac_charge_level (rw)\n *\n *   rate at which to charge when on AC (1.0A/h to 2.0A/h)\n *\n * /sys/kernel/fast_charge/usb_charge_level (r/w)\n *\n *   rate at which to charge when on USB (0.5A/h to 1.0A/h)\n *\n * /sys/kernel/fast_charge/failsafe (rw)\n *\n *   0 - disabled - allow 0.1A/h up to 2.0A/h to be used as AC / USB custom current\n *   1 - enabled  - behaviour as described above (default)\n *\n * /sys/kernel/fast_charge/ac_levels (ro)\n *\n *   display available levels for AC (for failsafe enabled mode)\n *\n * /sys/kernel/fast_charge/usb_levels (ro)\n *\n *   display available levels for USB (for failsafe enabled mode)\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Jean-Pierre Rasquin <yank555.lu@gmail.com>\nSigned-off-by: Chad Froebel <chadfroebel@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/de6698967630df5ca2ba4e6310ba392dec13be7b"},{"sha":"7fc69f5ffff5a25fcfbf7a5ee9878c3003051eaa","author":{"name":"Francisco Franco","email":"0ac3193ff3d7b4e68ae404d59f776924e2be9ac9@gmail.com"},"message":"fs: sync: Add fsync_enabled trigger\n\nIn some cases (e.g. benchmarks) file synchronization could be disabled\nfor better file system performance. But there is a risk of data loss,\nbecause the data does not flushes to the disk.\n\nAdd a module trigger for enabling fsync.\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Francisco Franco <franciscofranco.1990@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/7fc69f5ffff5a25fcfbf7a5ee9878c3003051eaa"},{"sha":"0f15a502dac8eff31860e161255b0096e109c16d","author":{"name":"Paul Reioux","email":"2df5ea7ea0deee0a93b94b0ea4649d185b73c84a@gmail.com"},"message":"fs: Introduce DFS\n\nDynamic File Synchronization module is used to avoid 'fsync' calls\nwhen the device is active. It can improve performance with a slight\nrisk of data loss.\n\nStatic file system is not a good thing, though. The concept of dynamic\nfile system synchronization is implemented into DFS. It uses STATE_NOTIFIER\nto monitor the device state. File system will be synchronized during\nsuspend, while 'fsync' call would be disabled on active state.\n\nOriginal author: Paul Reioux <reioux@gmail.com>\n[als]: Rewritten to work with state_notifier\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Paul Reioux <reioux@gmail.com>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/0f15a502dac8eff31860e161255b0096e109c16d"},{"sha":"8e0c9f7c415264505733ede4fc674c72794085da","author":{"name":"Alex Saiko","email":"7beb632b26f8bed29fb02d734696091dae659aec@gmail.com"},"message":"[backport] workqueue: Backport from Linux upstream\n\nworkqueue: use new hashtable implementation\n\nSwitch workqueues to use the new hashtable implementation. This reduces the\namount of generic unrelated code in the workqueues.\n\nThis patch depends on d9b482c ('hashtable: introduce a small and naive\nhashtable') which was merged in v3.6.\n\nAcked-by: Tejun Heo <tj@kernel.org>\nSigned-off-by: Sasha Levin <sasha.levin@oracle.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n\nConflicts:\nkernel/workqueue.c\n\nworkqueue: fix find_worker_executing_work() brekage from hashtable conversion\n\ncommit ('workqueue: use new hashtable implementation') incorrectly\nmade busy workers hashed by the pointer value of worker instead of\nwork.  This broke find_worker_executing_work() which in turn broke a\nlot of fundamental operations of workqueue - non-reentrancy and\nflushing among others.  The flush malfunction triggered warning in\ndisk event code in Fengguang's automated test.\n\n write_dev_root_ (3265) used greatest stack depth: 2704 bytes left\n ------------[ cut here ]------------\n WARNING: at /c/kernel-tests/src/stable/block/genhd.c:1574 disk_clear_events+0xcf/0x108()\n Hardware name: Bochs\n Modules linked in:\n Pid: 3328, comm: ata_id Not tainted 3.7.0-01930-gbff6343 #1167\n Call Trace:\n  [<ffffffff810997c4>] warn_slowpath_common+0x83/0x9c\n  [<ffffffff810997f7>] warn_slowpath_null+0x1a/0x1c\n  [<ffffffff816aea77>] disk_clear_events+0xcf/0x108\n  [<ffffffff811bd8be>] check_disk_change+0x27/0x59\n  [<ffffffff822e48e2>] cdrom_open+0x49/0x68b\n  [<ffffffff81ab0291>] idecd_open+0x88/0xb7\n  [<ffffffff811be58f>] __blkdev_get+0x102/0x3ec\n  [<ffffffff811bea08>] blkdev_get+0x18f/0x30f\n  [<ffffffff811bebfd>] blkdev_open+0x75/0x80\n  [<ffffffff8118f510>] do_dentry_open+0x1ea/0x295\n  [<ffffffff8118f5f0>] finish_open+0x35/0x41\n  [<ffffffff8119c720>] do_last+0x878/0xa25\n  [<ffffffff8119c993>] path_openat+0xc6/0x333\n  [<ffffffff8119cf37>] do_filp_open+0x38/0x86\n  [<ffffffff81190170>] do_sys_open+0x6c/0xf9\n  [<ffffffff8119021e>] sys_open+0x21/0x23\n  [<ffffffff82c1c3d9>] system_call_fastpath+0x16/0x1b\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReported-by: Fengguang Wu <fengguang.wu@intel.com>\nCc: Sasha Levin <sasha.levin@oracle.com>\n\nworkqueues: Introduce new flag WQ_POWER_EFFICIENT for power oriented workqueues\n\nAdapted for 3.4 from lsk-v3.10\n\nWorkqueues can be performance or power-oriented. Currently, most workqueues are\nbound to the CPU they were created on. This gives good performance (due to cache\neffects) at the cost of potentially waking up otherwise idle cores (Idle from\nscheduler's perspective. Which may or may not be physically idle) just to\nprocess some work. To save power, we can allow the work to be rescheduled on a\ncore that is already awake.\n\nWorkqueues created with the WQ_UNBOUND flag will allow some power savings.\nHowever, we don't change the default behaviour of the system.  To enable\npower-saving behaviour, a new config option CONFIG_WQ_POWER_EFFICIENT needs to\nbe turned on. This option can also be overridden by the\nworkqueue.power_efficient boot parameter.\n\ntj: Updated config description and comments.  Renamed\n    CONFIG_WQ_POWER_EFFICIENT to CONFIG_WQ_POWER_EFFICIENT_DEFAULT.\n\nSigned-off-by: Viresh Kumar <viresh.kumar@linaro.org>\nReviewed-by: Amit Kucheria <amit.kucheria@linaro.org>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n(cherry picked from commit cee22a1)\nSigned-off-by: Mark Brown <broonie@linaro.org>\nSigned-off-by: Luis Cruz <ljc2491@gmail.com>\nSigned-off-by: poondog <markj338@gmail.com>\n\nworkqueue: Add system wide power_efficient workqueues\n\nAdapted for 3.4 from lsk-v3.10\n\nThis patch adds system wide workqueues aligned towards power saving. This is\ndone by allocating them with WQ_UNBOUND flag if 'wq_power_efficient' is set to\n'true'.\n\ntj: updated comments a bit.\n\nSigned-off-by: Viresh Kumar <viresh.kumar@linaro.org>\nSigned-off-by: Tejun Heo <tj@kernel.org>\n(cherry picked from commit 0668106)\nSigned-off-by: Mark Brown <broonie@linaro.org>\nSigned-off-by: Luis Cruz <ljc2491@gmail.com>\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: 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\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: rename kernel/workqueue_sched.h to kernel/workqueue_internal.h\n\nWorkqueue wants to expose more interface internal to kernel/.  Instead\nof adding a new header file, repurpose kernel/workqueue_sched.h.\nRename it to workqueue_internal.h and add include protector.\n\nThis patch doesn't introduce any functional changes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\nCc: Ingo Molnar <mingo@redhat.com>\nCc: Peter Zijlstra <peterz@infradead.org>\n\nworkqueue: Added null check and warning\n\nIf work item is already in queue get_work_cwq() will return null.\nso null check is added to avoid crash in delayed_work_timer_on()\n\nSigned-off-by: Srinivasarao P <spathi@codeaurora.org>\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: fix spurious CPU locality WARN from process_one_work()\n\n25511a4 '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: 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\n    master\n\n    v3.17-rc2\n    …\n    v3.7\n\ncommit d4283e9 1 parent 0a13c00\nTejun Heo authored on Aug 3, 2012\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\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    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\nConflicts:\nkernel/workqueue.c\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\nConflicts:\nkernel/workqueue.c\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\n    master\n\n    v3.17-rc2\n    …\n    v3.7\n\ncommit bf4ede0 1 parent 715f130\nTejun Heo authored on Aug 3, 2012\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\nConflicts:\nkernel/workqueue.c\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\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\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    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\nConflicts:\nkernel/workqueue.c\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 3270476 ('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\ngcwq = get_gcwq(cpu);\nif (wq->flags & WQ_NON_REENTRANT &&\n(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 3270476 ('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\nConflicts:\nkernel/workqueue.c\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\nConflicts:\nkernel/workqueue.c\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\nConflicts:\nkernel/workqueue.c\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\nConflicts:\nkernel/workqueue.c\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\nConflicts:\ninclude/linux/workqueue.h\nkernel/workqueue.c\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\nworker->flags &= ~WORKER_UNBOUND;\nworker->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\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: stable@vger.kernel.org\n\nConflicts:\nkernel/workqueue.c\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\nwait_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 6037315 '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\nConflicts:\nkernel/workqueue.c\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\n    master\n\n    v3.17-rc2\n    …\n    v3.6\n\ncommit ee378aa 1 parent 552a37e\nLai Jiangshan laijs authored on Sep 10, 2012\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 25511a4 '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\n    master\n\n    v3.17-rc2\n    …\n    v3.6\n\ncommit 960bd11 1 parent ee378aa\nLai Jiangshan laijs authored on Sep 18, 2012\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:\n1) remove unlikely from too_many_workers(), ->idle_list can be empty\n   anytime, even before this patch, no reason to use unlikely.\n2) fix a small rebasing mistake.\n   (which is from rebasing the orignal fixing patch to for-next)\n3) add a lot of comments.\n4) 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\n\ntj: Updated description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\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   data    bss    dec    hexfilename\n  18513   2387   1221  22121   5669kernel/workqueue.o.cpu_notifier\n  18082   2355   1221  21658   549akernel/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: remove @delayed from cwq_dec_nr_in_flight()\n\n@delayed is now always false for all callers, remove it.\n\ntj: Updated description.\n\nSigned-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>\nSigned-off-by: Tejun Heo <tj@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\ne0aecdd ('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\n57b30ae ('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: mod_delayed_work_on() shouldn't queue timer on 0 delay\n\n8376fe2 ('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\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\n8852aac ('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.  8852aac\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 c1d390d ('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\nworkqueue: set PF_WQ_WORKER on rescuers\n\nPF_WQ_WORKER is used to tell scheduler that the task is a workqueue\nworker and needs wq_worker_sleeping/waking_up() invoked on it for\nconcurrency management.  As rescuers never participate in concurrency\nmanagement, PF_WQ_WORKER wasn't set on them.\n\nThere's a need for an interface which can query whether %current is\nexecuting a work item and if so which.  Such interface requires a way\nto identify all tasks which may execute work items and PF_WQ_WORKER\nwill be used for that.  As all normal workers always have PF_WQ_WORKER\nset, we only need to add it to rescuers.\n\nAs rescuers start with WORKER_PREP but never clear it, it's always\nNOT_RUNNING and there's no need to worry about it interfering with\nconcurrency management even if PF_WQ_WORKER is set; however, unlike\nnormal workers, rescuers currently don't have its worker struct as\nkthread_data().  It uses the associated workqueue_struct instead.\nThis is problematic as wq_worker_sleeping/waking_up() expect struct\nworker at kthread_data().\n\nThis patch adds worker->rescue_wq and start rescuer kthreads with\nworker struct as kthread_data and sets PF_WQ_WORKER on rescuers.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\n\nworkqueue: move struct worker definition to workqueue_internal.h\n\nThis will be used to implement an inline function to query whether\n%current is a workqueue worker and, if so, allow determining which\nwork item it's executing.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nCc: Linus Torvalds <torvalds@linux-foundation.org>\n\nworkqueue: unexport work_cpu()\n\nThis function no longer has any external users.  Unexport it.  It will\nbe removed later on.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: use std_ prefix for the standard per-cpu pools\n\nThere are currently two worker pools per cpu (including the unbound\ncpu) and they are the only pools in use.  New class of pools are\nscheduled to be added and some pool related APIs will be added\ninbetween.  Call the existing pools the standard pools and prefix them\nwith std_.  Do this early so that new APIs can use std_ prefix from\nthe beginning.\n\nThis patch doesn't introduce any functional difference.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: make GCWQ_DISASSOCIATED a pool flag\n\nMake GCWQ_DISASSOCIATED a pool flag POOL_DISASSOCIATED.  This patch\ndoesn't change locking - DISASSOCIATED on both pools of a CPU are set\nor clear together while holding gcwq->lock.  It shouldn't cause any\nfunctional difference.\n\nThis is part of an effort to remove global_cwq and make worker_pool\nthe top level abstraction, which in turn will help implementing worker\npools with user-specified attributes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: make GCWQ_FREEZING a pool flag\n\nMake GCWQ_FREEZING a pool flag POOL_FREEZING.  This patch doesn't\nchange locking - FREEZING on both pools of a CPU are set or clear\ntogether while holding gcwq->lock.  It shouldn't cause any functional\ndifference.\n\nThis leaves gcwq->flags w/o any flags.  Removed.\n\nWhile at it, convert BUG_ON()s in freeze_workqueue_begin() and\nthaw_workqueues() to WARN_ON_ONCE().\n\nThis is part of an effort to remove global_cwq and make worker_pool\nthe top level abstraction, which in turn will help implementing worker\npools with user-specified attributes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: introduce WORK_OFFQ_CPU_NONE\n\nCurrently, when a work item is off queue, high bits of its data\nencodes the last CPU it was on.  This is scheduled to be changed to\npool ID, which will make it impossible to use WORK_CPU_NONE to\nindicate no association.\n\nThis patch limits the number of bits which are used for off-queue cpu\nnumber to 31 (so that the max fits in an int) and uses the highest\npossible value - WORK_OFFQ_CPU_NONE - to indicate no association.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: add worker_pool->id\n\nAdd worker_pool->id which is allocated from worker_pool_idr.  This\nwill be used to record the last associated worker_pool in work->data.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: record pool ID instead of CPU in work->data when off-queue\n\nCurrently, when a work item is off-queue, work->data records the CPU\nit was last on, which is used to locate the last executing instance\nfor non-reentrance, flushing, etc.\n\nWe're in the process of removing global_cwq and making worker_pool the\ntop level abstraction.  This patch makes work->data point to the pool\nit was last associated with instead of CPU.\n\nAfter the previous WORK_OFFQ_POOL_CPU and worker_poo->id additions,\nthe conversion is fairly straight-forward.  WORK_OFFQ constants and\nfunctions are modified to record and read back pool ID instead.\nworker_pool_by_id() is added to allow looking up pool from ID.\nget_work_pool() replaces get_work_gcwq(), which is reimplemented using\nget_work_pool().  get_work_pool_id() replaces work_cpu().\n\nThis patch shouldn't introduce any observable behavior changes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nworkqueue: move busy_hash from global_cwq to worker_pool\n\nThere's no functional necessity for the two pools on the same CPU to\nshare the busy hash table.  It's also likely to be a bottleneck when\nimplementing pools with user-specified attributes.\n\nThis patch makes busy_hash per-pool.  The conversion is mostly\nstraight-forward.  Changes worth noting are,\n\n* Large block of changes in rebind_workers() is moving the block\n  inside for_each_worker_pool() as now there are separate hash tables\n  for each pool.  This changes the order of operations but doesn't\n  break anything.\n\n* Thre for_each_worker_pool() loops in gcwq_unbind_fn() are combined\n  into one.  This again changes the order of operaitons but doesn't\n  break anything.\n\nThis is part of an effort to remove global_cwq and make worker_pool\nthe top level abstraction, which in turn will help implementing worker\npools with user-specified attributes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\nConflicts:\nkernel/workqueue.c\n\nworkqueue: move global_cwq->cpu to worker_pool\n\nMove gcwq->cpu to pool->cpu.  This introduces a couple places where\ngcwq->pools[0].cpu is used.  These will soon go away as gcwq is\nfurther reduced.\n\nThis is part of an effort to remove global_cwq and make worker_pool\nthe top level abstraction, which in turn will help implementing worker\npools with user-specified attributes.\n\nSigned-off-by: Tejun Heo <tj@kernel.org>\nReviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>\n\n...","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/8e0c9f7c415264505733ede4fc674c72794085da"},{"sha":"dbcd8e3757b985cdb658d795f187d22642d079c0","author":{"name":"Fluxi","email":"95ab61bb01957fc548ef82d227666a28af3268a6@arcor.de"},"message":"clock-krait-8974: Voltage table interface for dts-based cpufreq device\n\nUserspace voltage table parses 'dts_freq_table' and gathers information\nfrom it. It shows voltages for active frequencies only to avoid an issue\nwith wrong voltage set.\n\nVoltages change due to 'cpu_clk' call with converted values (mV to uV),\nwhich come from userspace.\n\nChangelog:\n- Raise maximum CPU voltage to 1200000uV,\n- Export CPU voltage table to sysfs;\n\nSigned-off-by: Alex Saiko <solcmdr@gmail.com>\nSigned-off-by: Fluxi <linflux@arcor.de>","distinct":true,"url":"https://api.github.com/repos/alesaiko/breakfast-hammerheadcaf/commits/dbcd8e3757b985cdb658d795f187d22642d079c0"}]}
{"actor":{"display_login":"alesaiko"}}