From patchwork Thu May 23 10:54:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 1104036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="C9KHl+NO"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 458mmK13T9z9s5c for ; Thu, 23 May 2019 21:02:05 +1000 (AEST) Received: from localhost ([127.0.0.1]:33724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTlU3-0002Vt-4C for incoming@patchwork.ozlabs.org; Thu, 23 May 2019 07:02:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTlN9-0005H5-2h for qemu-devel@nongnu.org; Thu, 23 May 2019 06:54:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTlN7-0004ua-Lf for qemu-devel@nongnu.org; Thu, 23 May 2019 06:54:54 -0400 Received: from mail-eopbgr10111.outbound.protection.outlook.com ([40.107.1.111]:47693 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTlN6-0004rv-Vz for qemu-devel@nongnu.org; Thu, 23 May 2019 06:54:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5dG8ZjdUTTrH2EUOGNc9iCD4YPcVF71jqGSB4UceVx8=; b=C9KHl+NOHQF9XCMSXvv2uLHBRIFTgH1c8vCO22MRojOD9TsuC4sSz29au443siURmU1WPoqHC4AnIroge7suWTzWRMZWaOJwUl1gVJpXJWvfEXNZdiKKWHOT6R9Tu8sqWtm6aUpJi6zIY015sNKYveXkJsDEXpLKNA3FFpcoCcM= Received: from DBBPR08MB4854.eurprd08.prod.outlook.com (20.179.46.205) by DBBPR08MB4425.eurprd08.prod.outlook.com (20.179.43.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.16; Thu, 23 May 2019 10:54:49 +0000 Received: from DBBPR08MB4854.eurprd08.prod.outlook.com ([fe80::4d46:2c95:d6e:ab3f]) by DBBPR08MB4854.eurprd08.prod.outlook.com ([fe80::4d46:2c95:d6e:ab3f%7]) with mapi id 15.20.1900.010; Thu, 23 May 2019 10:54:49 +0000 From: Roman Kagan To: Paolo Bonzini , "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 2/2] cpus-common: assert BQL nesting within cpu-exclusive sections Thread-Index: AQHVEVXxmQM6pQZQ6EOMQW2xqwR+sg== Date: Thu, 23 May 2019 10:54:49 +0000 Message-ID: <20190523105440.27045-3-rkagan@virtuozzo.com> References: <20190523105440.27045-1-rkagan@virtuozzo.com> In-Reply-To: <20190523105440.27045-1-rkagan@virtuozzo.com> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [185.231.240.5] x-clientproxiedby: HE1PR0901CA0058.eurprd09.prod.outlook.com (2603:10a6:3:45::26) To DBBPR08MB4854.eurprd08.prod.outlook.com (2603:10a6:10:da::13) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.21.0 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 831b6e39-52ee-47ef-ecdc-08d6df6d1359 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:DBBPR08MB4425; x-ms-traffictypediagnostic: DBBPR08MB4425: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 00462943DE x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(136003)(39840400004)(366004)(376002)(396003)(199004)(189003)(81166006)(81156014)(8676002)(8936002)(50226002)(7736002)(2501003)(305945005)(36756003)(53936002)(386003)(6506007)(102836004)(52116002)(6486002)(14454004)(316002)(76176011)(1076003)(478600001)(99286004)(86362001)(6512007)(11346002)(2616005)(476003)(446003)(186003)(66066001)(68736007)(2906002)(26005)(256004)(71200400001)(110136005)(25786009)(66946007)(64756008)(14444005)(71190400001)(66476007)(66556008)(73956011)(5660300002)(3846002)(6436002)(66446008)(486006)(6116002); DIR:OUT; SFP:1102; SCL:1; SRVR:DBBPR08MB4425; H:DBBPR08MB4854.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: aq/9XU/d3rSV3dXma8TF9AIF8h8T/SIyI2wkCI124H+iTpY8SmJyMqz+LksOV87TvDtWydfAlDgyjojN881adHNKmqwdLVKabIM1dWWWst0nsTsO3pCbq14adfmxqiBWs46P4AdfYnvyCWpu7QZ312NAbOwVbj/SsZGahj1eQmxKBQR+/h4MsWHGHwX9XiFjC2KmvtDhln/vgawbem53iexjzdHIsK//Z/oMTA4ItjoArbO9A+IRN1rkYReK5LZhqP6NInAzTJF1Z24ZkX1SpKNcdGo40LX8INwGBXhaY1fbuFgUe8ssAw51PUZ+ZZnDY9dbqr7FqSJfQ7xWRZDr6SzJKBhZ8ce8nw16oQya2IwDqp/18xHnOivJS52Fl87RCLjot8zTA1pI76ssDX0LBGbgQFDqVTrxni6oxHkynQo= MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 831b6e39-52ee-47ef-ecdc-08d6df6d1359 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2019 10:54:49.1342 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4425 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.111 Subject: [Qemu-devel] [RFC PATCH 2/2] cpus-common: assert BQL nesting within cpu-exclusive sections X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Assert that the cpu-exclusive sections are never entered/left with the BQL taken. Signed-off-by: Roman Kagan --- cpus-common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpus-common.c b/cpus-common.c index 023cfebfa3..9aa75fe1ba 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -174,6 +174,7 @@ void start_exclusive(void) CPUState *other_cpu; int running_cpus; + assert(!qemu_mutex_iothread_locked()); qemu_mutex_lock(&qemu_cpu_list_lock); exclusive_idle(); @@ -205,6 +206,7 @@ void start_exclusive(void) /* Finish an exclusive operation. */ void end_exclusive(void) { + assert(!qemu_mutex_iothread_locked()); qemu_mutex_lock(&qemu_cpu_list_lock); atomic_set(&pending_cpus, 0); qemu_cond_broadcast(&exclusive_resume); @@ -214,6 +216,7 @@ void end_exclusive(void) /* Wait for exclusive ops to finish, and begin cpu execution. */ void cpu_exec_start(CPUState *cpu) { + assert(!qemu_mutex_iothread_locked()); atomic_set(&cpu->running, true); /* Write cpu->running before reading pending_cpus. */ @@ -255,6 +258,7 @@ void cpu_exec_start(CPUState *cpu) /* Mark cpu as not executing, and release pending exclusive ops. */ void cpu_exec_end(CPUState *cpu) { + assert(!qemu_mutex_iothread_locked()); atomic_set(&cpu->running, false); /* Write cpu->running before reading pending_cpus. */