From: Johannes Weiner <hannes@cmpxchg.org>
To: Brian Chen <brianchen118@gmail.com>
Cc: brianc118@fb.com, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] psi: fix PSI_MEM_FULL state when tasks are in memstall and doing reclaim
Date: Fri, 12 Nov 2021 11:53:20 -0500 [thread overview]
Message-ID: <YY6cAFtHOhw2zEc7@cmpxchg.org> (raw)
In-Reply-To: <20211110213312.310243-1-brianchen118@gmail.com>
On Wed, Nov 10, 2021 at 09:33:12PM +0000, Brian Chen wrote:
> We've noticed cases where tasks in a cgroup are stalled on memory but
> there is little memory FULL pressure since tasks stay on the runqueue
> in reclaim.
>
> A simple example involves a single threaded program that keeps leaking
> and touching large amounts of memory. It runs in a cgroup with swap
> enabled, memory.high set at 10M and cpu.max ratio set at 5%. Though
> there is significant CPU pressure and memory SOME, there is barely any
> memory FULL since the task enters reclaim and stays on the runqueue.
> However, this memory-bound task is effectively stalled on memory and
> we expect memory FULL to match memory SOME in this scenario.
>
> The code is confused about memstall && running, thinking there is a
> stalled task and a productive task when there's only one task: a
> reclaimer that's counted as both. To fix this, we redefine the
> condition for PSI_MEM_FULL to check that all running tasks are in an
> active memstall instead of checking that there are no running tasks.
>
> case PSI_MEM_FULL:
> - return unlikely(tasks[NR_MEMSTALL] && !tasks[NR_RUNNING]);
> + return unlikely(tasks[NR_MEMSTALL] &&
> + tasks[NR_RUNNING] == tasks[NR_MEMSTALL_RUNNING]);
>
> This will capture reclaimers. It will also capture tasks that called
> psi_memstall_enter() and are about to sleep, but this should be
> negligible noise.
>
> Signed-off-by: Brian Chen <brianchen118@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
This bug essentially causes us to count memory-some in walltime and
memory-full in tasktime, which can be quite confusing and misleading
in combined CPU and memory pressure situations.
The fix looks good to me, thanks Brian.
The bug's been there since the initial psi commit, so I don't think a
stable backport is warranted.
Peter, absent objections, can you please pick this up through -tip?
next prev parent reply other threads:[~2021-11-12 16:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 21:33 [PATCH] psi: fix PSI_MEM_FULL state when tasks are in memstall and doing reclaim Brian Chen
2021-11-12 16:53 ` Johannes Weiner [this message]
2021-11-13 7:39 ` Peter Zijlstra
2021-11-17 13:59 ` [tip: sched/core] psi: Fix " tip-bot2 for Brian Chen
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=YY6cAFtHOhw2zEc7@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=brianc118@fb.com \
--cc=brianchen118@gmail.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox