Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flTLk-0007h9-TU for qemu-devel@nongnu.org; Fri, 03 Aug 2018 02:14:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1flTLf-0002GA-UP for qemu-devel@nongnu.org; Fri, 03 Aug 2018 02:14:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43298 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1flTLf-0002FK-Nl for qemu-devel@nongnu.org; Fri, 03 Aug 2018 02:14:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67A7C40216F4 for ; Fri, 3 Aug 2018 06:14:00 +0000 (UTC) References: <20180803024217.GC16395@lemon.usersys.redhat.com> From: Paolo Bonzini Message-ID: <2b1415a5-9553-386b-6cb5-8da000ac71da@redhat.com> Date: Fri, 3 Aug 2018 08:13:58 +0200 MIME-Version: 1.0 In-Reply-To: <20180803024217.GC16395@lemon.usersys.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Node deletion in aio_set_fd_handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org On 03/08/2018 04:42, Fam Zheng wrote: > Paolo, is this else branch dead code (or bug?): > > /* If the lock is held, just mark the node as deleted */ > if (qemu_lockcnt_count(&ctx->list_lock)) { > node->deleted = 1; > node->pfd.revents = 0; > } else { > /* Otherwise, delete it for real. We can't just mark it as > * deleted because deleted nodes are only cleaned up while > * no one is walking the handlers list. > */ > QLIST_REMOVE(node, node); > deleted = true; > } > > Since we are in a qemu_lockcnt_lock/unlock section? No, qemu_lockcnt_count returns the number of nested qemu_lockcnt_inc/dec (read-side) sections. lock/unlock is for the write side. The comment should be improved (e.g. "if a read is in progress, just mark the node as deleted"). Paolo