Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238974 > unrolled thread

[PATCH -mm 0/3] minor kthread/signals cleanups and fix

Started byOleg Nesterov <oleg@redhat.com>
First post2015-10-03 20:20 +0200
Last post2015-10-04 19:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH -mm 0/3] minor kthread/signals cleanups and fix Oleg Nesterov <oleg@redhat.com> - 2015-10-03 20:20 +0200
    [PATCH 2/3] signal: introduce kernel_signal_stop() to fix  jffs2_garbage_collect_thread() Oleg Nesterov <oleg@redhat.com> - 2015-10-03 20:20 +0200
      Re: [PATCH 2/3] signal: introduce kernel_signal_stop() to fix  jffs2_garbage_collect_thread() Tejun Heo <tj@kernel.org> - 2015-10-04 19:30 +0200

#1238974 — [PATCH -mm 0/3] minor kthread/signals cleanups and fix

FromOleg Nesterov <oleg@redhat.com>
Date2015-10-03 20:20 +0200
Subject[PATCH -mm 0/3] minor kthread/signals cleanups and fix
Message-ID<qfzzA-1bp-5@gated-at.bofh.it>
On top of signals-kill-block_all_signals-and-unblock_all_signals.patch

Simple but untested, hopefully maintainers can ack or nack 1/3 at least.

Oleg.

 drivers/block/nbd.c                          |    9 ++-------
 drivers/usb/gadget/function/f_mass_storage.c |    4 +---
 fs/jffs2/background.c                        |    7 ++-----
 include/linux/sched.h                        |   21 ++++++++++++++++-----
 4 files changed, 21 insertions(+), 20 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1238975 — [PATCH 2/3] signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()

FromOleg Nesterov <oleg@redhat.com>
Date2015-10-03 20:20 +0200
Subject[PATCH 2/3] signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()
Message-ID<qfzzA-1bp-19@gated-at.bofh.it>
In reply to#1238974
jffs2_garbage_collect_thread() can race with SIGCONT and sleep in
TASK_STOPPED state after it was already sent. Add the new helper,
kernel_signal_stop(), which does this correctly.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 fs/jffs2/background.c |  3 +--
 include/linux/sched.h | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index f3145fd..53cc735 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -132,8 +132,7 @@ static int jffs2_garbage_collect_thread(void *_c)
 			case SIGSTOP:
 				jffs2_dbg(1, "%s(): SIGSTOP received\n",
 					  __func__);
-				set_current_state(TASK_STOPPED);
-				schedule();
+				kernel_signal_stop();
 				break;
 
 			case SIGKILL:
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e714539..56e688c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2477,6 +2477,16 @@ static inline int kernel_dequeue_signal(siginfo_t *info)
 	return ret;
 }
 
+static inline void kernel_signal_stop(void)
+{
+	spin_lock_irq(&current->sighand->siglock);
+	if (current->jobctl & JOBCTL_STOP_DEQUEUED)
+		__set_current_state(TASK_STOPPED);
+	spin_unlock_irq(&current->sighand->siglock);
+
+	schedule();
+}
+
 extern void release_task(struct task_struct * p);
 extern int send_sig_info(int, struct siginfo *, struct task_struct *);
 extern int force_sigsegv(int, struct task_struct *);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1239166 — Re: [PATCH 2/3] signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()

FromTejun Heo <tj@kernel.org>
Date2015-10-04 19:30 +0200
SubjectRe: [PATCH 2/3] signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()
Message-ID<qfVgK-6VO-25@gated-at.bofh.it>
In reply to#1238975
On Sat, Oct 03, 2015 at 08:13:38PM +0200, Oleg Nesterov wrote:
> jffs2_garbage_collect_thread() can race with SIGCONT and sleep in
> TASK_STOPPED state after it was already sent. Add the new helper,
> kernel_signal_stop(), which does this correctly.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Reviewed-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web