Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp580340imm; Wed, 8 Aug 2018 02:00:30 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZt0wnCzkEbIeL71ztuucPnf9XGXcta3Ba6Zq2G2s2nFPxvow1pxBQToyu5pPxxWcrKOUF X-Received: by 2002:a63:6fcc:: with SMTP id k195-v6mr1679160pgc.135.1533718830686; Wed, 08 Aug 2018 02:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533718830; cv=none; d=google.com; s=arc-20160816; b=iL6N317j8TCOszk233wxDkNgYCOkVOTzznhbmsVs2IC6vkQDYgCIaNDhsh5+JM6kJh cMouAN+RM8fF9qZT2Jx13lYWDyOWjGZycP4ZXzNz6w9sbmPXM+sSiUt1a1waQOfBOmeq 8gpm8727MwYArkI3ksBWQnK1JRokpQ3d/fzjT9A2/5yx7uVsAEvfLcrBr+TQnrgscQEj AqIwJySuhPbCR2Qt+9xNR1bmq46305LeOK3qJXE+wvJs//i3CKZMW1KA8hCTXPaNuD75 XPvH3lXqeL2QiuJTMVMWEoj9Y5KIzf8XGutsIgTpdcquiHzkzqklgg+wmZ6OqoNJ6mqB JdwA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=MBhhTpWGqFtz5xFMqkCHOuMh+nPSkMe+En5xcC/PkqU=; b=lS/DlfYRqUcnvgbGIyjIDc6t0r7eOGwQDxu6szS+1YQeeytkSEqdBphfn/O6Lak4Jf /oWyR4cNwosrK4TkYHZEnAeQyj5xwxxzMVOlUYNQobA9JjdszZwuzpgIqkWygaXUg/VG RRwRkm5euVRRkXQv/WJ/v1g90rJrl+A8EFpESrQohhiY50ITFvdWpK0OHS+9e5ztAU1o TOWQU7E3GOcCVNXwJONCsgkaBchX4ACRhGjOvgt3kCqoXHgv7aC/oOOz5zM1vJ9b66yO wOiQjAFz0xHVVOZXLsCe0NuJqvEC2WV/ZqpCssQ3Vtbgw+9CmrhmuxLnMwdrjjvn3rbm uNaQ== 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 bd6-v6si3116862plb.379.2018.08.08.02.00.16; Wed, 08 Aug 2018 02:00:30 -0700 (PDT) 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 S1727442AbeHHLRI (ORCPT + 99 others); Wed, 8 Aug 2018 07:17:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51264 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727083AbeHHLRI (ORCPT ); Wed, 8 Aug 2018 07:17:08 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 949101A03F7F7; Wed, 8 Aug 2018 16:58:20 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Wed, 8 Aug 2018 16:58:17 +0800 Subject: Re: [PATCH] net/9p/trans_virtio.c: decrease the refcount of 9p virtio device when removing it To: Dominique Martinet References: <5B6AA65E.3030907@huawei.com> <20180808083630.GB16121@nautica> CC: "akpm@linux-foundation.org" , "Eric Van Hensbergen" , Ron Minnich , "Latchesar Ionkov" , Greg Kurz , "Linux Kernel Mailing List" , From: piaojun Message-ID: <5B6AB081.6090608@huawei.com> Date: Wed, 8 Aug 2018 16:57:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20180808083630.GB16121@nautica> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dominique, On 2018/8/8 16:36, Dominique Martinet wrote: > piaojun wrote on Wed, Aug 08, 2018: >> I found that 9pnet_virtio.ko could not be removed by rmmod command, and I >> could still found it by lsmod. The reason is that we forgot decrease the >> refcount of 9p virtio device by kobject_put. So we should put refcount in >> p9_virtio_remove. > > > Hmm, I cannot seem to reproduce this. Can you give more details on how > to get into stuck state? > I tried mounting something, accessing the sysfs files, etc to no avail. > > lsmod gives a counter to how many references there are to the module, > you can use that to debug a bit. > For example here I get this line just after loading the module: > 9pnet_virtio 32768 0 > > Then after mounting something there is one reference: > 9pnet_virtio 32768 1 > > Then unmounting puts that back to 0 and 'modprobe -r' (or rmmod) works. > I try to remove 9pnet_virtio.ko by 'rmmod 9pnet_virtio' as I want to replace it without rebooting system. Here I have not mount 9pfs yet, so the refcount is still 0. Before rmmod: # lsmod | grep 9p 9pnet_virtio 20480 0 9pnet 106496 1 9pnet_virtio virtio_ring 28672 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net virtio 16384 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net After rmmod: # lsmod | grep 9p 9pnet_virtio 20480 0 9pnet 106496 1 9pnet_virtio virtio_ring 28672 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net virtio 16384 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net Normally 9pnet_virtio should be invisible after rmmod like this: # lsmod | grep 9p 9pnet 106496 0 > > > > I dislike saying the next part but I think form also is important, > please bear with me: > > - shorter subject line, please. For example, you can lose 20 characters > by reodering words so there is no need for pronouns > "net/9p/virtio: decrease 9p virtio device refcount on removal" > > - I personally dislike commit messages that are "novelized" (that is, > put yourself as an actor and describe what you were doing) > That seems to be somewhat accepted as looking at the kernel's git log I > see some (few) commits using "I ..." that are not pull request messages > but if possible please avoid this style and try to describe facts, how > things are wrong, what got fixed and if required how. > To give an example again, this says the same thing: > "The 9pnet_virtio module could not be unloaded because we forgot to > decrease the refcount of the 9p virtio device with kobject_put. > > Put the reference in 9p_virtio_remove" > Your suggestion really makes sense, and I will make some improvment later. Thanks, Jun > > Thanks, >