From nobody Wed Apr 24 11:17:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1590134807; cv=none; d=zohomail.com; s=zohoarc; b=IDGGSI8qlVU6t7CMmceR2ZSQ5kVPE+QXWYt+mea52DC/XKkLLdq7rw9eKgG4aQqNlxSOvPKTyL8QgLtReeer1xGOikAgL+MA7ztBS1lXi4NeyvGldrSAAwAJALNlqgorFkikGjVXquruhbB+Vwa7pVHE+6EWXLh7DZwEj+nL7aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590134807; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=f6g3VC+ylAATwcZL2gTiBgLAXNVb44fcid16Oj6ST8I=; b=L8lkf5HhzWA6UF/0OUtcsEPlmxqrLazqqgVRIod3TItMRxNVbTNsnjL9ww78GiurdUDF3+442MyG5Rc7F3yzPjfAVGTS06UlqwGlBnbkGkn/Z+t5FRCr1JVZKi0qEjwLpDAYPG0gJf6s3W1ywBWpqlUmwCtEXULBAEhc+HO6/pE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15901348073021002.761360302864; Fri, 22 May 2020 01:06:47 -0700 (PDT) Received: from localhost ([::1]:54254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jc2ha-0002wL-4C for importer@patchew.org; Fri, 22 May 2020 04:06:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc2fV-0005qs-Ke for qemu-devel@nongnu.org; Fri, 22 May 2020 04:04:37 -0400 Received: from mga17.intel.com ([192.55.52.151]:30272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jc2fU-0006Tw-OV for qemu-devel@nongnu.org; Fri, 22 May 2020 04:04:37 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 01:04:34 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005.fm.intel.com with ESMTP; 22 May 2020 01:04:33 -0700 IronPort-SDR: EHGmuRXRzNhrw9/HoWiS1+YWStldh/YHAy6MCiHl6n/+i0CzCltQ6PUKSW3rcJJi/aNDutic6G BQzz1735UYfg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False IronPort-SDR: E+OC3ShZm7B2ExWJrAuFQZKoy5LJnDM9C0MWflpi7BybGSQ47/ZVU9QzLp2R3SpDiKvcaB5IuY qmnUx6gwlLUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,420,1583222400"; d="scan'208";a="467104538" From: Zhang Chen To: Jason Wang Subject: [PATCH V2 1/7] net/colo-compare.c: Create event_bh with the right AioContext Date: Fri, 22 May 2020 15:53:51 +0800 Message-Id: <20200522075357.19883-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522075357.19883-1-chen.zhang@intel.com> References: <20200522075357.19883-1-chen.zhang@intel.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.151; envelope-from=chen.zhang@intel.com; helo=mga17.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 04:04:33 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, FROM_ADDR_WS=2.999, FROM_WSP_TRAIL=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Lukas Straub , qemu-dev , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Lukas Straub 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 Signed-off-by: Zhang Chen --- 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 c07e7c1c09..e557da70e5 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -890,6 +890,7 @@ static void colo_compare_handle_event(void *opaque) =20 static void colo_compare_iothread(CompareState *s) { + AioContext *ctx =3D iothread_get_aio_context(s->iothread); object_ref(OBJECT(s->iothread)); s->worker_context =3D iothread_get_g_main_context(s->iothread); =20 @@ -906,7 +907,7 @@ static void colo_compare_iothread(CompareState *s) } =20 colo_compare_timer_init(s); - s->event_bh =3D qemu_bh_new(colo_compare_handle_event, s); + s->event_bh =3D aio_bh_new(ctx, colo_compare_handle_event, s); } =20 static char *compare_get_pri_indev(Object *obj, Error **errp) --=20 2.17.1