From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] psi: fix aggregation idle shut-off
Date: Mon, 28 Jan 2019 17:38:43 -0500 [thread overview]
Message-ID: <20190128223843.GA2593@cmpxchg.org> (raw)
In-Reply-To: <20190128140336.25854cb97c25924f4bfc26c7@linux-foundation.org>
On Mon, Jan 28, 2019 at 02:03:36PM -0800, Andrew Morton wrote:
> On Wed, 16 Jan 2019 14:35:01 -0500 Johannes Weiner <hannes@cmpxchg.org> wrote:
> > +/**
> > + * wq_worker_last_func - retrieve worker's last work function
> > + *
> > + * Determine the last function a worker executed. This is called from
> > + * the scheduler to get a worker's last known identity.
> > + *
> > + * CONTEXT:
> > + * spin_lock_irq(rq->lock)
> > + *
> > + * Return:
> > + * The last work function %current executed as a worker, NULL if it
> > + * hasn't executed any work yet.
> > + */
> > +work_func_t wq_worker_last_func(struct task_struct *task)
> > +{
> > + struct worker *worker = kthread_data(task);
> > +
> > + return worker->last_func;
> > +}
>
> The semantics are troublesome. What guarantees that worker->last_func
> won't change under the caller's feet? The caller should hold some lock
> (presumably worker->pool->lock) in order to stabilize the
> wq_worker_last_func() return value?
>
> Also, the comment isn't really true - this is called from PSI, which is
> hardly "the scheduler"?
psi isn't scheduler core, but it only works from a scheduler context.
The psi task change hook already requires being called under the
rq->lock while the task in question cannot change its scheduling
state, to record it and start the clock on the new state.
That same context ensures wq_worker_last_func() is safe. We're using
it from where the worker is inside the scheduler and going to *sleep*
(not just preemption), so couldn't possibly be changing last_func.
So IMO it makes sense to keep this last_func thing a part of the
private API between scheduler context and the workqueue code.
next prev parent reply other threads:[~2019-01-28 22:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 19:35 [PATCH] psi: fix aggregation idle shut-off Johannes Weiner
2019-01-16 20:59 ` Suren Baghdasaryan
2019-01-28 22:03 ` Andrew Morton
2019-01-28 22:20 ` Suren Baghdasaryan
2019-01-28 22:38 ` Johannes Weiner [this message]
2019-01-28 22:59 ` Tejun Heo
2019-01-28 23:01 ` Tejun Heo
2019-01-28 23:06 ` Andrew Morton
2019-01-28 23:10 ` Suren Baghdasaryan
2019-02-06 2:50 ` Suren Baghdasaryan
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=20190128223843.GA2593@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=surenb@google.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.