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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05C4BC07E9D for ; Wed, 28 Sep 2022 00:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231993AbiI1AC4 (ORCPT ); Tue, 27 Sep 2022 20:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbiI1ACx (ORCPT ); Tue, 27 Sep 2022 20:02:53 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 624E7B6D54; Tue, 27 Sep 2022 17:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=guf6A20S3MwV/sozfojk73A9a5gLzuwZOHcY81yWs9s=; b=V+2f75PvljF3lRCCcfchpHgtNm Cb5hEGrH1L7Clwr8w8F7ZIUtHCA9POwQ/uCm0CYoJu+DUAoAMFK8Dbg9Wn6nkXqLQ9zBgNLPKvlYG 7iv7QdXWG0OAjOWs4gprIa7W2gbycW42Cw1Yr1Y0mTNY7N9zVAi9hJh3154PBmlK0vkYTeQ3BBWNp UE8exWdMXdRjbMME6NZF08HjFatVITEMX2av+3crRXQDLtkeQYPW0COvoZLi7/69j0YWfZzodsGoP jQg1zzz4940cYoA39xTRhJc6Ff/82hZ/QTZZX2Evyn9i5Khn2aY31vjgF6+GXzAj239pUHPHfLzW8 ns9Wsx+Q==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1odKXE-00DELX-JK; Wed, 28 Sep 2022 00:02:44 +0000 Date: Tue, 27 Sep 2022 17:02:44 -0700 From: Luis Chamberlain To: Bart Van Assche , Mauro Carvalho Chehab Cc: "Martin K . Petersen" , linux-scsi@vger.kernel.org, Christoph Hellwig , Ming Lei , Hannes Reinecke , John Garry , Mike Christie , Krzysztof Kozlowski , Greg Kroah-Hartman , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, "James E.J. Bottomley" , Tejun Heo Subject: Re: [PATCH v5 6/7] module: Improve support for asynchronous module exit code Message-ID: References: <20220914225621.415631-1-bvanassche@acm.org> <20220914225621.415631-7-bvanassche@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 20, 2022 at 10:13:40AM -0700, Bart Van Assche wrote: > On 9/14/22 15:56, Bart Van Assche wrote: > > Some kernel modules call device_del() from their module exit code and > > schedule asynchronous work from inside the .release callback without waiting > > until that callback has finished. As an example, many SCSI LLD drivers call > > scsi_remove_host() from their module exit code. scsi_remove_host() may > > invoke scsi_device_dev_release_usercontext() asynchronously. > > scsi_device_dev_release_usercontext() uses the host template pointer and > > that pointer usually exists in static storage in the SCSI LLD. Support > > using the module reference count to keep the module around until > > asynchronous module exiting has completed by waiting in the delete_module() > > system call until the module reference count drops to zero. > > Hi Luis, > > I'd like to know your opinion about this patch since you are the maintainer > of the kernel module system. See this patch which extends the documentation of try_module_get(): https://lkml.kernel.org/r/20211029184500.2821444-7-mcgrof@kernel.org You can ignore discussion around the thread as sadly it is just irrelevant stuff not about that patch. But the logic it spells out is still true. So, in short, using try_module_get() on exit is actually the wrong thing to do and it is no surprise it would fail. I haven't gotten yet around to reviewing Mauro's driver API which let's you unbind drivers, but it sounds related so I CC'd you on that. So I'd like to ask instead if an alternative to using try_module_get() on exit would be better here and for the future. Luis