<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/workqueue.c, branch v5.8.10</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.8.10</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.8.10'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-06-17T17:57:41Z</updated>
<entry>
<title>maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault</title>
<updated>2020-06-17T17:57:41Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-06-17T07:37:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fe557319aa06c23cffc9346000f119547e0f289a'/>
<id>urn:sha1:fe557319aa06c23cffc9346000f119547e0f289a</id>
<content type='text'>
Better describe what these functions do.

Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>workqueue: use BUILD_BUG_ON() for compile time test instead of WARN_ON()</title>
<updated>2020-06-01T15:02:42Z</updated>
<author>
<name>Lai Jiangshan</name>
<email>laijs@linux.alibaba.com</email>
</author>
<published>2020-06-01T08:44:40Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=10cdb15759540f03d056e2f73fe26377ed7dcfda'/>
<id>urn:sha1:10cdb15759540f03d056e2f73fe26377ed7dcfda</id>
<content type='text'>
Any runtime WARN_ON() has to be fixed, and BUILD_BUG_ON() can
help you nitice it earlier.

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: remove useless unlock() and lock() in series</title>
<updated>2020-05-29T14:25:23Z</updated>
<author>
<name>Lai Jiangshan</name>
<email>laijs@linux.alibaba.com</email>
</author>
<published>2020-05-29T06:59:02Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b8f06b0444ec146e3ae98caac8039c77e5308ce2'/>
<id>urn:sha1:b8f06b0444ec146e3ae98caac8039c77e5308ce2</id>
<content type='text'>
This is no point to unlock() and then lock() the same mutex
back to back.

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: void unneeded requeuing the pwq in rescuer thread</title>
<updated>2020-05-29T14:22:10Z</updated>
<author>
<name>Lai Jiangshan</name>
<email>laijs@linux.alibaba.com</email>
</author>
<published>2020-05-29T06:58:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4f3f4cf388f8fda7ee8ea7c6af0ff0ebb2d05fe4'/>
<id>urn:sha1:4f3f4cf388f8fda7ee8ea7c6af0ff0ebb2d05fe4</id>
<content type='text'>
008847f66c3 ("workqueue: allow rescuer thread to do more work.") made
the rescuer worker requeue the pwq immediately if there may be more
work items which need rescuing instead of waiting for the next mayday
timer expiration.  Unfortunately, it checks only whether the pool needs
help from rescuers, but it doesn't check whether the pwq has work items
in the pool (the real reason that this rescuer can help for the pool).

The patch adds the check and void unneeded requeuing.

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: Convert the pool::lock and wq_mayday_lock to raw_spinlock_t</title>
<updated>2020-05-29T14:03:47Z</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2020-05-27T19:46:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a9b8a985294debae00f6c087dfec8c384d30a3b9'/>
<id>urn:sha1:a9b8a985294debae00f6c087dfec8c384d30a3b9</id>
<content type='text'>
The workqueue code has it's internal spinlocks (pool::lock), which
are acquired on most workqueue operations. These spinlocks are
converted to 'sleeping' spinlocks on a RT-kernel.

Workqueue functions can be invoked from contexts which are truly atomic
even on a PREEMPT_RT enabled kernel. Taking sleeping locks from such
contexts is forbidden.

The pool::lock hold times are bound and the code sections are
relatively short, which allows to convert pool::lock and as a
consequence wq_mayday_lock to raw spinlocks which are truly spinning
locks even on a PREEMPT_RT kernel.

With the previous conversion of the manager waitqueue to a simple
waitqueue workqueues are now fully RT compliant.

Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Reviewed-by: Lai Jiangshan &lt;jiangshanlai@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Use rcuwait for wq_manager_wait</title>
<updated>2020-05-29T14:00:35Z</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2020-05-27T19:46:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d8bb65ab70f702531aaaa11d9710f9450078e295'/>
<id>urn:sha1:d8bb65ab70f702531aaaa11d9710f9450078e295</id>
<content type='text'>
The workqueue code has it's internal spinlock (pool::lock) and also
implicit spinlock usage in the wq_manager waitqueue. These spinlocks
are converted to 'sleeping' spinlocks on a RT-kernel.

Workqueue functions can be invoked from contexts which are truly atomic
even on a PREEMPT_RT enabled kernel. Taking sleeping locks from such
contexts is forbidden.

pool::lock can be converted to a raw spinlock as the lock held times
are short. But the workqueue manager waitqueue is handled inside of
pool::lock held regions which again violates the lock nesting rules
of raw and regular spinlocks.

The manager waitqueue has no special requirements like custom wakeup
callbacks or mass wakeups. While it does not use exclusive wait mode
explicitly there is no strict requirement to queue the waiters in a
particular order as there is only one waiter at a time.

This allows to replace the waitqueue with rcuwait which solves the
locking problem because rcuwait relies on existing locking.

Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Remove unnecessary kfree() call in rcu_free_wq()</title>
<updated>2020-05-27T13:52:41Z</updated>
<author>
<name>Zhang Qiang</name>
<email>qiang.zhang@windriver.com</email>
</author>
<published>2020-05-27T07:57:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=342ed2400b78072cc01c0130ce41240dec60d56d'/>
<id>urn:sha1:342ed2400b78072cc01c0130ce41240dec60d56d</id>
<content type='text'>
The data structure member "wq-&gt;rescuer" was reset to a null pointer
in one if branch. It was passed to a call of the function "kfree"
in the callback function "rcu_free_wq" (which was eventually executed).
The function "kfree" does not perform more meaningful data processing
for a passed null pointer (besides immediately returning from such a call).
Thus delete this function call which became unnecessary with the referenced
software update.

Fixes: def98c84b6cd ("workqueue: Fix spurious sanity check failures in destroy_workqueue()")

Suggested-by: Markus Elfring &lt;Markus.Elfring@web.de&gt;
Signed-off-by: Zhang Qiang &lt;qiang.zhang@windriver.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Fix an use after free in init_rescuer()</title>
<updated>2020-05-11T14:25:42Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2020-05-08T15:07:40Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b92b36eadf4d7fa4a34f048c2a3bb61a735a885e'/>
<id>urn:sha1:b92b36eadf4d7fa4a34f048c2a3bb61a735a885e</id>
<content type='text'>
We need to preserve error code before freeing "rescuer".

Fixes: f187b6974f6df ("workqueue: Use IS_ERR and PTR_ERR instead of PTR_ERR_OR_ZERO.")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Lai Jiangshan &lt;jiangshanlai@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Use IS_ERR and PTR_ERR instead of PTR_ERR_OR_ZERO.</title>
<updated>2020-05-05T15:56:07Z</updated>
<author>
<name>Sean Fu</name>
<email>fxinrong@gmail.com</email>
</author>
<published>2020-04-29T04:04:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f187b6974f6dfbeba4aafda972cc37f27d091b73'/>
<id>urn:sha1:f187b6974f6dfbeba4aafda972cc37f27d091b73</id>
<content type='text'>
Replace inline function PTR_ERR_OR_ZERO with IS_ERR and PTR_ERR to
remove redundant parameter definitions and checks.
Reduce code size.
Before:
   text	   data	    bss	    dec	    hex	filename
  47510	   5979	    840	  54329	   d439	kernel/workqueue.o
After:
   text	   data	    bss	    dec	    hex	filename
  47474	   5979	    840	  54293	   d415	kernel/workqueue.o

Signed-off-by: Sean Fu &lt;fxinrong@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>workqueue: Remove the warning in wq_worker_sleeping()</title>
<updated>2020-04-08T09:35:20Z</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2020-03-27T23:29:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=62849a9612924a655c67cf6962920544aa5c20db'/>
<id>urn:sha1:62849a9612924a655c67cf6962920544aa5c20db</id>
<content type='text'>
The kernel test robot triggered a warning with the following race:
   task-ctx A                            interrupt-ctx B
 worker
  -&gt; process_one_work()
    -&gt; work_item()
      -&gt; schedule();
         -&gt; sched_submit_work()
           -&gt; wq_worker_sleeping()
             -&gt; -&gt;sleeping = 1
               atomic_dec_and_test(nr_running)
         __schedule();                *interrupt*
                                       async_page_fault()
                                       -&gt; local_irq_enable();
                                       -&gt; schedule();
                                          -&gt; sched_submit_work()
                                            -&gt; wq_worker_sleeping()
                                               -&gt; if (WARN_ON(-&gt;sleeping)) return
                                          -&gt; __schedule()
                                            -&gt;  sched_update_worker()
                                              -&gt; wq_worker_running()
                                                 -&gt; atomic_inc(nr_running);
                                                 -&gt; -&gt;sleeping = 0;

      -&gt;  sched_update_worker()
        -&gt; wq_worker_running()
          if (!-&gt;sleeping) return

In this context the warning is pointless everything is fine.
An interrupt before wq_worker_sleeping() will perform the -&gt;sleeping
assignment (0 -&gt; 1 &gt; 0) twice.
An interrupt after wq_worker_sleeping() will trigger the warning and
nr_running will be decremented (by A) and incremented once (only by B, A
will skip it). This is the case until the -&gt;sleeping is zeroed again in
wq_worker_running().

Remove the WARN statement because this condition may happen. Document
that preemption around wq_worker_sleeping() needs to be disabled to
protect -&gt;sleeping and not just as an optimisation.

Fixes: 6d25be5782e48 ("sched/core, workqueues: Distangle worker accounting from rq lock")
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Link: https://lkml.kernel.org/r/20200327074308.GY11705@shao2-debian
</content>
</entry>
</feed>
