From: Ingo Molnar <mingo@kernel.org>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
Wanpeng Li <wanpengli@tencent.com>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Rik van Riel <riel@surriel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Yauheni Kaliuta <yauheni.kaliuta@redhat.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH 1/6] sched/cputime: Support other fields on kcpustat_field()
Date: Wed, 20 Nov 2019 12:51:42 +0100 [thread overview]
Message-ID: <20191120115142.GA89662@gmail.com> (raw)
In-Reply-To: <20191119232218.4206-2-frederic@kernel.org>
* Frederic Weisbecker <frederic@kernel.org> wrote:
> Provide support for user, nice, guest and guest_nice fields through
> kcpustat_field().
>
> Whether we account the delta to a nice or not nice field is decided on
> top of the nice value snapshot taken at the time we call kcpustat_field().
> If the nice value of the task has been changed since the last vtime
> update, we may have inacurrate distribution of the nice VS unnice
> cputime.
>
> However this is considered as a minor issue compared to the proper fix
> that would involve interrupting the target on nice updates, which is
> undesired on nohz_full CPUs.
>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Wanpeng Li <wanpengli@tencent.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> ---
> kernel/sched/cputime.c | 53 +++++++++++++++++++++++++++++++++---------
> 1 file changed, 42 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index e0cd20693ef5..b2cf544e2109 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -912,11 +912,21 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
> } while (read_seqcount_retry(&vtime->seqcount, seq));
> }
>
> +static u64 kcpustat_user_vtime(struct vtime *vtime)
> +{
> + if (vtime->state == VTIME_USER)
> + return vtime->utime + vtime_delta(vtime);
> + else if (vtime->state == VTIME_GUEST)
> + return vtime->gtime + vtime_delta(vtime);
> + return 0;
> +}
> +
> static int kcpustat_field_vtime(u64 *cpustat,
> - struct vtime *vtime,
> + struct task_struct *tsk,
> enum cpu_usage_stat usage,
> int cpu, u64 *val)
> {
> + struct vtime *vtime = &tsk->vtime;
> unsigned int seq;
> int err;
>
> @@ -946,9 +956,36 @@ static int kcpustat_field_vtime(u64 *cpustat,
>
> *val = cpustat[usage];
>
> - if (vtime->state == VTIME_SYS)
> - *val += vtime->stime + vtime_delta(vtime);
> -
> + /*
> + * Nice VS unnice cputime accounting may be inaccurate if
> + * the nice value has changed since the last vtime update.
> + * But proper fix would involve interrupting target on nice
> + * updates which is a no go on nohz_full.
Well, we actually already interrupt the target in both sys_nice() and
sys_setpriority() etc. syscall variants: we call set_user_nice() which
calls resched_curr() and the task is sent an IPI and runs through a
reschedule.
But ... I do agree that this kind of granularity of nice/non-nice
accounting doesn't really matter in practice: the changing of nice values
is a relatively low frequency operation on most systems.
But nevertheless the comment should probably be updated to reflect this.
Thanks,
Ingo
next prev parent reply other threads:[~2019-11-20 11:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 23:22 [PATCH 0/6] sched/nohz: Make the rest of kcpustat vtime aware v2 Frederic Weisbecker
2019-11-19 23:22 ` [PATCH 1/6] sched/cputime: Support other fields on kcpustat_field() Frederic Weisbecker
2019-11-20 11:51 ` Ingo Molnar [this message]
2019-11-20 21:04 ` Peter Zijlstra
2019-11-19 23:22 ` [PATCH 2/6] sched/vtime: Bring all-in-one kcpustat accessor for vtime fields Frederic Weisbecker
2019-11-20 12:04 ` Ingo Molnar
2019-11-20 15:00 ` Frederic Weisbecker
2019-11-19 23:22 ` [PATCH 3/6] procfs: Use all-in-one vtime aware kcpustat accessor Frederic Weisbecker
2019-11-19 23:22 ` [PATCH 4/6] cpufreq: Use vtime aware kcpustat accessors for user time Frederic Weisbecker
2019-11-19 23:22 ` [PATCH 5/6] leds: Use all-in-one vtime aware kcpustat accessor Frederic Weisbecker
2019-11-19 23:22 ` [PATCH 6/6] rackmeter: Use " Frederic Weisbecker
-- strict thread matches above, loose matches on Subject: below --
2019-11-21 2:44 [PATCH 0/6] sched/nohz: Make the rest of kcpustat vtime aware v3 Frederic Weisbecker
2019-11-21 2:44 ` [PATCH 1/6] sched/cputime: Support other fields on kcpustat_field() Frederic Weisbecker
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=20191120115142.GA89662@gmail.com \
--to=mingo@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=frederic@kernel.org \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=viresh.kumar@linaro.org \
--cc=wanpengli@tencent.com \
--cc=yauheni.kaliuta@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 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.