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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B15D7C433DF for ; Mon, 19 Oct 2020 15:05:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0162B2231B for ; Mon, 19 Oct 2020 15:05:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MF0uSzGh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0162B2231B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 38B6D6B007B; Mon, 19 Oct 2020 11:05:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 339B96B007D; Mon, 19 Oct 2020 11:05:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 202876B007E; Mon, 19 Oct 2020 11:05:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id E547A6B007B for ; Mon, 19 Oct 2020 11:05:15 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 864C91EE6 for ; Mon, 19 Oct 2020 15:05:15 +0000 (UTC) X-FDA: 77388998190.27.tooth26_5912f2f27237 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 6BCB73D663 for ; Mon, 19 Oct 2020 15:05:15 +0000 (UTC) X-HE-Tag: tooth26_5912f2f27237 X-Filterd-Recvd-Size: 4769 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Mon, 19 Oct 2020 15:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603119914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=enxheWw2McIocYr80cymg5IkoOYMMC2QNkvFOJ2MElw=; b=MF0uSzGhc0y575g1wlE+DURhHq0Fvex4lhBgp+SrWUpbbB3e7PDNLcWqyXmKlcrSX8LlIv 6ZDuJuC95cxSzHtOPTZXUIiUM7R9yEcKT6Aq7KqEAdiFf9QpqdzhFNMShKJeGC0m3gC+eI xJ9lWz0gE+iPvEetWsTVYlByNXWxlys= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-X870IfyvNgiV80OX02OmvQ-1; Mon, 19 Oct 2020 11:05:12 -0400 X-MC-Unique: X870IfyvNgiV80OX02OmvQ-1 Received: by mail-wm1-f70.google.com with SMTP id i9so54543wml.2 for ; Mon, 19 Oct 2020 08:05:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=enxheWw2McIocYr80cymg5IkoOYMMC2QNkvFOJ2MElw=; b=mQLhopiiWROFIPuvGjH6q6ISYWof33myZjMJbXU2CUZcgd+nzZ2JZ1qJGYvAb+OyFa JUpmIPITv1yNe9JiK6e3kt1n+yD3J130MZHpWLKYBh3Nlo6Yu+t4RqOD/UbU8XXRqwDh wqXxKXsI49PM1rIBWzsbfHU8oeXssUZUToMNyjdXzYr6NRye8tEjNA17zNTNJQ+iU+QX sRxezQYe5Byg/myMGsv+/LRuRI25hRFj8RQKfadNAMfD4fA3ss4ohoz135PnfruVfJL6 D+AIJjA05FFx29wPw8Yzz1Z4D3mmRRUxf2AIY2hCN4NvPDQATMEqDq5t49ll/J4hqsFF SiGA== X-Gm-Message-State: AOAM530A25TYAoRS3/Ygu7+3uajCMWCVcn4oJBRSnuAG2BXEDDRUeBn6 2huOlSFxiF1gqC7UB2GBJelE0QhQkfPgBIPE7fL9rHMOYOk+m2r5VOraJq3jF0h2zYcv9uGBPUf MllvMEcDS2N0= X-Received: by 2002:a1c:7213:: with SMTP id n19mr3382563wmc.188.1603119911237; Mon, 19 Oct 2020 08:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3S3i/HQ0OG5rt1LRdaMyszGX8TmDnqPMqyYCkULMyQOpS5GSU0GakFsswV+fZc56ZoUQOsw== X-Received: by 2002:a1c:7213:: with SMTP id n19mr3382540wmc.188.1603119910955; Mon, 19 Oct 2020 08:05:10 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id p9sm359354wma.12.2020.10.19.08.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:05:10 -0700 (PDT) Date: Mon, 19 Oct 2020 11:05:07 -0400 From: "Michael S. Tsirkin" To: Xie Yongji Cc: jasowang@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: Re: [RFC 3/4] vduse: grab the module's references until there is no vduse device Message-ID: <20201019110359-mutt-send-email-mst@kernel.org> References: <20201019145623.671-1-xieyongji@bytedance.com> <20201019145623.671-4-xieyongji@bytedance.com> MIME-Version: 1.0 In-Reply-To: <20201019145623.671-4-xieyongji@bytedance.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 19, 2020 at 10:56:22PM +0800, Xie Yongji wrote: > The module should not be unloaded if any vduse device exists. > So increase the module's reference count when creating vduse > device. And the reference count is kept until the device is > destroyed. > > Signed-off-by: Xie Yongji > --- > drivers/vdpa/vdpa_user/vduse_dev.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c > index 6787ba66725c..f04aa02de8c1 100644 > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > @@ -887,6 +887,7 @@ static int vduse_destroy_dev(u32 id) > kfree(dev->vqs); > vduse_iova_domain_destroy(dev->domain); > vduse_dev_destroy(dev); > + module_put(THIS_MODULE); > > return 0; > } > @@ -931,6 +932,7 @@ static int vduse_create_dev(struct vduse_dev_config *config) > > dev->connected = true; > list_add(&dev->list, &vduse_devs); > + __module_get(THIS_MODULE); > > return fd; > err_fd: This kind of thing is usually an indicator of a bug. E.g. if the refcount drops to 0 on module_put(THIS_MODULE) it will be unloaded and the following return will not run. > -- > 2.25.1