linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Coly Li <colyli@suse.de>,
	axboe@kernel.dk, linux-bcache@vger.kernel.org,
	linux-block@vger.kernel.org, hare@suse.de, mkoutny@suse.com
Subject: Re: [PATCH 1/2] bcache: ignore pending signals in bcache_device_init()
Date: Wed, 4 Mar 2020 13:41:44 +0100	[thread overview]
Message-ID: <20200304124144.GL16139@dhcp22.suse.cz> (raw)
In-Reply-To: <20200304123342.GD13170@redhat.com>

On Wed 04-03-20 13:33:42, Oleg Nesterov wrote:
> On 03/04, Michal Hocko wrote:
> >
> > On Wed 04-03-20 13:13:25, Oleg Nesterov wrote:
> > > On 03/04, Michal Hocko wrote:
> > > >
> > > > So what would be a legit usecase to drop all signals while explicitly
> > > > calling allow_signal?
> > >
> > > Not sure I understand...
> >
> > flush_signals will simply drop all pending signals on the floor so there
> > is no way to handle them, right? I am asking when is still really a
> > desirable thing to do when you allow_signal for the kthread. The only
> > one I can imagine is that the kthread allows a single signal so it is
> > quite clear which signal is flushed.
> 
> Yes. This is what I meant when I said "they should do the same if kthread
> allows a single signal".

OK, good that we are at the same page. I have clearly misread your
earlier email.
 
> > kernel_dequeue_signal on the other hand will give you a signal and so
> > the code can actually handle it in some way.
> 
> Yes.

diff --git a/kernel/signal.c b/kernel/signal.c
index 9ad8dea93dbb..959adc2a5a3d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -465,7 +465,18 @@ void flush_sigqueue(struct sigpending *queue)
 }
 
 /*
- * Flush all pending signals for this kthread.
+ * Flush all pending signals for this kthread. Please note that this interface
+ * shouldn't be and if there is a need for it then it should be clearly
+ * documented why.
+ *
+ * Existing users should be double checked because most of them are likely
+ * obsolete. Kernel threads are not on the receiving end of signal delivery
+ * unless they explicitly request that by allow_signal() and in that case
+ * flush_signals is almost always a bug because signal should be processed
+ * by kernel_dequeue_signal rather than dropping them on the floor. The only
+ * exception when flush_signals could be used is a micro-optimization when
+ * only a single signal is allowed when retreiving the specific signal number
+ * is not needed. Please document this usage.
  */
 void flush_signals(struct task_struct *t)
 {

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2020-03-04 12:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02  9:34 [PATCH 0/2] bcache patches for Linux v5.6-rc5 Coly Li
2020-03-02  9:34 ` [PATCH 1/2] bcache: ignore pending signals in bcache_device_init() Coly Li
2020-03-02 12:27   ` Michal Hocko
2020-03-02 13:29     ` Coly Li
2020-03-02 13:40       ` Michal Hocko
2020-03-02 17:06         ` Coly Li
2020-03-02 17:28           ` Michal Hocko
2020-03-02 17:47             ` Coly Li
2020-03-03  1:22               ` Guoqing Jiang
2020-03-03  1:30                 ` Coly Li
2020-03-02 13:49     ` Oleg Nesterov
2020-03-02 17:16       ` Coly Li
2020-03-02 17:19         ` Jens Axboe
2020-03-02 17:32           ` Coly Li
2020-03-02 20:33             ` Jens Axboe
2020-03-03  1:08               ` Coly Li
2020-03-03  7:22             ` Hannes Reinecke
2020-03-03  8:05       ` Michal Hocko
2020-03-03 12:19         ` Oleg Nesterov
2020-03-03 16:03           ` Michal Hocko
2020-03-04 11:36             ` Oleg Nesterov
2020-03-04 11:53               ` Oleg Nesterov
2020-03-04 18:42                 ` Jens Axboe
2020-03-04 11:57               ` Michal Hocko
2020-03-04 12:13                 ` Oleg Nesterov
2020-03-04 12:22                   ` Michal Hocko
2020-03-04 12:33                     ` Oleg Nesterov
2020-03-04 12:41                       ` Michal Hocko [this message]
2020-03-04 13:02                         ` Oleg Nesterov
2020-03-04 13:21                           ` Michal Hocko
2020-03-02 15:01     ` Jens Axboe
2020-03-02  9:34 ` [PATCH 2/2] bcache: fix code comments for ignore pending signals Coly Li

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=20200304124144.GL16139@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=colyli@suse.de \
    --cc=hare@suse.de \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=oleg@redhat.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;
as well as URLs for NNTP newsgroup(s).