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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 74416C43467 for ; Mon, 19 Oct 2020 15:47:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9922122200 for ; Mon, 19 Oct 2020 15:47:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZNZaRoPG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9922122200 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 16C776B0074; Mon, 19 Oct 2020 11:47:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F5226B0075; Mon, 19 Oct 2020 11:47:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFF8C6B0078; Mon, 19 Oct 2020 11:47:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id BBCB86B0074 for ; Mon, 19 Oct 2020 11:47:46 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 57F241EE6 for ; Mon, 19 Oct 2020 15:47:46 +0000 (UTC) X-FDA: 77389105332.04.room84_410a31927238 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 3442E80051B2 for ; Mon, 19 Oct 2020 15:47:46 +0000 (UTC) X-HE-Tag: room84_410a31927238 X-Filterd-Recvd-Size: 5748 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Mon, 19 Oct 2020 15:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603122464; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k2MEEZ/K/6boUhJVR6fTJ0aMQt927v1axXDlH3hhhjI=; b=ZNZaRoPG+U+dgaQirphJ/apY1ABOCwpgEZcVtc8aeTNWp/dtOgbtHgMwxTBQUKpam+9YZU mbRe2s/CuKpfAbxLOgQhzVNYVf8/5UORaixQy2DTNsu4jW8gYLkXei3GRI+FFDc89wQmK5 T7bCFP3Brh69+l3YZzH7eiJcCw/Shi4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-yKlCYeWGNiaf5BCvTerzyw-1; Mon, 19 Oct 2020 11:47:40 -0400 X-MC-Unique: yKlCYeWGNiaf5BCvTerzyw-1 Received: by mail-wm1-f71.google.com with SMTP id r7so90646wmr.5 for ; Mon, 19 Oct 2020 08:47:40 -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:content-transfer-encoding :in-reply-to; bh=k2MEEZ/K/6boUhJVR6fTJ0aMQt927v1axXDlH3hhhjI=; b=aNYJH+sAAjlsYkrkIaFvzHiKHd8EfIjyvkYEH+5vSzJjQ/piDnIEwEyabj00itS7S/ hgmbRdWPT0//eGciedTgmLnHDf7hQHekUb6zZ/a2k/oHt8Zse7eQBosaLpk1oTN0ReqS /VB5CkGg1t9Ydzj4mjPMtEds7T8YfYiOBAXxqdine09Fi3nLZE7n4FsiRjsrWC/BNZvd 6wCHsEHmuykfEBwqkCRu+lYfNIP1j//4i8KXvj7sPWPCl6JDW9NKoCLeoTgFMAIzZ7k3 xkBmnr1+cYmjlxlhOSf0psDFRJA7UlRLasBDk4EzASBM97IDxwWtFhvCD9uqJ2fWEbs1 1kbA== X-Gm-Message-State: AOAM53001n1NZfWCWaOohz0ihOwyN+NxNjb6mn6y6DdgKuv9Lbo1ORvT odEmKC+4r5BODrcL+Mzz91rHayDf7HvBT1ciSSkimNMrhjXqdgSePxr83XI72O0v80+ifz0ouYH WZEYd+X/vDG4= X-Received: by 2002:a1c:9d8e:: with SMTP id g136mr66184wme.18.1603122459093; Mon, 19 Oct 2020 08:47:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdIRz4VuTBoS8/Q6vEyJSCJtn8rj2adXrZn7kBKrSJM2JfAA7M22ciodXplTR6Hvp/Z8Q2ZQ== X-Received: by 2002:a1c:9d8e:: with SMTP id g136mr66171wme.18.1603122458923; Mon, 19 Oct 2020 08:47:38 -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 h128sm515626wme.38.2020.10.19.08.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:47:38 -0700 (PDT) Date: Mon, 19 Oct 2020 11:47:35 -0400 From: "Michael S. Tsirkin" To: =?utf-8?B?6LCi5rC45ZCJ?= Cc: jasowang@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: Re: [External] Re: [RFC 3/4] vduse: grab the module's references until there is no vduse device Message-ID: <20201019114701-mutt-send-email-mst@kernel.org> References: <20201019145623.671-1-xieyongji@bytedance.com> <20201019145623.671-4-xieyongji@bytedance.com> <20201019110359-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 In-Reply-To: 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 11:44:36PM +0800, =E8=B0=A2=E6=B0=B8=E5=90=89 wro= te: >=20 >=20 > On Mon, Oct 19, 2020 at 11:05 PM Michael S. Tsirkin wr= ote: >=20 > 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 > > --- > >=C2=A0 drivers/vdpa/vdpa_user/vduse_dev.c | 2 ++ > >=C2=A0 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vd= pa_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) > >=C2=A0 =C2=A0 =C2=A0 =C2=A0kfree(dev->vqs); > >=C2=A0 =C2=A0 =C2=A0 =C2=A0vduse_iova_domain_destroy(dev->domain); > >=C2=A0 =C2=A0 =C2=A0 =C2=A0vduse_dev_destroy(dev); > > +=C2=A0 =C2=A0 =C2=A0module_put(THIS_MODULE); > >=C2=A0 > >=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0; > >=C2=A0 } > > @@ -931,6 +932,7 @@ static int vduse_create_dev(struct vduse_dev_= config > *config) > >=C2=A0 > >=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->connected =3D true; > >=C2=A0 =C2=A0 =C2=A0 =C2=A0list_add(&dev->list, &vduse_devs); > > +=C2=A0 =C2=A0 =C2=A0__module_get(THIS_MODULE); > >=C2=A0 > >=C2=A0 =C2=A0 =C2=A0 =C2=A0return fd; > >=C2=A0 err_fd: >=20 > 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. >=20 >=20 >=20 > Should this happen?=C2=A0 The refcount should be only decreased to 0 af= ter the > misc_device is closed? >=20 > Thanks, > Yongji >=20 OTOH if it never drops to 0 anyway then why do you need to increase it? >=20 >=20 > > -- > > 2.25.1 >=20 >=20