<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/workqueue.c, branch linux-5.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-09-28T09:32:26Z</updated>
<entry>
<title>workqueue: don't skip lockdep work dependency in cancel_work_sync()</title>
<updated>2022-09-28T09:32:26Z</updated>
<author>
<name>Tetsuo Handa</name>
</author>
<published>2022-07-29T04:30:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c9245ea442a82357f4ae943e40b7189e0b3ce6e4'/>
<id>urn:sha1:c9245ea442a82357f4ae943e40b7189e0b3ce6e4</id>
<content type='text'>
[ Upstream commit c0feea594e058223973db94c1c32a830c9807c86 ]

Like Hillf Danton mentioned

  syzbot should have been able to catch cancel_work_sync() in work context
  by checking lockdep_map in __flush_work() for both flush and cancel.

in [1], being unable to report an obvious deadlock scenario shown below is
broken. From locking dependency perspective, sync version of cancel request
should behave as if flush request, for it waits for completion of work if
that work has already started execution.

  ----------
  #include &lt;linux/module.h&gt;
  #include &lt;linux/sched.h&gt;
  static DEFINE_MUTEX(mutex);
  static void work_fn(struct work_struct *work)
  {
    schedule_timeout_uninterruptible(HZ / 5);
    mutex_lock(&amp;mutex);
    mutex_unlock(&amp;mutex);
  }
  static DECLARE_WORK(work, work_fn);
  static int __init test_init(void)
  {
    schedule_work(&amp;work);
    schedule_timeout_uninterruptible(HZ / 10);
    mutex_lock(&amp;mutex);
    cancel_work_sync(&amp;work);
    mutex_unlock(&amp;mutex);
    return -EINVAL;
  }
  module_init(test_init);
  MODULE_LICENSE("GPL");
  ----------

The check this patch restores was added by commit 0976dfc1d0cd80a4
("workqueue: Catch more locking problems with flush_work()").

Then, lockdep's crossrelease feature was added by commit b09be676e0ff25bd
("locking/lockdep: Implement the 'crossrelease' feature"). As a result,
this check was once removed by commit fd1a5b04dfb899f8 ("workqueue: Remove
now redundant lock acquisitions wrt. workqueue flushes").

But lockdep's crossrelease feature was removed by commit e966eaeeb623f099
("locking/lockdep: Remove the cross-release locking checks"). At this
point, this check should have been restored.

Then, commit d6e89786bed977f3 ("workqueue: skip lockdep wq dependency in
cancel_work_sync()") introduced a boolean flag in order to distinguish
flush_work() and cancel_work_sync(), for checking "struct workqueue_struct"
dependency when called from cancel_work_sync() was causing false positives.

Then, commit 87915adc3f0acdf0 ("workqueue: re-add lockdep dependencies for
flushing") tried to restore "struct work_struct" dependency check, but by
error checked this boolean flag. Like an example shown above indicates,
"struct work_struct" dependency needs to be checked for both flush_work()
and cancel_work_sync().

Link: https://lkml.kernel.org/r/20220504044800.4966-1-hdanton@sina.com [1]
Reported-by: Hillf Danton &lt;hdanton@sina.com&gt;
Suggested-by: Lai Jiangshan &lt;jiangshanlai@gmail.com&gt;
Fixes: 87915adc3f0acdf0 ("workqueue: re-add lockdep dependencies for flushing")
Cc: Johannes Berg &lt;johannes.berg@intel.com&gt;
Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Avoid a false warning in unbind_workers()</title>
<updated>2022-07-29T17:49:02Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2022-07-29T09:44:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=46a4d679ef88285ea17c3e1e4fed330be2044f21'/>
<id>urn:sha1:46a4d679ef88285ea17c3e1e4fed330be2044f21</id>
<content type='text'>
Doing set_cpus_allowed_ptr() with wq_unbound_cpumask can be possible
fails and trigger the false warning.

Use cpu_possible_mask instead when wq_unbound_cpumask has no active CPUs.

It is very easy to trigger the warning:
  Set wq_unbound_cpumask to a small set of CPUs.
  Offline all the CPUs of wq_unbound_cpumask.
  Offline an extra CPU and trigger the warning.

Fixes: 10a5a651e3af ("workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs")
Signed-off-by: Lai Jiangshan &lt;jiangshan.ljs@antgroup.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Wrap flush_workqueue() using a macro</title>
<updated>2022-06-07T17:07:14Z</updated>
<author>
<name>Tetsuo Handa</name>
</author>
<published>2022-06-01T07:32:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c4f135d643823a869becfa87539f7820ef9d5bfa'/>
<id>urn:sha1:c4f135d643823a869becfa87539f7820ef9d5bfa</id>
<content type='text'>
Since flush operation synchronously waits for completion, flushing
system-wide WQs (e.g. system_wq) might introduce possibility of deadlock
due to unexpected locking dependency. Tejun Heo commented at [1] that it
makes no sense at all to call flush_workqueue() on the shared WQs as the
caller has no idea what it's gonna end up waiting for.

Although there is flush_scheduled_work() which flushes system_wq WQ with
"Think twice before calling this function! It's very easy to get into
trouble if you don't take great care." warning message, syzbot found a
circular locking dependency caused by flushing system_wq WQ [2].

Therefore, let's change the direction to that developers had better use
their local WQs if flush_scheduled_work()/flush_workqueue(system_*_wq) is
inevitable.

Steps for converting system-wide WQs into local WQs are explained at [3],
and a conversion to stop flushing system-wide WQs is in progress. Now we
want some mechanism for preventing developers who are not aware of this
conversion from again start flushing system-wide WQs.

Since I found that WARN_ON() is complete but awkward approach for teaching
developers about this problem, let's use __compiletime_warning() for
incomplete but handy approach. For completeness, we will also insert
WARN_ON() into __flush_workqueue() after all in-tree users stopped calling
flush_scheduled_work().

Link: https://lore.kernel.org/all/YgnQGZWT%2Fn3VAITX@slm.duckdns.org/ [1]
Link: https://syzkaller.appspot.com/bug?extid=bde0f89deacca7c765b8 [2]
Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp [3]
Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Restrict kworker in the offline CPU pool running on housekeeping CPUs</title>
<updated>2022-04-21T22:31:04Z</updated>
<author>
<name>Zqiang</name>
</author>
<published>2022-03-31T05:57:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=10a5a651e3afc9b0b381f47e8930972e4e918397'/>
<id>urn:sha1:10a5a651e3afc9b0b381f47e8930972e4e918397</id>
<content type='text'>
When a CPU is going offline, all workers on the CPU's pool will have their
cpus_allowed cleared to cpu_possible_mask and can run on any CPUs including
the isolated ones. Instead, set cpus_allowed to wq_unbound_cpumask so that
the can avoid isolated CPUs.

Signed-off-by: Zqiang &lt;qiang1.zhang@intel.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq</title>
<updated>2022-03-23T19:40:51Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2022-03-23T19:40:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=78383162605e22a2aad88e417bb8fcaf808f147a'/>
<id>urn:sha1:78383162605e22a2aad88e417bb8fcaf808f147a</id>
<content type='text'>
Pull workqueue updates from Tejun Heo:
 "Nothing major. Just follow-up cleanups from Lai after the earlier
  synchronization simplification"

* 'for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: Convert the type of pool-&gt;nr_running to int
  workqueue: Use wake_up_worker() in wq_worker_sleeping() instead of open code
  workqueue: Change the comments of the synchronization about the idle_list
  workqueue: Remove the mb() pair between wq_worker_sleeping() and insert_work()
</content>
</entry>
<entry>
<title>sched/isolation: Use single feature type while referring to housekeeping cpumask</title>
<updated>2022-02-16T14:57:55Z</updated>
<author>
<name>Frederic Weisbecker</name>
</author>
<published>2022-02-07T15:59:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04d4e665a60902cf36e7ad39af1179cb5df542ad'/>
<id>urn:sha1:04d4e665a60902cf36e7ad39af1179cb5df542ad</id>
<content type='text'>
Refer to housekeeping APIs using single feature types instead of flags.
This prevents from passing multiple isolation features at once to
housekeeping interfaces, which soon won't be possible anymore as each
isolation features will have their own cpumask.

Signed-off-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Juri Lelli &lt;juri.lelli@redhat.com&gt;
Reviewed-by: Phil Auld &lt;pauld@redhat.com&gt;
Link: https://lore.kernel.org/r/20220207155910.527133-5-frederic@kernel.org
</content>
</entry>
<entry>
<title>workqueue: Decouple HK_FLAG_WQ and HK_FLAG_DOMAIN cpumask fetch</title>
<updated>2022-02-16T14:57:54Z</updated>
<author>
<name>Frederic Weisbecker</name>
</author>
<published>2022-02-07T15:59:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7b45b51e778021cd7817b8f0d743a2c73205c011'/>
<id>urn:sha1:7b45b51e778021cd7817b8f0d743a2c73205c011</id>
<content type='text'>
To prepare for supporting each feature of the housekeeping cpumask
toward cpuset, prepare each of the HK_FLAG_* entries to move to their
own cpumask with enforcing to fetch them individually. The new
constraint is that multiple HK_FLAG_* entries can't be mixed together
anymore in a single call to housekeeping cpumask().

This will later allow, for example, to runtime modify the cpulist passed
through "isolcpus=", "nohz_full=" and "rcu_nocbs=" kernel boot
parameters.

Signed-off-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Juri Lelli &lt;juri.lelli@redhat.com&gt;
Reviewed-by: Phil Auld &lt;pauld@redhat.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Link: https://lore.kernel.org/r/20220207155910.527133-3-frederic@kernel.org
</content>
</entry>
<entry>
<title>workqueue: Convert the type of pool-&gt;nr_running to int</title>
<updated>2022-01-12T17:46:36Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2021-12-23T12:31:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bc35f7ef96284b8c963991357a9278a6beafca54'/>
<id>urn:sha1:bc35f7ef96284b8c963991357a9278a6beafca54</id>
<content type='text'>
It is only modified in associated CPU, so it doesn't need to be atomic.

tj: Comment updated.

Signed-off-by: Lai Jiangshan &lt;laijs@linux.alibaba.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Use wake_up_worker() in wq_worker_sleeping() instead of open code</title>
<updated>2022-01-12T17:40:32Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2021-12-23T12:31:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cc5bff38463e0894dd596befa99f9d6860e15f5e'/>
<id>urn:sha1:cc5bff38463e0894dd596befa99f9d6860e15f5e</id>
<content type='text'>
The wakeup code in wq_worker_sleeping() is the same as wake_up_worker().

Signed-off-by: Lai Jiangshan &lt;laijs@linux.alibaba.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Change the comments of the synchronization about the idle_list</title>
<updated>2022-01-12T17:39:15Z</updated>
<author>
<name>Lai Jiangshan</name>
</author>
<published>2021-12-23T12:31:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2c1f1a9180bfacbc3c8e5b10075640cc810cf9c0'/>
<id>urn:sha1:2c1f1a9180bfacbc3c8e5b10075640cc810cf9c0</id>
<content type='text'>
The access to idle_list in wq_worker_sleeping() is changed to be
protected by pool-&gt;lock, so the comments above idle_list can be changed
to "L:" which is the meaning of "access with pool-&gt;lock held".

And the outdated comments in wq_worker_sleeping() is removed since
the function is not called with rq lock held any more, idle_list is
dereferenced with pool lock now.

Signed-off-by: Lai Jiangshan &lt;laijs@linux.alibaba.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
</feed>
