[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386076887-2655-3-git-send-email-pmladek@suse.cz>
Date: Tue, 3 Dec 2013 14:21:21 +0100
From: Petr Mladek <pmladek@...e.cz>
To: Steven Rostedt <rostedt@...dmis.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Jiri Kosina <jkosina@...e.cz>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
Petr Mladek <pmladek@...e.cz>
Subject: [PATCH v5 2/8] x86: allow to call text_poke_bp during boot
We would like to use text_poke_bp in ftrace. It might be called also during
boot when there is only one CPU and we do not need to sync the others.
The check is must to have because there are also disabled interrupts during
the boot. Then the call would cause a deadlock, see the warning in
"smp_call_function_many", kernel/smp.c:371.
The change is inspired by the code in arch/x86/kernel/ftrace.c.
Signed-off-by: Petr Mladek <pmladek@...e.cz>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
---
arch/x86/kernel/alternative.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 10a7ec0c66f9..2e47107b9055 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -602,6 +602,17 @@ static void do_sync_core(void *info)
sync_core();
}
+static void run_sync(void)
+{
+ /*
+ * We do not need to sync other cores during boot when there is only one
+ * CPU enabled. In fact, we must not because there are also disabled
+ * interrupts. The call would fail because of a potential deadlock.
+ */
+ if (num_online_cpus() != 1)
+ on_each_cpu(do_sync_core, NULL, 1);
+}
+
static bool bp_patching_in_progress;
static void *bp_int3_handler, *bp_int3_addr;
@@ -664,7 +675,7 @@ int text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
if (unlikely(ret))
goto fail;
- on_each_cpu(do_sync_core, NULL, 1);
+ run_sync();
if (len - sizeof(int3) > 0) {
/* patch all but the first byte */
@@ -677,14 +688,14 @@ int text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
* not necessary and we'd be safe even without it. But
* better safe than sorry (plus there's not only Intel).
*/
- on_each_cpu(do_sync_core, NULL, 1);
+ run_sync();
}
/* patch the first byte */
ret = text_poke(addr, opcode, sizeof(int3));
BUG_ON(ret);
- on_each_cpu(do_sync_core, NULL, 1);
+ run_sync();
fail:
bp_patching_in_progress = false;
--
1.8.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists