All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@sandisk.com>
To: "hare@suse.de" <hare@suse.de>, "axboe@kernel.dk" <axboe@kernel.dk>
Cc: "hch@lst.de" <hch@lst.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jth@kernel.org" <jth@kernel.org>,
	"hare@suse.com" <hare@suse.com>
Subject: Re: [PATCH] genhd: Do not hold event lock when scheduling workqueue elements
Date: Tue, 31 Jan 2017 00:31:01 +0000	[thread overview]
Message-ID: <1485822639.2669.16.camel@sandisk.com> (raw)
In-Reply-To: <1484732896-22941-1-git-send-email-hare@suse.de>

On Wed, 2017-01-18 at 10:48 +0100, Hannes Reinecke wrote:
> @@ -1488,26 +1487,13 @@ static unsigned long disk_events_poll_jiffies(str=
uct gendisk *disk)
> =A0void disk_block_events(struct gendisk *disk)
> =A0{
> =A0=A0=A0=A0=A0=A0=A0=A0struct disk_events *ev =3D disk->ev;
> -=A0=A0=A0=A0=A0=A0=A0unsigned long flags;
> -=A0=A0=A0=A0=A0=A0=A0bool cancel;
> =A0
> =A0=A0=A0=A0=A0=A0=A0=A0if (!ev)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return;
> =A0
> -=A0=A0=A0=A0=A0=A0=A0/*
> -=A0=A0=A0=A0=A0=A0=A0 * Outer mutex ensures that the first blocker compl=
etes canceling
> -=A0=A0=A0=A0=A0=A0=A0 * the event work before further blockers are allow=
ed to finish.
> -=A0=A0=A0=A0=A0=A0=A0 */
> -=A0=A0=A0=A0=A0=A0=A0mutex_lock(&ev->block_mutex);
> -
> -=A0=A0=A0=A0=A0=A0=A0spin_lock_irqsave(&ev->lock, flags);
> -=A0=A0=A0=A0=A0=A0=A0cancel =3D !ev->block++;
> -=A0=A0=A0=A0=A0=A0=A0spin_unlock_irqrestore(&ev->lock, flags);
> -
> -=A0=A0=A0=A0=A0=A0=A0if (cancel)
> +=A0=A0=A0=A0=A0=A0=A0if (atomic_inc_return(&ev->block) =3D=3D 1)
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0cancel_delayed_work_sync(=
&disk->ev->dwork);
> =A0
> -=A0=A0=A0=A0=A0=A0=A0mutex_unlock(&ev->block_mutex);
> =A0}

Hello Hannes,

I have already encountered a few times a deadlock that was caused by the
event checking code so I agree with you that it would be a big step forward
if such deadlocks wouldn't occur anymore. However, this patch realizes a
change that has not been described in the patch description, namely that
disk_block_events() calls are no longer serialized. Are you sure it is safe
to drop the serialization of disk_block_events() calls?

Thanks,

Bart.=

WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <Bart.VanAssche@sandisk.com>
To: "hare@suse.de" <hare@suse.de>, "axboe@kernel.dk" <axboe@kernel.dk>
Cc: "hch@lst.de" <hch@lst.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jth@kernel.org" <jth@kernel.org>,
	"hare@suse.com" <hare@suse.com>
Subject: Re: [PATCH] genhd: Do not hold event lock when scheduling workqueue elements
Date: Tue, 31 Jan 2017 00:31:01 +0000	[thread overview]
Message-ID: <1485822639.2669.16.camel@sandisk.com> (raw)
In-Reply-To: <1484732896-22941-1-git-send-email-hare@suse.de>

On Wed, 2017-01-18 at 10:48 +0100, Hannes Reinecke wrote:
> @@ -1488,26 +1487,13 @@ static unsigned long disk_events_poll_jiffies(struct gendisk *disk)
>  void disk_block_events(struct gendisk *disk)
>  {
>         struct disk_events *ev = disk->ev;
> -       unsigned long flags;
> -       bool cancel;
>  
>         if (!ev)
>                 return;
>  
> -       /*
> -        * Outer mutex ensures that the first blocker completes canceling
> -        * the event work before further blockers are allowed to finish.
> -        */
> -       mutex_lock(&ev->block_mutex);
> -
> -       spin_lock_irqsave(&ev->lock, flags);
> -       cancel = !ev->block++;
> -       spin_unlock_irqrestore(&ev->lock, flags);
> -
> -       if (cancel)
> +       if (atomic_inc_return(&ev->block) == 1)
>                 cancel_delayed_work_sync(&disk->ev->dwork);
>  
> -       mutex_unlock(&ev->block_mutex);
>  }

Hello Hannes,

I have already encountered a few times a deadlock that was caused by the
event checking code so I agree with you that it would be a big step forward
if such deadlocks wouldn't occur anymore. However, this patch realizes a
change that has not been described in the patch description, namely that
disk_block_events() calls are no longer serialized. Are you sure it is safe
to drop the serialization of disk_block_events() calls?

Thanks,

Bart.

  reply	other threads:[~2017-01-31  0:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18  9:48 [PATCH] genhd: Do not hold event lock when scheduling workqueue elements Hannes Reinecke
2017-01-31  0:31 ` Bart Van Assche [this message]
2017-01-31  0:31   ` Bart Van Assche
2017-01-31 16:15   ` Hannes Reinecke
2017-01-31 16:15     ` Hannes Reinecke
2017-02-03 12:22     ` Dexuan Cui
2017-02-03 12:22       ` Dexuan Cui
2017-02-07  2:23       ` Dexuan Cui
2017-02-07  2:23         ` Dexuan Cui
2017-02-07  2:56         ` Bart Van Assche
2017-02-07  2:56           ` Bart Van Assche
2017-02-07  3:48           ` Dexuan Cui
2017-02-07  6:29             ` Dexuan Cui
2017-02-07  6:29               ` Dexuan Cui
2017-02-07 16:09               ` Jens Axboe
2017-02-08 10:48                 ` Dexuan Cui
2017-02-08 10:48                   ` Dexuan Cui
2017-02-08 17:43                   ` Boot regression (was "Re: [PATCH] genhd: Do not hold event lock when scheduling workqueue elements") Jens Axboe
2017-02-08 18:03                     ` hch
2017-02-09  7:35                       ` Dexuan Cui
2017-02-09  7:35                         ` Dexuan Cui
2017-02-09 13:08                         ` hch
2017-02-10 14:49                           ` Dexuan Cui
2017-02-10 14:49                             ` Dexuan Cui
2017-02-14 13:47                             ` hch
2017-02-14 14:17                               ` Dexuan Cui
2017-02-14 14:17                                 ` Dexuan Cui
2017-02-14 14:28                                 ` hch
2017-02-14 14:46                                   ` Dexuan Cui
2017-02-14 14:46                                     ` Dexuan Cui
2017-02-14 14:51                                     ` hch
2017-02-14 15:54                                       ` Dexuan Cui
2017-02-14 15:54                                         ` Dexuan Cui
2017-02-14 16:34                                         ` hch
2017-02-15 13:51                                           ` Dexuan Cui
2017-02-15 13:51                                             ` Dexuan Cui

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=1485822639.2669.16.camel@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jth@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.