From: NeilBrown <neilb@suse.de>
To: Hillf Danton <hdanton@sina.com>
Cc: TJ <tj@kernel.org>, Trond Myklebust <trondmy@hammerspace.com>,
PeterZ <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH rfc] workqueue: honour cond_resched() more effectively.
Date: Fri, 27 Nov 2020 10:44:14 +1100 [thread overview]
Message-ID: <87sg8vlm41.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20201126100646.1790-1-hdanton@sina.com>
[-- Attachment #1: Type: text/plain, Size: 2547 bytes --]
On Thu, Nov 26 2020, Hillf Danton wrote:
> On Fri, 20 Nov 2020 15:33:27 +1100 NeilBrown wrote:
>>
>>My first idea was to add WQ_CPU_INTENSIVE to the nfsiod workqueue, but
>>Trond wondered what was special about NFS. Many filesystems call iput
>>from a workqueue, so finding a solution that helps them all is best.
>
> In terms of iput, I think we can splice WQ_CPU_INTENSIVE to
> WQ_MEM_RECLAIM.
I'm actually starting to think that WQ_CPU_INTENSIVE is a mistake. If
you really have cpu-intensive work, you should be using WQ_UNBOUND.
It is possible that there might be work that is CPU intensive and which
must be run on a particular CPU - such as clearing out per-cpu lists of
recently freed slab allocations. But I don't WQ_CPU_INTENSIVE is currently
used that way.
I cannot find *any* users of WQ_CPU_INTENSIVE which call cond_resched()
in the relevant work items. And if the code doesn't call cond_resched()
(or similar), then it isn't really CPU-intensive.
>
>>I then suggested getting cond_resched() to do something more useful when
>>called by a worker. PeterZ didn't like the overhead.
>>
>>Also, TJ seemed to be against auto-adjusting for cpu-intensive code,
>>preferring the right sort of workqueue to be chosen up front.
>
> Actually WQ_EVENTS_LONG sounds better than WQ_CPU_INTENSIVE, given that
> we have two events WQs with the same attr.
There is no WQ_EVENTS_LONG
>
> system_wq = alloc_workqueue("events", 0, 0);
> system_long_wq = alloc_workqueue("events_long", 0, 0);
>
> Then what are the boundaries we can draw in between WQ_MEM_RECLAIM,
> WQ_CPU_INTENSIVE and WQ_EVENTS_LONG?
I think system_long_wq is a design flaw.
Some code (mistakenly) schedules work on system_wq, calls
flush_workqueue(system_wq)) and expects that to complete reasonably quickly.
To ensure this can work, system_long_wq was created and work items that
might take a long time are encouraged to be run there.
Instead, the mistaken code should create its own work queue, schedule
work on that, and flush that queue.
Thanks,
NeilBrown
>
>
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4261,6 +4261,9 @@ struct workqueue_struct *alloc_workqueue
> if ((flags & WQ_POWER_EFFICIENT) && wq_power_efficient)
> flags |= WQ_UNBOUND;
>
> + if (flags & (WQ_MEM_RECLAIM | WQ_UNBOUND) == WQ_MEM_RECLAIM)
> + flags |= WQ_CPU_INTENSIVE;
> +
> /* allocate wq and format name */
> if (flags & WQ_UNBOUND)
> tbl_size = nr_node_ids * sizeof(wq->numa_pwq_tbl[0]);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]
next prev parent reply other threads:[~2020-11-26 23:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 2:54 [PATCH rfc] workqueue: honour cond_resched() more effectively NeilBrown
2020-11-09 7:50 ` Michal Hocko
2020-11-09 8:00 ` Peter Zijlstra
2020-11-09 13:50 ` Trond Myklebust
2020-11-09 14:01 ` tj
2020-11-09 14:11 ` Trond Myklebust
2020-11-09 16:10 ` tj
2020-11-17 22:16 ` NeilBrown
[not found] ` <20201118025820.307-1-hdanton@sina.com>
2020-11-18 5:11 ` NeilBrown
[not found] ` <20201118055108.358-1-hdanton@sina.com>
2020-11-19 23:07 ` NeilBrown
2020-12-02 20:20 ` tj
[not found] ` <20201120025953.607-1-hdanton@sina.com>
2020-11-20 4:33 ` NeilBrown
[not found] ` <20201126100646.1790-1-hdanton@sina.com>
2020-11-26 23:44 ` NeilBrown [this message]
2020-11-19 23:23 ` NeilBrown
2020-11-25 12:36 ` tj
2020-11-26 23:30 ` NeilBrown
2020-11-09 14:20 ` Peter Zijlstra
2020-11-10 2:26 ` NeilBrown
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=87sg8vlm41.fsf@notabene.neil.brown.name \
--to=neilb@suse.de \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
--cc=trondmy@hammerspace.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox