From patchwork Thu May 23 10:54:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 1104031 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="WH8U7TUp"; 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 458mjt2nFLz9sBK for ; Thu, 23 May 2019 20:59:57 +1000 (AEST) Received: from localhost ([127.0.0.1]:33657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTlRz-0000tZ-MJ for incoming@patchwork.ozlabs.org; Thu, 23 May 2019 06:59:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTlN8-0005GH-4X 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 1hTlN6-0004tD-Jl for qemu-devel@nongnu.org; Thu, 23 May 2019 06:54:53 -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-CU for qemu-devel@nongnu.org; Thu, 23 May 2019 06:54:52 -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=Tv2Cbli/Tqvu7owPtK43D91girBk3sDgN7PJDxaDH2Y=; b=WH8U7TUpwDL7M5fgaDthqF46qEihBfd/WGJeHI1c+gutrh7P7nt+pDqiJcAcavTSx2oP5awKIXeujLxXpDY6FYcFqtTdllWU/JsRLAzSNkyQ8p1+QxCIjrg/lk2F2Y/DGINE15bdixgisc3y42tE7fxuq4mJJ+0uS3d7WF8uDTg= 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:48 +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:48 +0000 From: Roman Kagan To: Paolo Bonzini , "qemu-devel@nongnu.org" Thread-Topic: [RFC PATCH 1/2] cpus-common: nuke finish_safe_work Thread-Index: AQHVEVXwRYejWVDaoEKIMQ4+lvoMHA== Date: Thu, 23 May 2019 10:54:48 +0000 Message-ID: <20190523105440.27045-2-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: 8f746d30-988c-4662-6c5a-08d6df6d12fe 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:1443; 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: iQinH8RizUEZu28b2N8lSGYmFRqFrlge6WBPSDwQQf3+3XXRjgAdq9mSWruCLthVkX3cGulT+85GhzTxH7doXQHut5PQ8XKwYzt8FD+Vkimm1RmBRCdK8ttrFw1xMvgmmHEwtgbS19sE370yRtxVN10jqzYd73tSQTA5IkMwmOMpcuKjcF2FuUbNotBrW5x+XBR7ooXb2O1WyGXSP4eJM6RHVo0jlImaqnaZNtw20/Z8BwUOB6Kre7Ylnvk9eSzRmGrp4JN84LgP33fnj1asOTh4bDxgB/rcl8KN1/F3VrZVMiMAXCGDxVOuPw0m3l1yAs9p8G4OQF0VqGZ0vjE42DgZ7asNHn/q9KFX0ll44wG6HH4HtMPTMzz4fz8GbT0DSAosQ008zHXR8VLh1eo+Sh+SEfLeYoT5JfbbRtYCpdE= MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f746d30-988c-4662-6c5a-08d6df6d12fe X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2019 10:54:48.5235 (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 1/2] cpus-common: nuke finish_safe_work 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" It was introduced in commit b129972c8b41e15b0521895a46fd9c752b68a5e, with the following motivation: Because start_exclusive uses CPU_FOREACH, merge exclusive_lock with qemu_cpu_list_lock: together with a call to exclusive_idle (via cpu_exec_start/end) in cpu_list_add, this protects exclusive work against concurrent CPU addition and removal. However, it seems to be redundant, because the cpu-exclusive infrastructure provides suffificent protection against the newly added CPU starting execution while the cpu-exclusive work is running, and the aforementioned traversing of the cpu list is protected by qemu_cpu_list_lock. Besides, this appears to be the only place where the cpu-exclusive section is entered with the BQL taken, which has been found to trigger AB-BA deadlock as follows: vCPU thread main thread ----------- ----------- async_safe_run_on_cpu(self, async_synic_update) ... [cpu hot-add] process_queued_cpu_work() qemu_mutex_unlock_iothread() [grab BQL] start_exclusive() cpu_list_add() async_synic_update() finish_safe_work() qemu_mutex_lock_iothread() cpu_exec_start() So remove it. This paves the way to establishing a strict nesting rule of never entering the exclusive section with the BQL taken. Signed-off-by: Roman Kagan --- cpus-common.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cpus-common.c b/cpus-common.c index 3ca58c64e8..023cfebfa3 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -69,12 +69,6 @@ static int cpu_get_free_index(void) return cpu_index; } -static void finish_safe_work(CPUState *cpu) -{ - cpu_exec_start(cpu); - cpu_exec_end(cpu); -} - void cpu_list_add(CPUState *cpu) { qemu_mutex_lock(&qemu_cpu_list_lock); @@ -86,8 +80,6 @@ void cpu_list_add(CPUState *cpu) } QTAILQ_INSERT_TAIL_RCU(&cpus, cpu, node); qemu_mutex_unlock(&qemu_cpu_list_lock); - - finish_safe_work(cpu); } void cpu_list_remove(CPUState *cpu)