Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7973340ybc; Fri, 29 Nov 2019 03:57:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwOOa/24IH4WQCXjCHvdmDlOfK8qN9oo/A5LY/+7FPhKoA+gnsPyD2OCOIb7AiRG8CZVwYT X-Received: by 2002:aa7:c141:: with SMTP id r1mr14664637edp.126.1575028649863; Fri, 29 Nov 2019 03:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575028649; cv=none; d=google.com; s=arc-20160816; b=AjMFx8FOQGGs+bf4EOegfOOV1WvwwoeSAheZLqzq74lyNJ7qY98HBT4QH7+QINPN/l 7BqW6ZEQ2Av1emPEwyi2eHdJ79Tj7ZdhzewtEmxmFAiFExkoAca8mwTZ247uXjrSa9og QJavb6v5/s7bR5DnleOON8yA2WiFsBpWIPzsLQL9FQ6X07x6picM68e/6aOAdcGlKzPM ZYejBDneZUJeFvBM7jI5VxRi+cXUKQnqBEke/uwquD+IBxRVDTaZoSHXwvH7jpLq+7B8 cZ6gPMZyT75uWM+KWdsFvE76JCtY404B4anaWtKTmi9io+U9+3lNALOyJhdS0o3/vd9X NPJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=IfZTK7IKPXkhWmS8++kbToNz0NNfsVNmdOmcL5HJq0s=; b=0qxRw/6gFtHqMreSbsG3qm/k8C0XEODcLNKA/A/Fpuh6/xTZpRNs8OlovfL3wtU2WY fE+OMFkAHuaMSbPiLtxlft7OyhZOpwvgNfbL6uw2aU3I/6G1QdtnI4yPXvGPtaudRUZw OyfUr7pvxFz3G/vHpwDjaNi4pgTiE3uON8iv+GdQ30tyypZJEUmaG/jJWI86JumbgjGJ 3KcsFy8PsgSPE8Rk7Mtc+7mCusK18JkPUTKQLJlUzo4wOMHfWoPkzYj8Ma+LSwUpmn8w L95Dcajs3uVH4hz2SreFk4ApUb/RpTZt7rmH6/vco+8YthvR6MweiLPnV6swZGt1/EEp JMbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si13887884eju.84.2019.11.29.03.57.05; Fri, 29 Nov 2019 03:57:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbfK2L4I (ORCPT + 99 others); Fri, 29 Nov 2019 06:56:08 -0500 Received: from mx2.suse.de ([195.135.220.15]:50150 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725892AbfK2L4I (ORCPT ); Fri, 29 Nov 2019 06:56:08 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 521DBACC4; Fri, 29 Nov 2019 11:56:06 +0000 (UTC) Subject: Re: [PATCH] xen-blkback: allow module to be cleanly unloaded To: Paul Durrant Cc: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Jens Axboe , Konrad Rzeszutek Wilk References: <20191129113131.1954-1-pdurrant@amazon.com> From: Jan Beulich Message-ID: <6d0a90f6-3def-a970-6dca-8d1f3eb66c1c@suse.com> Date: Fri, 29 Nov 2019 12:56:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191129113131.1954-1-pdurrant@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.11.2019 12:31, Paul Durrant wrote: > --- a/drivers/block/xen-blkback/xenbus.c > +++ b/drivers/block/xen-blkback/xenbus.c > @@ -173,6 +173,8 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid) > init_completion(&blkif->drain_complete); > INIT_WORK(&blkif->free_work, xen_blkif_deferred_free); > > + __module_get(THIS_MODULE); > + > return blkif; > } > > @@ -320,6 +322,8 @@ static void xen_blkif_free(struct xen_blkif *blkif) > > /* Make sure everything is drained before shutting down */ > kmem_cache_free(xen_blkif_cachep, blkif); > + > + module_put(THIS_MODULE); > } I realize there are various example of this in the tree, but isn't this a flawed approach? __module_get() (nor even try_module_get()) will prevent an unload attempt ahead of it getting invoked, while execution is already in this module's .text section. I think the xenbus driver should do this before calling ->probe(), in case of its failure, and after a successful call to ->remove(). Jan