From: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
Dexuan Cui <decui@microsoft.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: RE: [PATCH 1/1] clocksource: hyper-v: Rework clocksource and sched clock setup
Date: Mon, 19 Jun 2023 16:44:47 +0000 [thread overview]
Message-ID: <BYAPR21MB1688E1163BB36DF03CC8E00BD75FA@BYAPR21MB1688.namprd21.prod.outlook.com> (raw)
In-Reply-To: <fdc643c4-6298-d337-1d8d-3f28f6c1acfc@linaro.org>
From: Daniel Lezcano <daniel.lezcano@linaro.org> Sent: Monday, June 19, 2023 9:16 AM
>
> On 09/06/2023 17:47, Michael Kelley wrote:
> > Current code assigns either the Hyper-V TSC page or MSR-based ref counter
> > as the sched clock. This may be sub-optimal in two cases. First, if there
> > is hardware support to ensure consistent TSC frequency across live
> > migrations and Hyper-V is using that support, the raw TSC is a faster
> > source of time than the Hyper-V TSC page. Second, the MSR-based ref
> > counter is relatively slow because reads require a trap to the hypervisor.
> > As such, it should never be used as the sched clock. The native sched
> > clock based on the raw TSC or jiffies is much better.
> >
> > Rework the sched clock setup so it is set to the TSC page only if
> > Hyper-V indicates that the TSC may have inconsistent frequency across
> > live migrations. Also, remove the code that sets the sched clock to
> > the MSR-based ref counter. In the cases where it is not set, the sched
> > clock will then be the native sched clock.
> >
> > As part of the rework, always enable both the TSC page clocksource and
> > the MSR-based ref counter clocksource. Set the ratings so the TSC page
> > clocksource is preferred. While the MSR-based ref counter clocksource
> > is unlikely to ever be the default, having it available for manual
> > selection is convenient for development purposes.
> >
> > Signed-off-by: Michael Kelley <mikelley@microsoft.com>
>
> The patch does not apply, does it depend on another patch?
It should apply to linux-next. It depends on two previous patches from
Peter Zijlstra in the sched/core branch of tip. See:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=sched/core&id=9397fa2ea3e7634f61da1ab76b9eb88ba04dfdfc
and
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=sched/core&id=e39acc37db34f6688e2c16e958fb1d662c422c81
Michael
>
> Rejected chunk:
>
> --- drivers/clocksource/hyperv_timer.c
> +++ drivers/clocksource/hyperv_timer.c
> @@ -485,15 +485,9 @@ static u64 notrace read_hv_clock_msr_cs(struct
> clocksource *arg)
> return read_hv_clock_msr();
> }
>
> -static u64 noinstr read_hv_sched_clock_msr(void)
> -{
> - return (read_hv_clock_msr() - hv_sched_clock_offset) *
> - (NSEC_PER_SEC / HV_CLOCK_HZ);
> -}
> -
> static struct clocksource hyperv_cs_msr = {
> .name = "hyperv_clocksource_msr",
> - .rating = 500,
> + .rating = 495,
> .read = read_hv_clock_msr_cs,
> .mask = CLOCKSOURCE_MASK(64),
> .flags = CLOCK_SOURCE_IS_CONTINUOUS,
>
>
> --
next prev parent reply other threads:[~2023-06-19 16:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 15:47 [PATCH 1/1] clocksource: hyper-v: Rework clocksource and sched clock setup Michael Kelley
2023-06-15 5:15 ` Dexuan Cui
2023-06-19 16:16 ` Daniel Lezcano
2023-06-19 16:44 ` Michael Kelley (LINUX) [this message]
2023-06-19 16:58 ` Daniel Lezcano
2023-06-19 17:41 ` Michael Kelley (LINUX)
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=BYAPR21MB1688E1163BB36DF03CC8E00BD75FA@BYAPR21MB1688.namprd21.prod.outlook.com \
--to=mikelley@microsoft.com \
--cc=daniel.lezcano@linaro.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=wei.liu@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 read-only IMAP folder(s) and NNTP newsgroup(s).