From nobody Sat Apr 27 15:13:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571044222; cv=none; d=zoho.com; s=zohoarc; b=QNVNN9jX2vkqJxTbU+5K5lgjuZFRams73v3jxkXgsbePbfzpxcGpmmcZNxryQn7qhTYwYC3KklIzRMK56IPEsu85XQPe0tMShlslvBZTZfbuNZ27xPz2NErkxX8gOYbJe90c5qGONrd1HLhfAnIaFz5FaRW4HxcdUCz6krto/+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571044222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mRZAGegaaPHQM+4m+cCaIcTVRYvwjxau2az7HZgdwBA=; b=myIeE6kgcJOv5XVivusQpgAPC/jIhHrZRMwVH14AFIbznkj9+JmmVs3R83WDhVicQu6CfhV55Rl2C8d8p86ex3rHP20MyXoao1pN+Mj4sH1cjLDPiuD9e1888HrQxoarB3lRI5pMqZ85NYEwKhA7rJffl6FHNFq8qlyDD02svgU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571044222229369.55126630550353; Mon, 14 Oct 2019 02:10:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJwLs-0005mG-GB; Mon, 14 Oct 2019 09:09:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJwLr-0005mB-UM for xen-devel@lists.xenproject.org; Mon, 14 Oct 2019 09:09:15 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4ae89e38-ee62-11e9-a531-bc764e2007e4; Mon, 14 Oct 2019 09:09:14 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C4700B65E; Mon, 14 Oct 2019 09:09:13 +0000 (UTC) X-Inumbo-ID: 4ae89e38-ee62-11e9-a531-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 14 Oct 2019 11:09:09 +0200 Message-Id: <20191014090910.9701-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191014090910.9701-1-jgross@suse.com> References: <20191014090910.9701-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 1/2] xen/netback: fix error path of xenvif_connect_data() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Wei Liu , "David S. Miller" , stable@vger.kernel.org, Paul Durrant MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" xenvif_connect_data() calls module_put() in case of error. This is wrong as there is no related module_get(). Remove the superfluous module_put(). Fixes: 279f438e36c0a7 ("xen-netback: Don't destroy the netdev until the vif= is shut down") Cc: # 3.12 Signed-off-by: Juergen Gross Reviewed-by: Paul Durrant --- drivers/net/xen-netback/interface.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/= interface.c index 240f762b3749..103ed00775eb 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -719,7 +719,6 @@ int xenvif_connect_data(struct xenvif_queue *queue, xenvif_unmap_frontend_data_rings(queue); netif_napi_del(&queue->napi); err: - module_put(THIS_MODULE); return err; } =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat Apr 27 15:13:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571044222; cv=none; d=zoho.com; s=zohoarc; b=HK2X9sIn8SJmKo+0R43KlWO7WEeyeX3wkv9VDVUvXVxkqxTthn87meSJHDIrmUdccS9CKANxkmz4yW6K2q3C52nyEx5Su+ueNsSHQGZXaCLTYe0v1CbxV0iWygEM54dC6kvKjZjK1Yxmn9Uz2EGDimnraGe1fheJO5u7TFFCJdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571044222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qui2qHJLWQbW0Resp/RTNG+UiAikv/hhUEXyOOhPRjc=; b=bS27lhE1D2BlbAhYfESyDh7x+fyXbPoBadm/OqpT53x3+a9rLnnzikB4jvxoIivnH8LRgIwViymXMk53OlAt2NeRiuO2Dkj6izZ+blRwdEJEy/JwacOg+hHFxBrcP/xEwgzdgFJG+UIyswqirc/yk8bT3JrGOiUbS1c2DWb1DkU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571044222037899.7213127754745; Mon, 14 Oct 2019 02:10:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJwLu-0005mW-OY; Mon, 14 Oct 2019 09:09:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iJwLt-0005mM-7k for xen-devel@lists.xenproject.org; Mon, 14 Oct 2019 09:09:17 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4aea7208-ee62-11e9-9375-12813bfff9fa; Mon, 14 Oct 2019 09:09:14 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EEC30B664; Mon, 14 Oct 2019 09:09:13 +0000 (UTC) X-Inumbo-ID: 4aea7208-ee62-11e9-9375-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 14 Oct 2019 11:09:10 +0200 Message-Id: <20191014090910.9701-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191014090910.9701-1-jgross@suse.com> References: <20191014090910.9701-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/2] xen/netback: cleanup init and deinit code X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Wei Liu , "David S. Miller" , Paul Durrant MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Do some cleanup of the netback init and deinit code: - add an omnipotent queue deinit function usable from xenvif_disconnect_data() and the error path of xenvif_connect_data() - only install the irq handlers after initializing all relevant items (especially the kthreads related to the queue) - there is no need to use get_task_struct() after creating a kthread and using put_task_struct() again after having stopped it. - use kthread_run() instead of kthread_create() to spare the call of wake_up_process(). Signed-off-by: Juergen Gross Reviewed-by: Paul Durrant --- drivers/net/xen-netback/interface.c | 114 +++++++++++++++++---------------= ---- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/= interface.c index 103ed00775eb..68dd7bb07ca6 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -626,6 +626,38 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_= t ring_ref, return err; } =20 +static void xenvif_disconnect_queue(struct xenvif_queue *queue) +{ + if (queue->tx_irq) { + unbind_from_irqhandler(queue->tx_irq, queue); + if (queue->tx_irq =3D=3D queue->rx_irq) + queue->rx_irq =3D 0; + queue->tx_irq =3D 0; + } + + if (queue->rx_irq) { + unbind_from_irqhandler(queue->rx_irq, queue); + queue->rx_irq =3D 0; + } + + if (queue->task) { + kthread_stop(queue->task); + queue->task =3D NULL; + } + + if (queue->dealloc_task) { + kthread_stop(queue->dealloc_task); + queue->dealloc_task =3D NULL; + } + + if (queue->napi.poll) { + netif_napi_del(&queue->napi); + queue->napi.poll =3D NULL; + } + + xenvif_unmap_frontend_data_rings(queue); +} + int xenvif_connect_data(struct xenvif_queue *queue, unsigned long tx_ring_ref, unsigned long rx_ring_ref, @@ -651,13 +683,27 @@ int xenvif_connect_data(struct xenvif_queue *queue, netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll, XENVIF_NAPI_WEIGHT); =20 + queue->stalled =3D true; + + task =3D kthread_run(xenvif_kthread_guest_rx, queue, + "%s-guest-rx", queue->name); + if (IS_ERR(task)) + goto kthread_err; + queue->task =3D task; + + task =3D kthread_run(xenvif_dealloc_kthread, queue, + "%s-dealloc", queue->name); + if (IS_ERR(task)) + goto kthread_err; + queue->dealloc_task =3D task; + if (tx_evtchn =3D=3D rx_evtchn) { /* feature-split-event-channels =3D=3D 0 */ err =3D bind_interdomain_evtchn_to_irqhandler( queue->vif->domid, tx_evtchn, xenvif_interrupt, 0, queue->name, queue); if (err < 0) - goto err_unmap; + goto err; queue->tx_irq =3D queue->rx_irq =3D err; disable_irq(queue->tx_irq); } else { @@ -668,7 +714,7 @@ int xenvif_connect_data(struct xenvif_queue *queue, queue->vif->domid, tx_evtchn, xenvif_tx_interrupt, 0, queue->tx_irq_name, queue); if (err < 0) - goto err_unmap; + goto err; queue->tx_irq =3D err; disable_irq(queue->tx_irq); =20 @@ -678,47 +724,18 @@ int xenvif_connect_data(struct xenvif_queue *queue, queue->vif->domid, rx_evtchn, xenvif_rx_interrupt, 0, queue->rx_irq_name, queue); if (err < 0) - goto err_tx_unbind; + goto err; queue->rx_irq =3D err; disable_irq(queue->rx_irq); } =20 - queue->stalled =3D true; - - task =3D kthread_create(xenvif_kthread_guest_rx, - (void *)queue, "%s-guest-rx", queue->name); - if (IS_ERR(task)) { - pr_warn("Could not allocate kthread for %s\n", queue->name); - err =3D PTR_ERR(task); - goto err_rx_unbind; - } - queue->task =3D task; - get_task_struct(task); - - task =3D kthread_create(xenvif_dealloc_kthread, - (void *)queue, "%s-dealloc", queue->name); - if (IS_ERR(task)) { - pr_warn("Could not allocate kthread for %s\n", queue->name); - err =3D PTR_ERR(task); - goto err_rx_unbind; - } - queue->dealloc_task =3D task; - - wake_up_process(queue->task); - wake_up_process(queue->dealloc_task); - return 0; =20 -err_rx_unbind: - unbind_from_irqhandler(queue->rx_irq, queue); - queue->rx_irq =3D 0; -err_tx_unbind: - unbind_from_irqhandler(queue->tx_irq, queue); - queue->tx_irq =3D 0; -err_unmap: - xenvif_unmap_frontend_data_rings(queue); - netif_napi_del(&queue->napi); +kthread_err: + pr_warn("Could not allocate kthread for %s\n", queue->name); + err =3D PTR_ERR(task); err: + xenvif_disconnect_queue(queue); return err; } =20 @@ -746,30 +763,7 @@ void xenvif_disconnect_data(struct xenvif *vif) for (queue_index =3D 0; queue_index < num_queues; ++queue_index) { queue =3D &vif->queues[queue_index]; =20 - netif_napi_del(&queue->napi); - - if (queue->task) { - kthread_stop(queue->task); - put_task_struct(queue->task); - queue->task =3D NULL; - } - - if (queue->dealloc_task) { - kthread_stop(queue->dealloc_task); - queue->dealloc_task =3D NULL; - } - - if (queue->tx_irq) { - if (queue->tx_irq =3D=3D queue->rx_irq) - unbind_from_irqhandler(queue->tx_irq, queue); - else { - unbind_from_irqhandler(queue->tx_irq, queue); - unbind_from_irqhandler(queue->rx_irq, queue); - } - queue->tx_irq =3D 0; - } - - xenvif_unmap_frontend_data_rings(queue); + xenvif_disconnect_queue(queue); } =20 xenvif_mcast_addr_list_free(vif); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel