[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4] x86/mwait-idle: re-order state entry/exit code a little
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 22 Feb 2022 10:08:12 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/dS/IeSJ8DSlTMyCGhRUeFVmOB5eHgZdLu+OSOPyKhU=; b=oUG8iRGAPRsoNo0RtNQhKnDFoqfBSU6Odl/xw/Uav6cw44aj6qj2hxwqAPHah1BDp5T1BwyR1C8sOjbOhFjBtRS+0H1diP/ZKmenRhu0exa2txFpFI/zjVSgj3ijbpj8jtCqpeO7HLZFsAru0FwLty0oJJAQvrSic/4kBwtViJxoGTRODp8uICgj27vUoF1e22V6KYXCc8362j7dSCIdM5QD38c6cK3zT3AV6F3PKW+HOBX/M4ZAoseXj+mpnS9Xp/m+ODaxXjMljcvYdXcN29hwJjaF6cL8+KjpMSMT2IcSVfr2QBMd3LjJZhrj/FsX8u2SkOT9Mplko5Q7y1/W8A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4Gb189I0O7cSnk6YGFQE79K/I8ebJXuI8erlv8XnhrJ/fgoUx1rvRXWsem2sgtFy92LoK/i83RLmI9yfpOCe2aZBgJ/XgnG8Gv8DcFPOYe4xa26LKWLZ2wo+iacsBj9QD4H2NjSmVmmSNPGpO4jwk6UMcOioPUbmyKsOEZMsV3k6AUJgwoKsYMWtmHH4vkB5v6xeapznw39OyxEFFIR/wBxpiT8W/7JHlDeFOeYZd0U9f36EUKgG0m/PMr288pFQD5hsigHYw8W2583V3lKOk9loWtgyA78Nlocz4QzZQvgnZevP5E4ZC6yPOR/SspY/5+KNIbwO8Qb4fh5zAagOQ==
- Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 22 Feb 2022 09:08:31 +0000
- Ironport-data: A9a23:fy0KR6wWNQwpTpPDbLh6t+cgxirEfRIJ4+MujC+fZmUNrF6WrkUFz zEcWDjQOfuONGb8ed4kPYu3/R8H68TXmtAyQAdkryAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnj/0bv656yMUOZigHtIQMsadUsxKbVIiGHdJZS5LwbZj2NYy24LhWWthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NplqZGxVVx4Hvb2xr47a0B6DhljJIhvweqSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY2J4fQK2FN 5JxhTxHTC2RewRWC20sJsgisO2MpnLFdA0JpwfAzUYwyzeKl1EguFT3C/LKfvSaSMMTmVyXz krW8mK8DhwEOdi3zTue7mnqluLJhTn8Wo8ZCPu/7PECqF+Zy3EXCRYWfUCmuvT/gUm7M++zM GRNpHBo9/JrshX2EJ+tBHVUvUJooDYAVttMSLwaszvTkIzsuiSEPnUdaxd4PYlOWNANeRQm0 V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PlHb21LtBPB5ryw6SHlYndotvaPKA18A==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Fri, Feb 18, 2022 at 09:35:10AM +0100, Jan Beulich wrote:
> The initial observation is that unlike the original ACPI idle driver we
> have a 2nd cpu_is_haltable() in here. By making the actual state entry
> conditional, the emitted trace records as well as the subsequent stats
> update are at least misleading in case the state wasn't actually entered.
> Hence they would want moving inside the conditional. At which point the
> cpuidle_get_tick() invocations could (and hence should) move as well.
> cstate_restore_tsc() also isn't needed if we didn't actually enter the
> state.
>
> This leaves only the errata_c6_workaround() and lapic_timer_off()
> invocations outside the conditional. As a result it looks easier to
> drop the conditional (and come back in sync with the other driver again)
> than to move almost everything into the conditional.
>
> While there also move the TRACE_6D() out of the IRQ-disabled region.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Moving the TRACE_6D() may be a little controversial, as this could lead
> to a sequence of trace records not actually representing the sequence of
> events, in case further records get emitted by interrupt handlers. But
> with us now conditionally enabling interrupts around MWAIT, that issue
> exists already anyway.
I think that's OK. We have to priority interrupt latency over trace
readability.
> Unlike said in the earlier outline of the alternative approach,
> errata_c6_workaround() cannot be moved: cpu_has_pending_apic_eoi() needs
> to be called when IRQs are already off.
> ---
> v4: Different approach (and title), as was previously outlined as an
> alternative.
> v3: Also move cstate_restore_tsc() invocation and split ones to
> update_idle_stats().
> v2: New.
>
> --- a/xen/arch/x86/cpu/mwait-idle.c
> +++ b/xen/arch/x86/cpu/mwait-idle.c
> @@ -847,26 +847,25 @@ static void mwait_idle(void)
>
> update_last_cx_stat(power, cx, before);
>
> - if (cpu_is_haltable(cpu)) {
> - if (cx->irq_enable_early)
> - local_irq_enable();
> + if (cx->irq_enable_early)
> + local_irq_enable();
Now that I look at this again, we need to be careful with the enabling
interrupts and the interaction with errata_c6_workaround. Enabling
interrupts here could change the result of the check for pending EOIs,
and thus enter mwait with a condition that could trigger the erratas.
Hopefully CPUIDLE_FLAG_IRQ_ENABLE is only set for C1.
It might be prudent to only allow setting CPUIDLE_FLAG_IRQ_ENABLE for
states <= 2.
Thanks, Roger.
|