From nobody Tue Feb 10 05:46:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635929744458202.7919334086239; Wed, 3 Nov 2021 01:55:44 -0700 (PDT) Received: from localhost ([::1]:50830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miC3b-0002B5-ET for importer@patchew.org; Wed, 03 Nov 2021 04:55:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miBw1-0002qa-1M for qemu-devel@nongnu.org; Wed, 03 Nov 2021 04:47:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miBvW-00048l-UP for qemu-devel@nongnu.org; Wed, 03 Nov 2021 04:47:52 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-RfqhDxivPz2VHRkYGYHplw-1; Wed, 03 Nov 2021 04:46:16 -0400 Received: by mail-wm1-f71.google.com with SMTP id m14-20020a05600c3b0e00b0033308dcc933so289396wms.7 for ; Wed, 03 Nov 2021 01:46:16 -0700 (PDT) Received: from localhost (static-233-86-86-188.ipcom.comunitel.net. [188.86.86.233]) by smtp.gmail.com with ESMTPSA id u19sm1325631wmm.5.2021.11.03.01.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 01:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635929242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hsQ8hXBn7WkAri1/B/nJyK+EZjImeCKuGXRF/WepPqo=; b=XtryX7jmJKozKNkOoPm8VO2OIGVv5dZWtDcHphIT4JpEv9OXn7SIyYsQp5oR3lXCHblKgt XmCfmBlpuVJhHnn3+uDWnKAFeCrlFNPx91O2BbWbTw+C9hjPpT+lWfY6UgfYF1vLfq00IM oA90IRDDRGTCofAZACG5I+r9vWd8860= X-MC-Unique: RfqhDxivPz2VHRkYGYHplw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hsQ8hXBn7WkAri1/B/nJyK+EZjImeCKuGXRF/WepPqo=; b=uDeojjdzgWryAVgx3zf+UtlHAV9Uw1Gttejq7UvBL2RRIkXMIAYA7r7d/igAusqZWJ JRnzJe1RYBSvW1Gl5kGZgkZDniKF/WAjC9IS9MLvICnP28eOso/X9AMI8ocXIvZHewKt QZNqRSDNMNtLtbChVWXKV8JQFkMNXbT+lLYEAz5UbnlX98O/60aOps0c+YMaMVBaJY9r kt+7J6oDL56QuuUMIRDoXgbLtB3XXC0tqTVel3wG3NYXv+kpi5uttWpMgMjLu7XnUF5C KeFcAdU+C2cv64B6lLuKbAirebmEUJQX7LJbUd4tpum8NNb9FKqauDzogXw3SIgz6ODd VwjA== X-Gm-Message-State: AOAM530gICt9L1SXLWGVyZgblTUGee3ZZWpuN5RpdlXZiqluzfXmwXpw s8S4zxq9pgjXp4/hqX2fUYhVbXKVui4Cjlf9WAZeKz5OIjXCX8++8cX+TiklVcKZei9djY2Hqqa RgVO/yhUHQsuC9bUq3V+sKcoFPOPvAhzn5GYJBkgfk9LW0JZ9vENDf0+cs4tWIjsWHdY= X-Received: by 2002:adf:e54a:: with SMTP id z10mr43727617wrm.328.1635929174994; Wed, 03 Nov 2021 01:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw00E5UDZhwc6Tbj13Lif2FxQzdCLYIQHzj/ixj0s1ag48c2KkhkAR3RvF4ZczpKOaFQIXfpw== X-Received: by 2002:adf:e54a:: with SMTP id z10mr43727570wrm.328.1635929174550; Wed, 03 Nov 2021 01:46:14 -0700 (PDT) From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 06/11] Fixed SVM hang when do failover before PVM crash Date: Wed, 3 Nov 2021 09:46:00 +0100 Message-Id: <20211103084605.20027-7-quintela@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211103084605.20027-1-quintela@redhat.com> References: <20211103084605.20027-1-quintela@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.702, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hailiang Zhang , Li Zhijian , Juan Quintela , Jason Wang , "Dr. David Alan Gilbert" , Zhang Chen , "Rao, Lei" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635929745319100001 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" This patch fixed as follows: Thread 1 (Thread 0x7f34ee738d80 (LWP 11212)): #0 __pthread_clockjoin_ex (threadid=3D139847152957184, thread_return=3D= 0x7f30b1febf30, clockid=3D, abstime=3D, block= =3D) at pthread_join_common.c:145 #1 0x0000563401998e36 in qemu_thread_join (thread=3D0x563402d66610) at = util/qemu-thread-posix.c:587 #2 0x00005634017a79fa in process_incoming_migration_co (opaque=3D0x0) a= t migration/migration.c:502 #3 0x00005634019b59c9 in coroutine_trampoline (i0=3D63395504, i1=3D2206= 8) at util/coroutine-ucontext.c:115 #4 0x00007f34ef860660 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__s= tart_context.S:91 from /lib/x86_64-linux-gnu/libc.so.6 #5 0x00007f30b21ee730 in ?? () #6 0x0000000000000000 in ?? () Thread 13 (Thread 0x7f30b3dff700 (LWP 11747)): #0 __lll_lock_wait (futex=3Dfutex@entry=3D0x56340218ffa0 , private=3D0) at lowlevellock.c:52 #1 0x00007f34efa000a3 in _GI__pthread_mutex_lock (mutex=3D0x56340218ff= a0 ) at ../nptl/pthread_mutex_lock.c:80 #2 0x0000563401997f99 in qemu_mutex_lock_impl (mutex=3D0x56340218ffa0 = , file=3D0x563401b7a80e "migration/colo.c", line=3D806) = at util/qemu-thread-posix.c:78 #3 0x0000563401407144 in qemu_mutex_lock_iothread_impl (file=3D0x56340= 1b7a80e "migration/colo.c", line=3D806) at /home/workspace/colo-qemu/cpus.c= :1899 #4 0x00005634017ba8e8 in colo_process_incoming_thread (opaque=3D0x5634= 02d664c0) at migration/colo.c:806 #5 0x0000563401998b72 in qemu_thread_start (args=3D0x5634039f8370) at = util/qemu-thread-posix.c:519 #6 0x00007f34ef9fd609 in start_thread (arg=3D) at pthre= ad_create.c:477 #7 0x00007f34ef924293 in clone () at ../sysdeps/unix/sysv/linux/x86_64= /clone.S:95 The QEMU main thread is holding the lock: (gdb) p qemu_global_mutex $1 =3D {lock =3D {_data =3D {lock =3D 2, __count =3D 0, __owner =3D 112= 12, __nusers =3D 9, __kind =3D 0, __spins =3D 0, __elision =3D 0, __list = =3D {_prev =3D 0x0, __next =3D 0x0}}, __size =3D "\002\000\000\000\000\000\000\000\314+\000\000\t", '\000' <= repeats 26 times>, __align =3D 2}, file =3D 0x563401c07e4b "util/main-loop.= c", line =3D 240, initialized =3D true} >From the call trace, we can see it is a deadlock bug. and the QEMU main th= read holds the global mutex to wait until the COLO thread ends. and the col= o thread wants to acquire the global mutex, which will cause a deadlock. So, we shou= ld release the qemu_global_mutex before waiting colo thread ends. Signed-off-by: Lei Rao Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 3fb856f6e1..abaf6f9e3d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -590,8 +590,10 @@ static void process_incoming_migration_co(void *opaque) mis->have_colo_incoming_thread =3D true; qemu_coroutine_yield(); =20 + qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ qemu_thread_join(&mis->colo_incoming_thread); + qemu_mutex_lock_iothread(); /* We hold the global iothread lock, so it is safe here */ colo_release_ram_cache(); } --=20 2.33.1