Skip to content

Commit

Permalink
kexec: Introduce kexec_with_frozen_processes
Browse files Browse the repository at this point in the history
Drivers running .shutdown() might want to wait for userspace to complete
before exiting.

If userspace is frozen and we are running kexec they will stall the
computer.

Add a way for them to figure out if they should just skip waiting for
userspace.

Cc: stable@vger.kernel.org
Fixes: 83bfc7e ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
  • Loading branch information
ribalda authored and intel-lab-lkp committed Nov 30, 2022
1 parent 4312098 commit ddb7195
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/linux/kexec.h
Expand Up @@ -426,6 +426,8 @@ extern int kexec_load_disabled;
/* flag to track if kexec reboot is in progress */
extern bool kexec_in_progress;

bool kexec_with_frozen_processes(void);

int crash_shrink_memory(unsigned long new_size);
ssize_t crash_get_memory_size(void);

Expand Down Expand Up @@ -507,6 +509,7 @@ static inline void __crash_kexec(struct pt_regs *regs) { }
static inline void crash_kexec(struct pt_regs *regs) { }
static inline int kexec_should_crash(struct task_struct *p) { return 0; }
static inline int kexec_crash_loaded(void) { return 0; }
static inline bool kexec_with_frozen_processes(void) { return false; }
#define kexec_in_progress false
#endif /* CONFIG_KEXEC_CORE */

Expand Down
5 changes: 5 additions & 0 deletions kernel/kexec_core.c
Expand Up @@ -54,6 +54,11 @@ note_buf_t __percpu *crash_notes;
/* Flag to indicate we are going to kexec a new kernel */
bool kexec_in_progress = false;

bool kexec_with_frozen_processes(void)
{
return kexec_in_progress && pm_freezing;
}
EXPORT_SYMBOL(kexec_with_frozen_processes);

/* Location of the reserved area for the crash kernel */
struct resource crashk_res = {
Expand Down

0 comments on commit ddb7195

Please sign in to comment.