All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: Tejun Heo <tj@kernel.org>
Cc: 0day robot <lkp@intel.com>, LKML <linux-kernel@vger.kernel.org>,
	lkp@lists.01.org, kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH] workqueue: Use private WQ for schedule_on_each_cpu() API
Date: Thu, 24 Feb 2022 07:26:30 +0900	[thread overview]
Message-ID: <9a883d72-ea7d-1936-93e6-5c2a290509d4@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <YhaoDiJ8MUOhRmp6@slm.duckdns.org>

On 2022/02/24 6:33, Tejun Heo wrote:
> On Wed, Feb 23, 2022 at 09:57:27AM +0900, Tetsuo Handa wrote:
>> On 2022/02/23 2:29, Tejun Heo wrote:
>>> On Mon, Feb 21, 2022 at 07:38:09PM +0900, Tetsuo Handa wrote:
>>>> Since schedule_on_each_cpu() calls schedule_work_on() and flush_work(),
>>>> we should avoid using system_wq in order to avoid unexpected locking
>>>> dependency.
>>>
>>> I don't get it. schedule_on_each_cpu() is flushing each work item and thus
>>> shouldn't need its own flushing domain. What's this change for?
>>
>> A kernel test robot tested "[PATCH v2] workqueue: Warn flush attempt using
>> system-wide workqueues" on 5.16.0-06523-g29bd199e4e73 and hit a lockdep
>> warning ( https://lkml.kernel.org/r/20220221083358.GC835@xsang-OptiPlex-9020 ).
>>
>> Although the circular locking dependency itself needs to be handled by
>> lockless console printing support, we won't be able to apply
>> "[PATCH v2] workqueue: Warn flush attempt using system-wide workqueues"
>> if schedule_on_each_cpu() continues using system-wide workqueues.
> 
> The patch seems pretty wrong. What's problematic is system workqueue flushes
> (which flushes the entire workqueue), not work item flushes.

Why? My understanding is that

  flushing a workqueue waits for completion of all work items in that workqueue

  flushing a work item waits for for completion of that work item using
  a workqueue specified as of queue_work()

and

  if a work item in some workqueue is blocked by other work in that workqueue
  (e.g. max_active limit, work items on that workqueue and locks they need),
  it has a risk of deadlock

. Then, how can flushing a work item using system-wide workqueues be free of deadlock risk?
Isn't it just "unlikely to deadlock" rather than "impossible to deadlock"?


WARNING: multiple messages have this Message-ID (diff)
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: lkp@lists.01.org
Subject: Re: [PATCH] workqueue: Use private WQ for schedule_on_each_cpu() API
Date: Thu, 24 Feb 2022 07:26:30 +0900	[thread overview]
Message-ID: <9a883d72-ea7d-1936-93e6-5c2a290509d4@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <YhaoDiJ8MUOhRmp6@slm.duckdns.org>

[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]

On 2022/02/24 6:33, Tejun Heo wrote:
> On Wed, Feb 23, 2022 at 09:57:27AM +0900, Tetsuo Handa wrote:
>> On 2022/02/23 2:29, Tejun Heo wrote:
>>> On Mon, Feb 21, 2022 at 07:38:09PM +0900, Tetsuo Handa wrote:
>>>> Since schedule_on_each_cpu() calls schedule_work_on() and flush_work(),
>>>> we should avoid using system_wq in order to avoid unexpected locking
>>>> dependency.
>>>
>>> I don't get it. schedule_on_each_cpu() is flushing each work item and thus
>>> shouldn't need its own flushing domain. What's this change for?
>>
>> A kernel test robot tested "[PATCH v2] workqueue: Warn flush attempt using
>> system-wide workqueues" on 5.16.0-06523-g29bd199e4e73 and hit a lockdep
>> warning ( https://lkml.kernel.org/r/20220221083358.GC835(a)xsang-OptiPlex-9020 ).
>>
>> Although the circular locking dependency itself needs to be handled by
>> lockless console printing support, we won't be able to apply
>> "[PATCH v2] workqueue: Warn flush attempt using system-wide workqueues"
>> if schedule_on_each_cpu() continues using system-wide workqueues.
> 
> The patch seems pretty wrong. What's problematic is system workqueue flushes
> (which flushes the entire workqueue), not work item flushes.

Why? My understanding is that

  flushing a workqueue waits for completion of all work items in that workqueue

  flushing a work item waits for for completion of that work item using
  a workqueue specified as of queue_work()

and

  if a work item in some workqueue is blocked by other work in that workqueue
  (e.g. max_active limit, work items on that workqueue and locks they need),
  it has a risk of deadlock

. Then, how can flushing a work item using system-wide workqueues be free of deadlock risk?
Isn't it just "unlikely to deadlock" rather than "impossible to deadlock"?

  reply	other threads:[~2022-02-23 22:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21  8:33 [workqueue] 29bd199e4e: WARNING:possible_circular_locking_dependency_detected kernel test robot
2022-02-21  8:33 ` kernel test robot
2022-02-21 10:38 ` [PATCH] workqueue: Use private WQ for schedule_on_each_cpu() API Tetsuo Handa
2022-02-21 10:38   ` Tetsuo Handa
2022-02-22 17:29   ` Tejun Heo
2022-02-22 17:29     ` Tejun Heo
2022-02-23  0:57     ` Tetsuo Handa
2022-02-23  0:57       ` Tetsuo Handa
2022-02-23 21:33       ` Tejun Heo
2022-02-23 21:33         ` Tejun Heo
2022-02-23 22:26         ` Tetsuo Handa [this message]
2022-02-23 22:26           ` Tetsuo Handa
2022-02-23 22:29           ` Tejun Heo
2022-02-23 22:29             ` Tejun Heo
2022-02-28 14:03             ` [PATCH v3] workqueue: Warn flushing of kernel-global workqueues Tetsuo Handa
2022-02-28 14:03               ` Tetsuo Handa
2022-02-28 18:42               ` Tejun Heo
2022-02-28 18:42                 ` Tejun Heo
2022-03-17 22:25                 ` Tetsuo Handa
2022-03-17 22:25                   ` Tetsuo Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a883d72-ea7d-1936-93e6-5c2a290509d4@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lkp@lists.01.org \
    --cc=oliver.sang@intel.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.