From: Thomas Gleixner <tglx@linutronix.de>
To: "Vineeth Pillai (Google)" <vineeth@bitbyteword.org>,
Ben Segall <bsegall@google.com>, Borislav Petkov <bp@alien8.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
"H . Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>, Mel Gorman <mgorman@suse.de>,
Paolo Bonzini <pbonzini@redhat.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Sean Christopherson <seanjc@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Valentin Schneider <vschneid@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>
Cc: "Vineeth Pillai (Google)" <vineeth@bitbyteword.org>,
Suleiman Souhlal <suleiman@google.com>,
Masami Hiramatsu <mhiramat@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, Joel Fernandes <joel@joelfernandes.org>
Subject: Re: [RFC PATCH 8/8] irq: boost/unboost in irq/nmi entry/exit and softirq
Date: Fri, 15 Dec 2023 18:26:51 +0100 [thread overview]
Message-ID: <87zfybml5w.ffs@tglx> (raw)
In-Reply-To: <20231214024727.3503870-9-vineeth@bitbyteword.org>
On Wed, Dec 13 2023 at 21:47, Vineeth Pillai (Google) wrote:
> The host proactively boosts the VCPU threads during irq/nmi injection.
> However, the host is unaware of posted interrupts, and therefore, the
> guest should request a boost if it has not already been boosted.
>
> Similarly, guest should request an unboost on irq/nmi/softirq exit if
> the vcpu doesn't need the boost any more.
That's giving a hint but no context for someone who is not familiar with
the problem which is tried to be solved here.
> @@ -327,6 +327,13 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
> .exit_rcu = false,
> };
>
> +#ifdef CONFIG_PARAVIRT_SCHED
> + instrumentation_begin();
Slapping instrumentation_begin() at it silences the objtool checker, but
that does not make it correct in any way.
You _cannot_ call random code _before_ the kernel has established
context. It's clearly documented:
https://www.kernel.org/doc/html/latest/core-api/entry.html
No?
> + if (pv_sched_enabled())
> + pv_sched_boost_vcpu_lazy();
> + instrumentation_end();
> +#endif
> +
> if (user_mode(regs)) {
> irqentry_enter_from_user_mode(regs);
> return ret;
> @@ -452,6 +459,18 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
> if (state.exit_rcu)
> ct_irq_exit();
> }
> +
> +#ifdef CONFIG_PARAVIRT_SCHED
> + instrumentation_begin();
Broken too
> + /*
> + * On irq exit, request a deboost from hypervisor if no softirq pending
> + * and current task is not RT and !need_resched.
> + */
> + if (pv_sched_enabled() && !local_softirq_pending() &&
> + !need_resched() && !task_is_realtime(current))
> + pv_sched_unboost_vcpu();
> + instrumentation_end();
> +#endif
> }
>
> irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
> @@ -469,6 +488,11 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
> kmsan_unpoison_entry_regs(regs);
> trace_hardirqs_off_finish();
> ftrace_nmi_enter();
> +
> +#ifdef CONFIG_PARAVIRT_SCHED
> + if (pv_sched_enabled())
> + pv_sched_boost_vcpu_lazy();
> +#endif
> instrumentation_end();
>
> return irq_state;
> @@ -482,6 +506,12 @@ void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state)
> trace_hardirqs_on_prepare();
> lockdep_hardirqs_on_prepare();
> }
> +
> +#ifdef CONFIG_PARAVIRT_SCHED
> + if (pv_sched_enabled() && !in_hardirq() && !local_softirq_pending() &&
> + !need_resched() && !task_is_realtime(current))
> + pv_sched_unboost_vcpu();
> +#endif
Symmetry is overrated. Just pick a spot and slap your hackery in.
Aside of that this whole #ifdeffery is tasteless at best.
> instrumentation_end();
> +#ifdef CONFIG_PARAVIRT_SCHED
> + if (pv_sched_enabled())
> + pv_sched_boost_vcpu_lazy();
> +#endif
But what's worse is that this is just another approach of sprinkling
random hints all over the place and see what sticks.
Abusing KVM as the man in the middle to communicate between guest and
host scheduler is creative, but ill defined.
From the host scheduler POV the vCPU is just a user space thread and
making the guest special is just the wrong approach.
The kernel has no proper general interface to convey information from a
user space task to the scheduler.
So instead of adding some ad-hoc KVM hackery the right thing is to solve
this problem from ground up in a generic way and KVM can just utilize
that instead of having the special snow-flake hackery which is just a
maintainability nightmare.
Thanks,
tglx
next prev parent reply other threads:[~2023-12-15 17:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 2:47 [RFC PATCH 0/8] Dynamic vcpu priority management in kvm Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 1/8] kvm: x86: MSR for setting up scheduler info shared memory Vineeth Pillai (Google)
2023-12-14 10:53 ` Vitaly Kuznetsov
2023-12-14 19:53 ` Vineeth Remanan Pillai
2023-12-14 2:47 ` [RFC PATCH 2/8] sched/core: sched_setscheduler_pi_nocheck for interrupt context usage Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 3/8] kvm: x86: vcpu boosting/unboosting framework Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 4/8] kvm: x86: boost vcpu threads on latency sensitive paths Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 5/8] kvm: x86: upper bound for preemption based boost duration Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 6/8] kvm: x86: enable/disable global/per-guest vcpu boost feature Vineeth Pillai (Google)
2023-12-14 2:47 ` [RFC PATCH 7/8] sched/core: boost/unboost in guest scheduler Vineeth Pillai (Google)
2024-01-09 17:26 ` Shrikanth Hegde
2023-12-14 2:47 ` [RFC PATCH 8/8] irq: boost/unboost in irq/nmi entry/exit and softirq Vineeth Pillai (Google)
2023-12-15 17:26 ` Thomas Gleixner [this message]
2023-12-15 18:52 ` Vineeth Remanan Pillai
2023-12-14 16:38 ` [RFC PATCH 0/8] Dynamic vcpu priority management in kvm Sean Christopherson
2023-12-14 19:25 ` Vineeth Remanan Pillai
2023-12-14 20:13 ` Sean Christopherson
2023-12-14 21:36 ` Vineeth Remanan Pillai
2023-12-15 0:47 ` Sean Christopherson
2023-12-15 14:34 ` Vineeth Remanan Pillai
2023-12-15 16:56 ` Sean Christopherson
2023-12-15 17:40 ` Vineeth Remanan Pillai
2023-12-15 17:54 ` Sean Christopherson
2023-12-15 19:10 ` Vineeth Remanan Pillai
2023-12-15 15:20 ` Joel Fernandes
2023-12-15 16:38 ` Sean Christopherson
2023-12-15 20:18 ` Joel Fernandes
2023-12-15 22:01 ` Sean Christopherson
2024-01-12 18:37 ` Joel Fernandes
2023-12-15 18:10 ` David Vernet
2024-01-03 20:09 ` Joel Fernandes
2024-01-04 22:34 ` David Vernet
2024-01-24 2:15 ` Joel Fernandes
2024-01-24 17:06 ` David Vernet
2024-01-25 1:08 ` Joel Fernandes
2024-01-26 21:19 ` David Vernet
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=87zfybml5w.ffs@tglx \
--to=tglx@linutronix.de \
--cc=bp@alien8.de \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=hpa@zytor.com \
--cc=joel@joelfernandes.org \
--cc=juri.lelli@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mgorman@suse.de \
--cc=mhiramat@google.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=seanjc@google.com \
--cc=suleiman@google.com \
--cc=vincent.guittot@linaro.org \
--cc=vineeth@bitbyteword.org \
--cc=vkuznets@redhat.com \
--cc=vschneid@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@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