From patchwork Tue Feb 7 12:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 53864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2825429wrn; Tue, 7 Feb 2023 04:41:56 -0800 (PST) X-Google-Smtp-Source: AK7set8jyDH9w6x5dVpUWLv4GklTaI4EL3xRYAd6Ih0cbdC034dZjvBpJHSkFZnsQBNJRvplw3xC X-Received: by 2002:a17:902:ec8e:b0:198:f574:1d2c with SMTP id x14-20020a170902ec8e00b00198f5741d2cmr2717197plg.24.1675773716490; Tue, 07 Feb 2023 04:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675773716; cv=none; d=google.com; s=arc-20160816; b=CF0iVB9WgdvdvQU8jsRChaSkm381Tr1IxTe+SFqYi1JSmsnKTR0em2PBFqXYMhImZ6 tYZs0JUNQayuNfxrpV4hreh12oQNPmbpt4LRtm3TbRgcR2yPTpZDRjk72sZv5llZMdUp aOIpH10WdLndrZ5TX8WsXk26ray31EANshFWXobOGiC11E4uaJALdS5aehz1JCq++Zr9 9CK17Ku6kNqwtkiqmCElMkFl2XoM+EpJbwOiayVcSjYT7hode04LZZIozCcppHCf9o4G aryCQRHbXJEIp1FC3l0qQkAlHyOtQvm2i5/o6Vk9Voi3NskDIzbKUrttIXAWjZ3Eh5mr g7eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U05d1FEwEV4kFx0/0h+z779sxBqZgM/TYt1Z/WbUp1A=; b=n4FFxlHno524qh4eJURbbu6UFvwXChbAXTM+ycpLJLM9FQFPTh7zyfKnyhCW7Yqvp3 8bQ3DZGBiRT8gkao2FHXuCLH061sIkGuYR9zoL8xN3loqqj3zYWdhSTzMEDNHh1kAQga StIl/Gkp9xaBnvrdQNQt4JnHUT99DVXRYQvEx00uM0h7fTGGJ48LINZsg6q76ZY0fbPd PO1UncbiTODAFk06djbQMPKrhcnDeZ/OjEytCZJDHyJws8enNI3O9lrF9x1to9jHmNpy 4V+aIIdd3kD8iHySLz4IQibxjptKBT9dc1dk/8wMyRqD6N6SELvMY+k3gRxxhlk/gFwU 9P1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Bg6A8O/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a170902700700b001978f72aee3si13205907plk.502.2023.02.07.04.41.44; Tue, 07 Feb 2023 04:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Bg6A8O/9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbjBGMhb (ORCPT + 99 others); Tue, 7 Feb 2023 07:37:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbjBGMhZ (ORCPT ); Tue, 7 Feb 2023 07:37:25 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78761E2B9; Tue, 7 Feb 2023 04:37:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675773444; x=1707309444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LiSxcagqNB+5kdb9BVVbcrT1QJr/8pqeefoLK3ITSQA=; b=Bg6A8O/9PBpkWNomYDrP164OIOQjpvRzyp0WemoXr22Fo9b38t2NBSjQ WGkDnVP/Lpl91hxUCxU8KX/Yr0b+ZHMnj9suPYkf27Jw04QCQ3y1XPZhi EUmX6Ae2GQlZRY1U83M+6u6quaj69b8ifNUZdTWShGdr7SRrHlStutATr CS5iQtcMsOvKOwLP0NpkWkycjYkTIwyDT+x4SDvODSyqEwZSrXGy5WCwg BrX1dAo4eZFGwKadKS2Okhzgv7LuuVZ01tIQb6s2zrkiKQvlfJCb+pspA EAVO4yKxga2sCnsL775hQxllTK3WB0l0kryXBXsURqH/nMO3C65pVJBpC g==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="309140933" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="309140933" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 04:37:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="697268000" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="697268000" Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by orsmga008.jf.intel.com with ESMTP; 07 Feb 2023 04:37:22 -0800 From: Wei Wang To: pbonzini@redhat.com, seanjc@google.com, mhal@rbox.co Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Wang Subject: [PATCH v2 2/2] kvm/eventfd: use list_for_each_entry when deassign ioeventfd Date: Tue, 7 Feb 2023 20:37:13 +0800 Message-Id: <20230207123713.3905-3-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230207123713.3905-1-wei.w.wang@intel.com> References: <20230207123713.3905-1-wei.w.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757176100381135385?= X-GMAIL-MSGID: =?utf-8?q?1757176100381135385?= Simpify kvm_deassign_ioeventfd_idx to use list_for_each_entry as the loop just ends at the entry that's founded and deleted. Signed-off-by: Wei Wang Reviewed-by: Sean Christopherson --- virt/kvm/eventfd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 1b277afb545b..2b56a3c81957 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -868,7 +868,7 @@ static int kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx, struct kvm_ioeventfd *args) { - struct _ioeventfd *p, *tmp; + struct _ioeventfd *p; struct eventfd_ctx *eventfd; struct kvm_io_bus *bus; int ret = -ENOENT; @@ -882,8 +882,7 @@ kvm_deassign_ioeventfd_idx(struct kvm *kvm, enum kvm_bus bus_idx, mutex_lock(&kvm->slots_lock); - list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) { - + list_for_each_entry(p, &kvm->ioeventfds, list) { if (p->bus_idx != bus_idx || p->eventfd != eventfd || p->addr != args->addr ||