Skip to content

Commit 758dfdb

Browse files
guilhermepiccolirichardweinberger
authored andcommitted
um: Improve panic notifiers consistency and ordering
Currently the panic notifiers from user mode linux don't follow the convention for most of the other notifiers present in the kernel (indentation, priority setting, numeric return). More important, the priorities could be improved, since it's a special case (userspace), hence we could run the notifiers earlier; user mode linux shouldn't care much with other panic notifiers but the ordering among the mconsole and arch notifier is important, given that the arch one effectively triggers a core dump. Fix that by running the mconsole notifier as the first panic notifier, followed by the architecture one (that coredumps). Cc: Anton Ivanov <[email protected]> Cc: Johannes Berg <[email protected]> Cc: Richard Weinberger <[email protected]> Signed-off-by: Guilherme G. Piccoli <[email protected]> V3: - No changes. V2: - Kept the notifier header to avoid implicit usage - thanks Johannes for the suggestion! Signed-off-by: Richard Weinberger <[email protected]>
1 parent c8b2c26 commit 758dfdb

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

arch/um/drivers/mconsole_kern.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,13 +846,12 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1,
846846

847847
mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
848848
strlen(message) + 1);
849-
return 0;
849+
return NOTIFY_DONE;
850850
}
851851

852852
static struct notifier_block panic_exit_notifier = {
853-
.notifier_call = notify_panic,
854-
.next = NULL,
855-
.priority = 1
853+
.notifier_call = notify_panic,
854+
.priority = INT_MAX, /* run as soon as possible */
856855
};
857856

858857
static int add_notifier(void)

arch/um/kernel/um_arch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ static int panic_exit(struct notifier_block *self, unsigned long unused1,
247247
bust_spinlocks(0);
248248
uml_exitcode = 1;
249249
os_dump_core();
250-
return 0;
250+
251+
return NOTIFY_DONE;
251252
}
252253

253254
static struct notifier_block panic_exit_notifier = {
254-
.notifier_call = panic_exit,
255-
.next = NULL,
256-
.priority = 0
255+
.notifier_call = panic_exit,
256+
.priority = INT_MAX - 1, /* run as 2nd notifier, won't return */
257257
};
258258

259259
void uml_finishsetup(void)

0 commit comments

Comments
 (0)