From: Oleg Nesterov <oleg@redhat.com>
To: Petr Mladek <pmladek@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Richard Weinberger <richard@nod.at>,
Steven Rostedt <rostedt@goodmis.org>,
David Woodhouse <dwmw2@infradead.org>,
linux-mtd@lists.infradead.org,
Trond Myklebust <trond.myklebust@primarydata.com>,
Anna Schumaker <anna.schumaker@netapp.com>,
linux-nfs@vger.kernel.org, Chris Mason <clm@fb.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Kosina <jkosina@suse.cz>, Borislav Petkov <bp@suse.de>,
Michal Hocko <mhocko@suse.cz>,
live-patching@vger.kernel.org, linux-api@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 06/18] signal/kthread: Initial implementation of kthread signal handling
Date: Mon, 8 Jun 2015 23:13:36 +0200 [thread overview]
Message-ID: <20150608211336.GB24869@redhat.com> (raw)
In-Reply-To: <20150608135107.GB3135@pathway.suse.cz>
Let me first repeat that I agree that everything is subjective ;)
On 06/08, Petr Mladek wrote:
>
> To be honest, this patch set does _not_ make any big change.
But to me it does because (again, imo) it adds the a) unnecessary
and b) wrong interface.
But yes, yes, I agree that most (all?) of kthread/signal (ab)users
need cleanups. And fixes.
> I think that we should make it independent on the iterant kthread API.
Yes! please. Then we can discuss this again and perhaps reconsider
this API.
So I am going to ignore some parts of your email. I am sleeping,
please let me know if I missed something important ;)
> Well, note that allow_signal() sets some "crazy" value (2) for the
> signal handler. IMHO, we should check for these values and handle
> them reasonably even in kthreads. It will make the code more secure.
Not sure I understand. The crazy "2" value just means that kthread
wants to recieve and dequeue this signal. I agree with the good name
for this hard-coded number in advance.
> > > +
> > > + /* Run the custom handler if any */
> > > + if (ka->sa.kthread_sa_handler != KTHREAD_SIG_DFL) {
> > > + ksig.ka = *ka;
> > > +
> > > + if (ka->sa.sa_flags & SA_ONESHOT)
> > > + ka->sa.kthread_sa_handler = KTHREAD_SIG_DFL;
> > > +
> > > + spin_unlock_irqrestore(&sighand->siglock, flags);
> > > + /* could run directly for kthreads */
> > > + ksig.ka.sa.kthread_sa_handler(signr);
> > > + freezable_cond_resched();
> > > + goto relock;
> >
> > Well. But for what? A simple "switch (signr)" after kthread_dequeue_signal()
> > can do the same. Or, speaking of kthread_iterant_fn() it can even dequeue the
> > signal and pass it to kti->whatever(signr).
>
> I wanted to make it independent on the iterant API. Also if you want to
> handle more signals, you need even more code, e.g. the cycle,
> cond_resched(). So, I think that some generic helper is useful.
I do not. Contrary, I think this needs more code in the likely case.
Anyway, this API won't have too many users, so I don't even this this
is that important.
> > > + if (sig_kernel_stop(signr)) {
> > > + __set_current_state(TASK_STOPPED);
> > > + spin_unlock_irqrestore(&sighand->siglock, flags);
> > > + /* Don't run again until woken by SIGCONT or SIGKILL */
> > > + freezable_schedule();
> > > + goto relock;
> >
> > Yes this avoids the race with SIGCONT. But as I said we can add another
> > trivial helper which checks JOBCTL_STOP_DEQUEUED. So a kthread can do
> > this itself.
>
> Hmm, the helper would have a strange semantic. You need to take
> sighand->siglock, dequeue the signal (SIGSTOP), and call
> __set_current_state(TASK_STOPPED) before you release the lock.
> But what would happen if the dequeued signal is _not_ SIGSTOP?
Perhaps I missed your point, but no. If you want to handle SIGSTOP
you can do
signr = kthread_signal_dequeue();
switch (signr) {
case SIGSTOP:
something_else();
kthread_do_signal_stop();
...
}
> I think that we should support only the standard handling of
> SIGSTOP. It is closely related with SIGCONT.
Agreed. If kthread wants to actually sleep in TASK_STOPPED state then
it should know about SIGCONT.
> > To me, SIG_DFL behaviour just makes makes no sense when it comes to
> > kthreads. I do not even think this can simplify the code. Unlike user-
> > space task, kthread can happily dequeue SIGSTOP, so why should we mimic
> > the userspace SIG_DFL logic.
>
> Maybe, we should handle only SIGSTOP
So far I even disagree with SIGSTOP "default" semantics. I simply see
no value.
Oleg.
next prev parent reply other threads:[~2015-06-08 21:14 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 15:00 [RFC PATCH 00/18] kthreads/signal: Safer kthread API and signal handling Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 01/18] kthread: Allow to call __kthread_create_on_node() with va_list args Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 02/18] kthread: Add API for iterant kthreads Petr Mladek
2015-06-09 6:23 ` Tejun Heo
2015-06-15 12:46 ` Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 03/18] kthread: Add kthread_stop_current() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 04/18] signal: Rename kernel_sigaction() to kthread_sigaction() and clean it up Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 05/18] freezer/scheduler: Add freezable_cond_resched() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 06/18] signal/kthread: Initial implementation of kthread signal handling Petr Mladek
2015-06-06 21:58 ` Oleg Nesterov
2015-06-08 13:51 ` Petr Mladek
2015-06-08 21:13 ` Oleg Nesterov [this message]
2015-06-15 13:13 ` Petr Mladek
2015-06-15 19:14 ` Oleg Nesterov
2015-06-16 7:54 ` Petr Mladek
2015-06-09 7:10 ` Tejun Heo
2015-06-09 12:15 ` Jiri Kosina
2015-06-10 3:13 ` Tejun Heo
2015-06-05 15:01 ` [RFC PATCH 07/18] kthread: Make iterant kthreads freezable by default Petr Mladek
2015-06-09 7:20 ` Tejun Heo
2015-06-09 15:53 ` Petr Mladek
2015-06-10 4:31 ` Tejun Heo
2015-06-12 13:24 ` Petr Mladek
2015-06-13 23:22 ` Tejun Heo
2015-06-15 9:28 ` Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 08/18] kthread: Allow to get struct kthread_iterant from task_struct Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 09/18] kthread: Make it easier to correctly sleep in iterant kthreads Petr Mladek
2015-06-05 16:10 ` Peter Zijlstra
2015-06-08 10:01 ` Petr Mladek
2015-06-08 11:39 ` Peter Zijlstra
2015-06-09 15:25 ` Petr Mladek
2015-06-10 9:05 ` Peter Zijlstra
2015-06-09 7:32 ` Tejun Heo
2015-06-08 17:48 ` Steven Rostedt
2015-06-10 9:07 ` Peter Zijlstra
2015-06-10 14:07 ` Steven Rostedt
2015-06-11 4:28 ` Jiri Kosina
2015-06-05 15:01 ` [RFC PATCH 10/18] jffs2: Remove forward definition of jffs2_garbage_collect_thread() Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 11/18] jffs2: Convert jffs2_gcd_mtd kthread into the iterant API Petr Mladek
2015-06-06 21:16 ` Oleg Nesterov
2015-06-06 21:32 ` Jiri Kosina
2015-06-06 22:30 ` Oleg Nesterov
2015-06-06 22:44 ` Jiri Kosina
2015-06-06 22:58 ` Oleg Nesterov
2015-06-05 15:01 ` [RFC PATCH 12/18] lockd: Convert the central lockd service to kthread_iterant API Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 13/18] ring_buffer: Use iterant kthreads API in the ring buffer benchmark Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 14/18] ring_buffer: Allow to cleanly freeze the ring buffer benchmark kthreads Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 15/18] ring_buffer: Allow to exit the ring buffer benchmark immediately Petr Mladek
2015-06-08 17:44 ` Steven Rostedt
2015-06-15 15:23 ` Petr Mladek
2015-06-15 15:33 ` Steven Rostedt
2015-06-15 15:54 ` Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 16/18] kthread: Support interruptible sleep with a timeout by iterant kthreads Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 17/18] ring_buffer: Use the new API for a sleep with a timeout in the benchmark Petr Mladek
2015-06-05 15:01 ` [RFC PATCH 18/18] jffs2: Use the new API for a sleep with a timeout Petr Mladek
2015-06-05 16:22 ` [RFC PATCH 00/18] kthreads/signal: Safer kthread API and signal handling Peter Zijlstra
2015-06-09 6:14 ` Tejun Heo
2015-06-10 10:40 ` Peter Zijlstra
2015-06-11 22:02 ` Tejun Heo
2015-06-09 6:10 ` Tejun Heo
2015-06-09 7:58 ` Tejun Heo
2015-06-17 11:34 ` Christoph Hellwig
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=20150608211336.GB24869@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anna.schumaker@netapp.com \
--cc=bp@suse.de \
--cc=clm@fb.com \
--cc=dwmw2@infradead.org \
--cc=jkosina@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mhocko@suse.cz \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.cz \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@primarydata.com \
/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