Commit 6b53022d authored by Stéphane Eranian's avatar Stéphane Eranian Committed by David Mosberger

[PATCH] ia64: fix perfmon bug that could result in kernel hang

This patch fixes a potential kernel hang in perfmon during
PFM_UNLOAD_CONTEXT.  This commands requires that the monitored task be
stopped (except when self-monitoring). The task state tests in
check_task_state() were incorrect and an actively running task was
accepted for PFM_UNLOAD_CONTEXT. This eventually leads to a kernel
hang.
Signed-off-by: default avatarStephane Eranian <eranian@hpl.hp.com>
Signed-off-by: default avatarDavid Mosberger <davidm@hpl.hp.com>
parent d971b2bf
...@@ -4728,6 +4728,11 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags) ...@@ -4728,6 +4728,11 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
*/ */
if (task == current || ctx->ctx_fl_system) return 0; if (task == current || ctx->ctx_fl_system) return 0;
/*
* if context is UNLOADED we are safe to go
*/
if (state == PFM_CTX_UNLOADED) return 0;
/* /*
* no command can operate on a zombie context * no command can operate on a zombie context
*/ */
...@@ -4737,12 +4742,9 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags) ...@@ -4737,12 +4742,9 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
} }
/* /*
* if context is UNLOADED, MASKED we are safe to go * context is LOADED or MASKED. Some commands may need to have
*/ * the task stopped.
if (state != PFM_CTX_LOADED) return 0; *
/*
* context is LOADED, we must make sure the task is stopped
* We could lift this restriction for UP but it would mean that * We could lift this restriction for UP but it would mean that
* the user has no guarantee the task would not run between * the user has no guarantee the task would not run between
* two successive calls to perfmonctl(). That's probably OK. * two successive calls to perfmonctl(). That's probably OK.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment