From: tip-bot for Oleg Nesterov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, efault@gmx.de, milos@redhat.com,
linux-kernel@vger.kernel.org, tj@kernel.org,
peterz@infradead.org, hpa@zytor.com,
torvalds@linux-foundation.org, oleg@redhat.com, mingo@kernel.org,
prarit@redhat.com
Subject: [tip:sched/core] stop_machine: Clean up the usage of the preemption counter in cpu_stopper_thread()
Date: Mon, 23 Nov 2015 08:23:51 -0800 [thread overview]
Message-ID: <tip-accaf6ea3db6f5fb997f096b6eefd5431d03f7e5@git.kernel.org> (raw)
In-Reply-To: <20151115193332.GA8281@redhat.com>
Commit-ID: accaf6ea3db6f5fb997f096b6eefd5431d03f7e5
Gitweb: http://git.kernel.org/tip/accaf6ea3db6f5fb997f096b6eefd5431d03f7e5
Author: Oleg Nesterov <oleg@redhat.com>
AuthorDate: Sun, 15 Nov 2015 20:33:32 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 23 Nov 2015 09:48:20 +0100
stop_machine: Clean up the usage of the preemption counter in cpu_stopper_thread()
1. Change this code to use preempt_count_inc/preempt_count_dec; this way
it works even if CONFIG_PREEMPT_COUNT=n, and we avoid the unnecessary
__preempt_schedule() check (stop_sched_class is not preemptible).
And this makes clear that we only want to make preempt_count() != 0
for __might_sleep() / schedule_debug().
2. Change WARN_ONCE() to use %pf to print the function name and remove
kallsyms_lookup/ksym_buf.
3. Move "int ret" into the "if (work)" block, this looks more consistent.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Milos Vyletel <milos@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20151115193332.GA8281@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/stop_machine.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 7ff7ace..6110119 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -435,7 +435,6 @@ static void cpu_stopper_thread(unsigned int cpu)
{
struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
struct cpu_stop_work *work;
- int ret;
repeat:
work = NULL;
@@ -451,23 +450,19 @@ repeat:
cpu_stop_fn_t fn = work->fn;
void *arg = work->arg;
struct cpu_stop_done *done = work->done;
- char ksym_buf[KSYM_NAME_LEN] __maybe_unused;
+ int ret;
- /* cpu stop callbacks are not allowed to sleep */
- preempt_disable();
+ /* cpu stop callbacks must not sleep, make in_atomic() == T */
+ preempt_count_inc();
ret = fn(arg);
if (done) {
if (ret)
done->ret = ret;
cpu_stop_signal_done(done);
}
- /* restore preemption and check it's still balanced */
- preempt_enable();
+ preempt_count_dec();
WARN_ONCE(preempt_count(),
- "cpu_stop: %s(%p) leaked preempt count\n",
- kallsyms_lookup((unsigned long)fn, NULL, NULL, NULL,
- ksym_buf), arg);
-
+ "cpu_stop: %pf(%p) leaked preempt count\n", fn, arg);
goto repeat;
}
}
next prev parent reply other threads:[~2015-11-23 16:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-15 19:32 [PATCH 0/8] stop_machine: stop_one_cpu_nowait() fix, misc cleanups Oleg Nesterov
2015-11-15 19:33 ` [PATCH 1/8] stop_machine: cpu_stopper_thread() must check done != NULL Oleg Nesterov
2015-11-16 18:52 ` Tejun Heo
2015-11-17 17:53 ` Oleg Nesterov
2015-11-23 16:21 ` [tip:sched/core] stop_machine: Fix possible cpu_stopper_thread() crash tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 2/8] stop_machine: don't disable preemption in stop_two_cpus() Oleg Nesterov
2015-11-23 16:21 ` [tip:sched/core] stop_machine: Don' t " tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 3/8] stop_machine: make cpu_stop_queue_work() and stop_one_cpu_nowait() return bool Oleg Nesterov
2015-11-17 17:05 ` [PATCH v2 " Oleg Nesterov
2015-11-17 18:05 ` Peter Zijlstra
2015-11-23 16:22 ` [tip:sched/core] stop_machine: Make " tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 4/8] stop_machine: change stop_one_cpu() to rely on cpu_stop_queue_work() Oleg Nesterov
2015-11-23 16:22 ` [tip:sched/core] stop_machine: Change " tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 5/8] stop_machine: change __stop_cpus() " Oleg Nesterov
2015-11-23 16:22 ` [tip:sched/core] stop_machine: Change " tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 6/8] stop_machine: kill cpu_stop_done->executed Oleg Nesterov
2015-11-23 16:23 ` [tip:sched/core] stop_machine: Kill cpu_stop_done->executed tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 7/8] stop_machine: shift the done != NULL check from cpu_stop_signal_done() to callers Oleg Nesterov
2015-11-23 16:23 ` [tip:sched/core] stop_machine: Shift the 'done != NULL' " tip-bot for Oleg Nesterov
2015-11-15 19:33 ` [PATCH 8/8] stop_machine: cleanup the usage of preemption counter in cpu_stopper_thread() Oleg Nesterov
2015-11-16 19:10 ` Tejun Heo
2015-11-23 16:23 ` tip-bot for Oleg Nesterov [this message]
2015-11-16 9:43 ` [PATCH 0/8] stop_machine: stop_one_cpu_nowait() fix, misc cleanups Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-accaf6ea3db6f5fb997f096b6eefd5431d03f7e5@git.kernel.org \
--to=tipbot@zytor.com \
--cc=efault@gmx.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=milos@redhat.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=prarit@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox