From: Jiri Slaby <jslaby@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, rostedt@goodmis.org, mingo@redhat.com,
akpm@linux-foundation.org, andi@firstfloor.org,
paulmck@linux.vnet.ibm.com, pavel@ucw.cz, jirislaby@gmail.com,
Vojtech Pavlik <vojtech@suse.cz>, Michael Matz <matz@suse.de>,
Jiri Kosina <jkosina@suse.cz>, Jiri Slaby <jslaby@suse.cz>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH -repost 10/21] kgr: kthreads support
Date: Wed, 25 Jun 2014 13:07:04 +0200 [thread overview]
Message-ID: <1403694435-3180-10-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1403694435-3180-1-git-send-email-jslaby@suse.cz>
Wake up kthreads so that they cycle through kgr_task_safe either
by an explicit call to it or implicitly via try_to_freeze. This
ensures nobody should use the old version of the code and kgraft core
can push everybody to use the new version by switching to the fast
path.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
---
kernel/kgraft.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/kernel/kgraft.c b/kernel/kgraft.c
index b0c712e8297c..d21eaad8d48d 100644
--- a/kernel/kgraft.c
+++ b/kernel/kgraft.c
@@ -53,7 +53,7 @@ static void kgr_stub_slow(unsigned long ip, unsigned long parent_ip,
{
struct kgr_loc_caches *c = ops->private;
- if (kgr_task_in_progress(current) && current->mm) {
+ if (kgr_task_in_progress(current)) {
pr_info("kgr: slow stub: calling old code at %lx\n",
c->old);
kgr_set_regs_ip(regs, c->old + MCOUNT_INSN_SIZE);
@@ -71,11 +71,7 @@ static bool kgr_still_patching(void)
read_lock(&tasklist_lock);
for_each_process(p) {
- /*
- * TODO
- * kernel thread codepaths not supported and silently ignored
- */
- if (kgr_task_in_progress(p) && p->mm) {
+ if (kgr_task_in_progress(p)) {
pr_info("pid %d (%s) still in kernel after timeout\n",
p->pid, p->comm);
failed = true;
@@ -123,13 +119,23 @@ static void kgr_work_fn(struct work_struct *work)
mutex_unlock(&kgr_in_progress_lock);
}
-static void kgr_mark_processes(void)
+static void kgr_handle_processes(void)
{
struct task_struct *p;
read_lock(&tasklist_lock);
- for_each_process(p)
+ for_each_process(p) {
kgr_mark_task_in_progress(p);
+
+ /* wake up kthreads, they will clean the progress flag */
+ if (!p->mm) {
+ /*
+ * this is incorrect for kthreads waiting still for
+ * their first wake_up.
+ */
+ wake_up_process(p);
+ }
+ }
read_unlock(&tasklist_lock);
}
@@ -274,8 +280,7 @@ static int kgr_patch_code(const struct kgr_patch_fun *patch_fun, bool final)
* kgr_start_patching -- the entry for a kgraft patch
* @patch: patch to be applied
*
- * Start patching of code that is neither running in IRQ context nor
- * kernel thread.
+ * Start patching of code that is not running in IRQ context.
*/
int kgr_start_patching(const struct kgr_patch *patch)
{
@@ -314,7 +319,7 @@ int kgr_start_patching(const struct kgr_patch *patch)
kgr_patch = patch;
mutex_unlock(&kgr_in_progress_lock);
- kgr_mark_processes();
+ kgr_handle_processes();
/*
* give everyone time to exit kernel, and check after a while
--
2.0.0
next prev parent reply other threads:[~2014-06-25 11:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 11:06 [PATCH -repost 01/21] ftrace: Add function to find fentry of function Jiri Slaby
2014-06-25 11:06 ` [PATCH -repost 02/21] ftrace: Make ftrace_is_dead available globally Jiri Slaby
2014-06-25 11:06 ` [PATCH -repost 03/21] kgr: initial code Jiri Slaby
2014-06-25 11:06 ` [PATCH -repost 04/21] kgr: add testing kgraft patch Jiri Slaby
2014-06-25 11:06 ` [PATCH -repost 05/21] kgr: update Kconfig documentation Jiri Slaby
2014-06-25 12:42 ` One Thousand Gnomes
2014-06-26 8:25 ` Jiri Slaby
2014-06-26 8:34 ` Jiri Kosina
2014-06-27 19:18 ` Pavel Machek
2014-07-04 9:14 ` Jiri Slaby
2014-07-04 10:35 ` Pavel Machek
2014-07-05 19:47 ` Jiri Kosina
2014-07-06 12:35 ` Pavel Machek
2014-06-25 11:07 ` [PATCH -repost 06/21] kgr: add Documentation Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 07/21] kgr: trigger the first check earlier Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 08/21] kgr: sched.h, introduce kgr_task_safe helper Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 09/21] kgr: mark task_safe in some kthreads Jiri Slaby
2014-06-25 11:07 ` Jiri Slaby [this message]
2014-06-25 11:07 ` [PATCH -repost 11/21] kgr: handle irqs Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 12/21] kgr: add MAINTAINERS entry Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 13/21] kgr: x86: refuse to build without fentry support Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 14/21] kgr: add procfs interface for per-process 'kgr_in_progress' Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 15/21] kgr: make a per-process 'in progress' flag a single bit Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 16/21] kgr: add support for missing functions Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 17/21] kgr: exercise non-present function Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 18/21] kgr: fix race of stub and patching Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 19/21] kgr: expose global 'in_progress' state through procfs Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 20/21] kgr: rephrase the "kGraft failed" message Jiri Slaby
2014-06-25 11:07 ` [PATCH -repost 21/21] kgr: x86: optimize handling of CPU-bound tasks Jiri Slaby
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=1403694435-3180-10-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=fweisbec@gmail.com \
--cc=jirislaby@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=matz@suse.de \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pavel@ucw.cz \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=vojtech@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).