From nobody Mon Feb 9 21:12:15 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1586610425; cv=none; d=zohomail.com; s=zohoarc; b=etHt5CJuNxm/Q7K/1kbYozyFoCcov+aMd9uWCYtONMcv9AaQ6keY6x3N+n0qTwWTSsBJmqT8fXXYl354V1FPZYwDu4TW87p6KMsYHt2fhU9/jljXzgRs4Gf6IuG1KmMs7RhCy5ROlKpkH7/jrkUi9f9ZyWJOW1XbDmXQVQxh6yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586610425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=taSWfJvQWiJh1LHKH1Z4zjsoIVsofodaoPw9g1FbQ0g=; b=V96bl9ZQ05/CiwEzAMtvDAPaZvnQvRB8ZgCAp9MJxXMMWEIFFxDz8QobG2cE2oNJK3DmgSJFJ0Gw9ru9AfGH1AVFuYuyq2+BgtFHWZMsByt6V1OABepnaBkBI6A6UBP0sHAOet8j8j3duEwXYImEAJYmp+NAMg7RlJZk4+u9x4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586610425951289.72362492916693; Sat, 11 Apr 2020 06:07:05 -0700 (PDT) Received: from localhost ([::1]:51832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNFqi-000410-Lq for importer@patchew.org; Sat, 11 Apr 2020 09:07:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33238) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNFnQ-00078B-Iq for qemu-devel@nongnu.org; Sat, 11 Apr 2020 09:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jNFnO-0002ZZ-Hz for qemu-devel@nongnu.org; Sat, 11 Apr 2020 09:03:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47216 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jNFnO-0002Z7-EF for qemu-devel@nongnu.org; Sat, 11 Apr 2020 09:03:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-RY3z9BdZNYC9o0CcKaNh_A-1; Sat, 11 Apr 2020 09:03:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 776241005513; Sat, 11 Apr 2020 13:03:34 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB3998A2B; Sat, 11 Apr 2020 13:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586610218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=taSWfJvQWiJh1LHKH1Z4zjsoIVsofodaoPw9g1FbQ0g=; b=ea21BXhdanWcADdeIBsneGL9wuWkjnUf9B5ePu1jkVXMyIBGqRFZSIRLQrtOYChZUx5Mdf y+MONJOfyrsSbCd3Inr0uh5Mh8B0HkdOgqSPqbd+XyYJ8vW+rtV/sU8XpA1Jflup4mKpcC Vi8A/Dw1a15Bd0dUeUc4iItpbav2Y9E= X-MC-Unique: RY3z9BdZNYC9o0CcKaNh_A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 2/8] oslib-posix: take lock before qemu_cond_broadcast Date: Sat, 11 Apr 2020 09:03:24 -0400 Message-Id: <20200411130330.1993-3-pbonzini@redhat.com> In-Reply-To: <20200411130330.1993-1-pbonzini@redhat.com> References: <20200411130330.1993-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bauerchen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bauerchen In touch_all_pages, if the mutex is not taken around qemu_cond_broadcast, qemu_cond_broadcast may be called before all touch page threads enter qemu_cond_wait. In this case, the touch page threads wait forever for the main thread to wake them up, causing a deadlock. Signed-off-by: Bauerchen Signed-off-by: Paolo Bonzini --- util/oslib-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4dd6d7d4b4..062236a1ab 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -492,8 +492,11 @@ static bool touch_all_pages(char *area, size_t hpagesi= ze, size_t numpages, QEMU_THREAD_JOINABLE); addr +=3D memset_thread[i].numpages * hpagesize; } + + qemu_mutex_lock(&page_mutex); threads_created_flag =3D true; qemu_cond_broadcast(&page_cond); + qemu_mutex_unlock(&page_mutex); =20 for (i =3D 0; i < memset_num_threads; i++) { qemu_thread_join(&memset_thread[i].pgthread); --=20 2.18.2