All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Pingfan Liu <piliu@redhat.com>
Cc: dm-devel@redhat.com, Ming Lei <minlei@redhat.com>,
	Tao Liu <ltao@redhat.com>
Subject: Re: [dm-devel] A hang bug of dm on s390x
Date: Thu, 16 Feb 2023 08:08:35 +0800	[thread overview]
Message-ID: <Y+10AxZ8tcd6SemJ@T590> (raw)
In-Reply-To: <CAF+s44TZw40c_hNDi78VkMq6Xhp23h5j_cadHWirOnYW-wR=NQ@mail.gmail.com>

On Wed, Feb 15, 2023 at 07:23:40PM +0800, Pingfan Liu wrote:
> Hi guys,
> 
> I encountered  a hang issue on a s390x system.  The tested kernel is
> not preemptible and booting with "nr_cpus=1"
> 
> The test steps:
>       umount /home
>       lvremove /dev/rhel_s390x-kvm-011/home
>       ## uncomment "snapshot_autoextend_threshold = 70" and
>       "snapshot_autoextend_percent = 20" in /etc/lvm/lvm.conf
> 
>       systemctl enable lvm2-monitor.service
>       systemctl start lvm2-monitor.service
> 
>       lvremove -y rhel_s390x-kvm-011/thinp
>       lvcreate -L 10M -T rhel_s390x-kvm-011/thinp
>       lvcreate -V 400M -T rhel_s390x-kvm-011/thinp -n src
>       mkfs.ext4 /dev/rhel_s390x-kvm-011/src
>       mount /dev/rhel_s390x-kvm-011/src /mnt
>       for((i=0;i<4;i++)); do dd if=/dev/zero of=/mnt/test$i.img
> bs=100M count=1; done
> 
> And the system hangs with the console log [1]
> 
> The related kernel config
> 
>     CONFIG_PREEMPT_NONE_BUILD=y
>     CONFIG_PREEMPT_NONE=y
>     CONFIG_PREEMPT_COUNT=y
>     CONFIG_SCHED_CORE=y
> 
> It turns out that when hanging, the kernel is stuck in the dead-loop
> in the function dm_wq_work()
>         while (!test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) {
>                 spin_lock_irq(&md->deferred_lock);
>                 bio = bio_list_pop(&md->deferred);
>                 spin_unlock_irq(&md->deferred_lock);
> 
>                 if (!bio)
>                         break;
>                 thread_cpu = smp_processor_id();
>                 submit_bio_noacct(bio);
>         }
> where dm_wq_work()->__submit_bio_noacct()->...->dm_handle_requeue()
> keeps generating new bio, and the condition "if (!bio)" can not be
> meet.
> 
> 
> After applying the following patch, the issue is gone.
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index e1ea3a7bd9d9..95c9cb07a42f 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -2567,6 +2567,7 @@ static void dm_wq_work(struct work_struct *work)
>                         break;
> 
>                 submit_bio_noacct(bio);
> +               cond_resched();
>         }
>  }
> 
> But I think it is not a proper solution. And without this patch, if
> removing nr_cpus=1 (the system has two cpus), the issue can not be
> triggered. That says when more than one cpu, the above loop can exit
> by the condition "if (!bio)"
> 
> Any ideas?

I think the patch is correct.

For kernel built without CONFIG_PREEMPT, in case of single cpu core,
if the dm target(such as dm-thin) needs another wq or kthread for
handling IO, then dm target side is blocked because dm_wq_work()
holds the single cpu, sooner or later, dm target may have not
resource to handle new io from dm core and returns REQUEUE.

Then dm_wq_work becomes one dead loop.


Thanks,
Ming
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2023-02-16  0:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 11:23 [dm-devel] A hang bug of dm on s390x Pingfan Liu
2023-02-16  0:08 ` Ming Lei [this message]
2023-02-16  8:30   ` Pingfan Liu
2023-02-16 12:39     ` Zdenek Kabelac
2023-02-16 17:29     ` Mike Snitzer

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=Y+10AxZ8tcd6SemJ@T590 \
    --to=ming.lei@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ltao@redhat.com \
    --cc=minlei@redhat.com \
    --cc=piliu@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 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.