irqchip/gic-v3-its: Postpone LPI pending table freeing and memreserve
commit eba1e44b upstream Memory used by the LPI tables have to be made persistent for kexec to have a chance to work, as explained in [1]. If they have been made persistent and we are booting into a kexec'd kernel, we also need to free the pages that were preemptively allocated by the new kernel for those tables. Both of those operations currently happen during its_cpu_init(), which happens in a _STARTING (IOW atomic) cpuhp callback for secondary CPUs. efi_mem_reserve_iomem() issues a GFP_ATOMIC allocation, which unfortunately doesn't work under PREEMPT_RT (this ends up grabbing a non-raw spinlock, which can sleep under PREEMPT_RT). Similarly, freeing the pages ends up grabbing a sleepable spinlock. Since the memreserve is only required by kexec, it doesn't have to be done so early in the secondary boot process. Issue the reservation in a new CPUHP_AP_ONLINE_DYN cpuhp callback, and piggy-back the page freeing on top of it. A CPU gets to run the body of this new callback exactly once. As kexec issues a machine_shutdown() prior to machine_kexec(), it will be serialized vs a CPU being plugged to life by the hotplug machinery - either the CPU will have been brought up and have had its redistributor's pending table memreserved, or it never went online and will have its table allocated by the new kernel. [1]: https://lore.kernel.org/lkml/20180921195954.21574-1-marc.zyngier@arm.com/ Stable backport notes: When rt kernel boots up, there is below calltrace BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:969 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/1 Preemption disabled at: [<ffff800010089c14>] migrate_enable+0x44/0x1c8 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.10.140-rt73-yocto-preempt-rt #3 Hardware name: LS1028A RDB Board (DT) Call trace: dump_backtrace+0x0/0x1e0 show_stack+0x2c/0x38 dump_stack+0xcc/0x104 ___might_sleep+0x10c/0x178 rt_spin_lock+0x2c/0x88 __free_pages_ok+0x170/0x590 __free_pages+0xcc/0xe8 free_pages.part.123+0x3c/0x48 free_pages+0x2c/0x38 its_free_pending_table+0x68/0x78 its_cpu_init+0x7c8/0xa78 gic_starting_cpu+0x24/0x38 cpuhp_invoke_callback+0xb8/0x890 notify_cpu_starting+0xa8/0xe0 secondary_start_kernel+0x138/0x1d0 In latest mainline kernel, this patch improved the LPI pending table freeing and memreserve strategy, and also fix the calltrace issue. Therefore, backport it and its fixing patches to stable kernel v5.15. Signed-off-by: Valentin Schneider <valentin.schneider@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20211027151506.2085066-3-valentin.schneider@arm.com Cc: stable@vger.kernel.org Signed-off-by: Meng Li <Meng.Li@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
parent
1fa94473
Please register or sign in to comment