From: Tejun Heo <tj@kernel.org>
To: Valentin Schneider <vschneid@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <frederic@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>, Phil Auld <pauld@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH v4 3/4] workqueue: Convert the idle_timer to a delayed_work
Date: Mon, 31 Oct 2022 08:49:16 -1000 [thread overview]
Message-ID: <Y2AYrG8q+I3VhHoF@slm.duckdns.org> (raw)
In-Reply-To: <20221004150521.822266-4-vschneid@redhat.com>
Hello,
On Tue, Oct 04, 2022 at 04:05:20PM +0100, Valentin Schneider wrote:
> +static void idle_reaper_fn(struct work_struct *work)
> {
> - struct worker_pool *pool = from_timer(pool, t, idle_timer);
> + struct delayed_work *dwork = to_delayed_work(work);
> + struct worker_pool *pool = container_of(dwork, struct worker_pool, idle_reaper_work);
>
> raw_spin_lock_irq(&pool->lock);
>
> while (too_many_workers(pool)) {
> struct worker *worker;
> unsigned long expires;
> + unsigned long now = jiffies;
>
> - /* idle_list is kept in LIFO order, check the last one */
> + /* idle_list is kept in LIFO order, check the oldest entry */
> worker = list_entry(pool->idle_list.prev, struct worker, entry);
> expires = worker->last_active + IDLE_WORKER_TIMEOUT;
>
> - if (time_before(jiffies, expires)) {
> - mod_timer(&pool->idle_timer, expires);
So, one thing which bothers me is that the idle timer is supposed to go off
spuriously periodically. The idea being that letting it expire spuriously
should usually be cheaper than trying to update it constantly as workers
wake up and sleep. Converting the timer to a delayed work makes spurious
wakeups significantly more expensive tho as it's now a full scheduling
event.
Can we separate the timer and work item out so that we can kick off the work
item iff there actually are tasks to kill?
Thanks.
--
tejun
next prev parent reply other threads:[~2022-10-31 18:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 15:05 [PATCH v4 0/4] workqueue: destroy_worker() vs isolated CPUs Valentin Schneider
2022-10-04 15:05 ` [PATCH v4 1/4] workqueue: Protects wq_unbound_cpumask with wq_pool_attach_mutex Valentin Schneider
2022-10-04 15:05 ` [PATCH v4 2/4] workqueue: Factorize unbind/rebind_workers() logic Valentin Schneider
2022-10-04 15:05 ` [PATCH v4 3/4] workqueue: Convert the idle_timer to a delayed_work Valentin Schneider
2022-10-31 18:49 ` Tejun Heo [this message]
2022-11-02 17:13 ` Valentin Schneider
2022-10-04 15:05 ` [PATCH v4 4/4] workqueue: Unbind workers before sending them to exit() Valentin Schneider
[not found] ` <20221005010832.1934-1-hdanton@sina.com>
2022-10-05 11:13 ` Valentin Schneider
[not found] ` <20221005145022.1695-1-hdanton@sina.com>
2022-10-05 16:14 ` Valentin Schneider
2022-10-25 9:42 ` [PATCH v4 0/4] workqueue: destroy_worker() vs isolated CPUs Valentin Schneider
2022-10-31 18:45 ` Tejun Heo
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=Y2AYrG8q+I3VhHoF@slm.duckdns.org \
--to=tj@kernel.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pauld@redhat.com \
--cc=peterz@infradead.org \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®