Re: [PATCHv4 14/14] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

From: kirill.shutemov@xxxxxxxxxxxxxxx
Date: Fri Dec 22 2023 - 06:20:02 EST


On Tue, Dec 05, 2023 at 11:36:55PM +0000, Huang, Kai wrote:
>
> > +
> > +static void acpi_mp_stop_other_cpus(int wait)
> > +{
> > + smp_shutdown_nonboot_cpus(smp_processor_id());
> > +}
>
> Is this and ...
>
> + smp_ops.stop_other_cpus = acpi_mp_stop_other_cpus;
>
> ... this below still needed?
>
> I think the current native_stop_other_cpus() should just work given you have set
> up ...
>
> + smp_ops.crash_play_dead = crash_acpi_mp_play_dead;
>
> ... for TDX guest?

To make it work stop_this_cpu() would need to be modified to use
smp_ops.crash_play_dead() instead of native_halt(). But name of the
callback doesn't match the function, so I renamed it to
smp_ops.stop_this_cpu().

> Sorry for saying this late. I think we can also use kernel_ident_mapping_init()
> to do the init_transition_pgtable()? We can set struct x86_mapping_info::offset
> to __PAGE_OFFSET to do that?
>
> Looks set_up_temporary_mappings() in arch/x86/power/hibernate_64.c uses the same
> trick.
>
> Anyway I am not sure how many LoC (assuming can do) can be saved so up to you.

Yeah. Benefit is not clear to me. I will leave it as is.


>
> It's a little bit sad such cleanup code isn't in common code, e.g., with a
>
> void (*free_pgt_page)(void *);
>
> to allow the user to specify how to free the page table.
>
> But this can be future job if needed.

I will consider moving this cleanup in common code. And maybe fix other
users of kernel_ident_mapping_init(). Nobody seems to care to cleanup page
tables on ENOMEM.

--
Kiryl Shutsemau / Kirill A. Shutemov