From patchwork Sun Apr 26 19:25:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11510973 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 A3AC192A for ; Sun, 26 Apr 2020 19:33:51 +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 7922320700 for ; Sun, 26 Apr 2020 19:33:51 +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="YwWoBmLJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7922320700 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]:43702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSn2D-0005K8-2i for patchwork-qemu-devel@patchwork.kernel.org; Sun, 26 Apr 2020 15:33:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47706) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSmud-0001Cu-Rz for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSmud-0005nJ-Cz for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:25:59 -0400 Received: from mout.web.de ([217.72.192.78]:42417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSmuc-0005iC-P7 for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:25:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1587929140; bh=6pc9YXNKhuW8jIo+3vRiEjlLgHIMsoHErd6rjWBDDRk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=YwWoBmLJDlw2wpSHh/fJOU8LgyEgfCctJzFNUz2fLQgmQDjWXa4p2VbSWVTfp79sn Zn/beSM+eQDSPpP5nlMHUJ43SMiIykmao5frkaFpmGjgtokJK8/4n0zdSUL3b7i4uY xnWDGDHZpn+z/cnkp3tKiC5Uf6dMRPYyTEJLen3E= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.95]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M09dQ-1jC62K0IlY-00uKv9; Sun, 26 Apr 2020 21:25:40 +0200 Date: Sun, 26 Apr 2020 21:25:38 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v2 1/6] 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:JlkzBR+7HxwSYRWS4OUWJUhDmB/2kMywrHnAnQ7UBqYh9h9TwMY OSN0sM3cSjIbv5pVtUHzVzfsUryRTwkgSOAANyr3ZvMtH3ljmxQpqqLecn5B/C3Mvk141SK ifaZBVe+AtJMC1568mz5q32eBGocLXzs2bTCnfPUur13xebqsi+Jp0KZXXdtIn/c7HmpoeH 0F/C6zP3GV9imHhGfVdZw== X-UI-Out-Filterresults: notjunk:1;V03:K0:6xeLxWDG2qU=:5pgQqo9w8wXgC8tnJlxFYC /dWZ6e+qeO2jBe/nxW4tG2AQ/uebqafJwMlowJUgSnh5cDtIOGBEahxSSjd/6bb7rbs+xfPVo 2aSC2pGBrlrXZRiXYSqSa07XIi8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K9 iXPTQFpeB/YNZ/q3Ot8tkbL28saenzB4uJR2oajld0iq6lmQQXnnV1fT6iMjD018a+MwAbpiT 7hrqexU+pyMGsAB6s Received-SPF: pass client-ip=217.72.192.78; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 15:25:57 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.78 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 crashes as colo_compare_handle_event assumes that it has exclusive access the queues, which are also concurrently accessed in the iothread. Create the bh with the AioContext of the iothread to fulfill these assumptions and fix the crashes. This is safe, because the bh already takes the appropriate locks. 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)