From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 756DEC41535 for ; Tue, 19 Dec 2023 15:59:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFcUX-0000KP-Vf; Tue, 19 Dec 2023 10:58:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFcUV-0000K6-St for qemu-devel@nongnu.org; Tue, 19 Dec 2023 10:58:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rFcUS-0000tn-1q for qemu-devel@nongnu.org; Tue, 19 Dec 2023 10:58:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703001519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SPIlk2eJxTfq//Ywc/9wCHLMmNMOKaq1o79CCvNfbmo=; b=hU2d+EyaVpTyREkfHJpv3/pKhBU8rHCA1QBRy3VCuggNaJgtm93nQSXPtKoksa2iuB6hkD /MHskmmbWqIts2UmWdg5KEit1yucx1/HG62HAPn0IGxBPmWcRMZc7M55qgxPJ/krkNPY91 p2tNsbXcKTIIxmmIvyRTRKYWhL9f3JA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-cHhYhpcWNo24o_j-pPdaXw-1; Tue, 19 Dec 2023 10:58:34 -0500 X-MC-Unique: cHhYhpcWNo24o_j-pPdaXw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14BC63833354; Tue, 19 Dec 2023 15:58:33 +0000 (UTC) Received: from redhat.com (unknown [10.39.194.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68C43492BF0; Tue, 19 Dec 2023 15:58:27 +0000 (UTC) Date: Tue, 19 Dec 2023 16:58:26 +0100 From: Kevin Wolf To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , Vladimir Sementsov-Ogievskiy , Cleber Rosa , Xie Changlong , Paul Durrant , Ari Sundholm , Jason Wang , Eric Blake , John Snow , Eduardo Habkost , Wen Congyang , Alberto Garcia , Anthony Perard , "Michael S. Tsirkin" , Stefano Stabellini , qemu-block@nongnu.org, Juan Quintela , Paolo Bonzini , Coiby Xu , Fabiano Rosas , Hanna Reitz , Zhang Chen , Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= , Pavel Dovgalyuk , Peter Xu , Emanuele Giuseppe Esposito , Fam Zheng , Leonardo Bras , David Hildenbrand , Li Zhijian , xen-devel@lists.xenproject.org Subject: Re: [PATCH v2 06/14] block: remove AioContext locking Message-ID: References: <20231205182011.1976568-1-stefanha@redhat.com> <20231205182011.1976568-7-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231205182011.1976568-7-stefanha@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Am 05.12.2023 um 19:20 hat Stefan Hajnoczi geschrieben: > This is the big patch that removes > aio_context_acquire()/aio_context_release() from the block layer and > affected block layer users. > > There isn't a clean way to split this patch and the reviewers are likely > the same group of people, so I decided to do it in one patch. > > Signed-off-by: Stefan Hajnoczi > Reviewed-by: Eric Blake > Reviewed-by: Kevin Wolf > Reviewed-by: Paul Durrant > diff --git a/migration/block.c b/migration/block.c > index a15f9bddcb..2bcfcbfdf6 100644 > --- a/migration/block.c > +++ b/migration/block.c > @@ -313,22 +311,10 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds) > block_mig_state.submitted++; > blk_mig_unlock(); > > - /* We do not know if bs is under the main thread (and thus does > - * not acquire the AioContext when doing AIO) or rather under > - * dataplane. Thus acquire both the iothread mutex and the > - * AioContext. > - * > - * This is ugly and will disappear when we make bdrv_* thread-safe, > - * without the need to acquire the AioContext. > - */ > - qemu_mutex_lock_iothread(); > - aio_context_acquire(blk_get_aio_context(bmds->blk)); > bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_SIZE, > nr_sectors * BDRV_SECTOR_SIZE); > blk->aiocb = blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk->qiov, > 0, blk_mig_read_cb, blk); > - aio_context_release(blk_get_aio_context(bmds->blk)); > - qemu_mutex_unlock_iothread(); > > bmds->cur_sector = cur_sector + nr_sectors; > return (bmds->cur_sector >= total_sectors); With this hunk applied, qemu-iotests 183 fails: (gdb) bt #0 0x000055aaa7d47c09 in bdrv_graph_co_rdlock () at ../block/graph-lock.c:176 #1 0x000055aaa7d3de2e in graph_lockable_auto_lock (x=) at /home/kwolf/source/qemu/include/block/graph-lock.h:215 #2 blk_co_do_preadv_part (blk=0x7f38a4000f30, offset=0, bytes=1048576, qiov=0x7f38a40250f0, qiov_offset=qiov_offset@entry=0, flags=0) at ../block/block-backend.c:1340 #3 0x000055aaa7d3e006 in blk_aio_read_entry (opaque=0x7f38a4025140) at ../block/block-backend.c:1620 #4 0x000055aaa7e7aa5b in coroutine_trampoline (i0=, i1=) at ../util/coroutine-ucontext.c:177 #5 0x00007f38d14dbe90 in __start_context () at /lib64/libc.so.6 #6 0x00007f38b3dfa060 in () #7 0x0000000000000000 in () qemu_get_current_aio_context() returns NULL now. I don't completely understand why it depends on the BQL, but adding the BQL locking back fixes it. Kevin