From patchwork Wed Apr 8 18:33:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11480639 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 B798214B4 for ; Wed, 8 Apr 2020 18:40:05 +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 26C802072F for ; Wed, 8 Apr 2020 18:40:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="WyesaHeA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26C802072F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMFcJ-0008G4-P2 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Apr 2020 14:40:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMFWa-0006dy-QT for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMFWZ-0004TB-PI for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:08 -0400 Received: from mout.web.de ([212.227.15.4]:38207) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMFWZ-0004Qz-B7 for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1586370831; bh=w3iV2InOTr+OaFsy3Tv/Ld/RwwZF35icTcq2qLOoinc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=WyesaHeA3VGLUr2X3l/h/2sFEdSpARmEoLQWh/6j9QmPifbdSzV5J5Fd0iRWJjbwr hOwND/EplZQe2O0XU7pPR1WQ5FwPqZGhnQ/pLOQlGs1Bef/nbNd6j3xFXnqnfa5/G7 PlLg5DlZiMr+zK+UoBh04xKdKnk8xYrqlfvK/MNg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.62]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LdmgV-1ivkXU29pr-00j2Rc; Wed, 08 Apr 2020 20:33:51 +0200 Date: Wed, 8 Apr 2020 20:33:49 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH 1/3] net/colo-compare.c: Create event_bh with the right AioContext Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:a9zfYhdq6WD3p57xVTNR97ZmTuwTC78GUI//Eu+/9hozsshzWdH Z6XRQbkOWu9SyFw0HSHDwp3PbaSuiPlckgmXwzi1BAklnudNovtyHOBty699Qj6ZRk8ge/H TLubcIXZnfBkGu4ynQIZcNuiDx+IMnjjOHtkuB9lWeUnzLt2c81FkqA2W0WbSPeAw12SP6x n9+Ulzm9NiRgJ/rvz9a1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:yllrF+KxOW4=:GSiDFyfxRFgVKhlWsMVzWY B0JY4dl+W4RSvQ2AIPycUWjyJvAgxjbaX1CUZxVLYvYd5EriNIvDai6Nx5hW58VpNixhYhzBq tFqgq7CgxN/xNJXpN9hxMkJm0dzUb0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4eA83z3Hla0YWM9pQWLjEWOQ9XRRdTLyK6ZB5i45m/yydB8e9XBqPZUUz+Fs0DqNNOhJG FgrO9LmZ48HrhZ8/T X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.4 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: Zhang Chen , Jason Wang , Paolo Bonzini , Li Zhijian , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qemu_bh_new will set the bh to be executed in the main loop. This causes problems as colo_compare_handle_event assumes that it has exclusive access the queues, which are also accessed in the iothread. It also assumes that it runs in a different thread than the caller and takes the appropriate locks. Create the bh with the AioContext of the iothread to fulfill these assumptions. Signed-off-by: Lukas Straub Reviewed-by: Zhang Chen Reviewed-by: Derek Su Tested-by: Derek Su --- net/colo-compare.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 10c0239f9d..1de4220fe2 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -890,6 +890,7 @@ static void colo_compare_handle_event(void *opaque) static void colo_compare_iothread(CompareState *s) { + AioContext *ctx = iothread_get_aio_context(s->iothread); object_ref(OBJECT(s->iothread)); s->worker_context = iothread_get_g_main_context(s->iothread); @@ -906,7 +907,7 @@ static void colo_compare_iothread(CompareState *s) } colo_compare_timer_init(s); - s->event_bh = qemu_bh_new(colo_compare_handle_event, s); + s->event_bh = aio_bh_new(ctx, colo_compare_handle_event, s); } static char *compare_get_pri_indev(Object *obj, Error **errp)