From: Andrew Morton <akpm@linux-foundation.org>
To: SeongJae Park <sj@kernel.org>
Cc: shakeelb@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] mm/damon/core: Avoid fake load reports due to uninterruptible sleeps
Date: Wed, 24 Nov 2021 13:42:10 -0800 [thread overview]
Message-ID: <20211124134210.36ae288d02fea0a95e69e2ff@linux-foundation.org> (raw)
In-Reply-To: <20211124145219.32866-1-sj@kernel.org>
On Wed, 24 Nov 2021 14:52:19 +0000 SeongJae Park <sj@kernel.org> wrote:
> Because DAMON sleeps in uninterruptible mode, /proc/loadavg reports fake
> load while DAMON is turned on, though it is doing nothing. This can
> confuse users[1]. To avoid the case, this commit makes DAMON sleeps in
> idle mode.
>
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -12,6 +12,8 @@
> #include <linux/kthread.h>
> #include <linux/mm.h>
> #include <linux/random.h>
> +#include <linux/sched.h>
> +#include <linux/sched/debug.h>
> #include <linux/slab.h>
> #include <linux/string.h>
>
> @@ -976,12 +978,25 @@ static unsigned long damos_wmark_wait_us(struct damos *scheme)
> return 0;
> }
>
> +/* sleep for @usecs in idle mode */
> +static void __sched damon_usleep_idle(unsigned long usecs)
> +{
> + ktime_t exp = ktime_add_us(ktime_get(), usecs);
> + u64 delta = usecs * NSEC_PER_USEC / 100; /* allow 1% error */
> +
> + for (;;) {
> + __set_current_state(TASK_IDLE);
> + if (!schedule_hrtimeout_range(&exp, delta, HRTIMER_MODE_ABS))
> + break;
> + }
> +}
Let's not copy-n-paste usleep_range() into damon code?
A new usleep_idle_range() in kernel/time/timer.c seems like a
worthwhile addition. Perhaps usleep_idle_range() and usleep_range()
can be static inline wrappers against a new, more general function in
kernel/time/timer.c - usleep_range_state(min, max, state)?
next prev parent reply other threads:[~2021-11-24 21:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 14:52 [PATCH] mm/damon/core: Avoid fake load reports due to uninterruptible sleeps SeongJae Park
2021-11-24 21:42 ` Andrew Morton [this message]
2021-11-25 7:49 ` SeongJae Park
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=20211124134210.36ae288d02fea0a95e69e2ff@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shakeelb@google.com \
--cc=sj@kernel.org \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).