From patchwork Mon Apr 6 03:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?YmF1ZXJjaGVuKOmZiOiSmeiSmSk=?= X-Patchwork-Id: 11474957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62098112C for ; Mon, 6 Apr 2020 03:14:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F1A42054F for ; Mon, 6 Apr 2020 03:14:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=tencent.com header.i=@tencent.com header.b="dGdO0xJb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F1A42054F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=tencent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLIDN-0006Pq-3D for patchwork-qemu-devel@patchwork.kernel.org; Sun, 05 Apr 2020 23:14:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34490) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLICq-0005zt-Ud for qemu-devel@nongnu.org; Sun, 05 Apr 2020 23:13:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLICm-0008Tt-VO for qemu-devel@nongnu.org; Sun, 05 Apr 2020 23:13:45 -0400 Received: from mail6.tencent.com ([220.249.245.26]:35357) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLICk-0008Ph-LA for qemu-devel@nongnu.org; Sun, 05 Apr 2020 23:13:44 -0400 Received: from EX-SZ021.tencent.com (unknown [10.28.6.73]) by mail6.tencent.com (Postfix) with ESMTP id 69B6FCC0E4; Mon, 6 Apr 2020 11:14:14 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tencent.com; s=s202002; t=1586142854; bh=8fCEIbDk68Acp+vs6mxoEb2prh1aikrPFzroeCeH/eI=; h=From:To:CC:Subject:Date; b=dGdO0xJbydrO67m9J7/+35uuzZGQ6r84uF85cj8kCcxFhWB1QeMMaHqURIa8zZd1I A3G//U1JEgwCiQl7feRU60WpG78gkgJVZaPgvTLI63RwZ66i9PqrvOSZcrQHAzDTuq XV+92GylN6sqXnmcuyIE1oMWZHzEVIipWPYS8078= Received: from EX-SZ008.tencent.com (10.28.6.32) by EX-SZ021.tencent.com (10.28.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Mon, 6 Apr 2020 11:13:35 +0800 Received: from EX-SZ005.tencent.com (10.28.6.29) by EX-SZ008.tencent.com (10.28.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Mon, 6 Apr 2020 11:13:34 +0800 Received: from EX-SZ005.tencent.com ([fe80::5d14:1c60:ce53:dbd6]) by EX-SZ005.tencent.com ([fe80::5d14:1c60:ce53:dbd6%4]) with mapi id 15.01.1847.007; Mon, 6 Apr 2020 11:13:34 +0800 From: =?utf-8?b?YmF1ZXJjaGVuKOmZiOiSmeiSmSk=?= To: qemu-devel Subject: Requesting review about a bugfix in touch_all_pages Thread-Topic: Requesting review about a bugfix in touch_all_pages Thread-Index: AQHWC8D0kmS2yvN+ZEGzd75W8Q0lkQ== Date: Mon, 6 Apr 2020 03:13:34 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [9.19.161.78] MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.249.245.26 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: pbonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From faf903f7b8892179e64bd1a37fe3585a6441bc51 Mon Sep 17 00:00:00 2001 From: Bauerchen Date: Mon, 6 Apr 2020 10:36:54 +0800 Subject: [PATCH] Fix: In touch_all_pages, maybe we need a lock to protect  qemu_cond_boardcast, or qemu_cond_boardcast may be called before all touch  page threads enter qemu_cond_wait. In this case,  main thread waits touch  page threads return, touch page threads wait main thread waking up, that is a  dead lock ,vm will be in pause state forever; Signed-off-by: Bauerchen ---  util/oslib-posix.c | 3 +++  1 file changed, 3 insertions(+) --  1.8.3.1 diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4dd6d7d..062236a 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -492,8 +492,11 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,                             QEMU_THREAD_JOINABLE);          addr += memset_thread[i].numpages * hpagesize;      } + +    qemu_mutex_lock(&page_mutex);      threads_created_flag = true;      qemu_cond_broadcast(&page_cond); +    qemu_mutex_unlock(&page_mutex);        for (i = 0; i < memset_num_threads; i++) {          qemu_thread_join(&memset_thread[i].pgthread);