public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Greg KH <greg@kroah.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND] char_dev: add cdev->release() and convert	cdev_alloc() to use it
Date: Thu, 28 Aug 2008 19:44:55 +0200	[thread overview]
Message-ID: <48B6E417.5030605@kernel.org> (raw)
In-Reply-To: <20080828173813.GC18097@kroah.com>

Greg KH wrote:
> On Thu, Aug 28, 2008 at 06:56:48PM +0200, Tejun Heo wrote:
>> Greg KH wrote:
>>> Ick, I really don't want struct cdev to be used for lifecycle
>>> management, as it is only for major:minor stuff.  Why do you want to
>>> make this change?
>> Well, as cdev can be referenced from userspace, ->release is required
>> for most purposes.  The reason why devices have been getting by without
>> it is because most chardevs are created on module load and destroyed on
>> module unload and in the meantime cdev refcount virtually equals module
>> refcnt, but I'm fairly sure we have cases where cdev can be destroyed
>> for other reasons then module unloading and it's very likely those cases
>> are buggy in the current code (backing structure gone bug cdev still
>> hanging around).
> 
> Hm, I thought Al covered that when he created the cdev interface, I
> would be a bit supprised if this was the case.

Hmmm.... I've never actually audited the code so... it could be that no
chardev is created and destroyed that way, I guess.

>> As CUSE can create and destroy devices regardless of module reference
>> count, it falls in the second category and needs cdev->release() to make
>> sure the backing structure doesn't go away till cdev is released.
> 
> But CUSE should be it's own module, right?  And it would "own" the cdev,
> so the module and cdev count should be fine and matching.  The userspace
> code could go away but the CUSE code should handle that with a different
> reference count.  This is the way that hardware drivers handle the
> issue.

The problem is not the device to talk to CUSE (/dev/cuse as in
/dev/fuse), for which module refcount and device refcount match fine.
But the whole point of CUSE is allowing CUSE clients to create arbitrary
character devices, so in addition to /dev/cuse which clients use to talk
to CUSE, CUSE hosts character devices for its clients and they come and
go dynamically and thus requires proper lifetime management.

Thanks.

-- 
tejun

  reply	other threads:[~2008-08-28 17:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-28 16:36 [PATCH RESEND] char_dev: add cdev->release() and convert cdev_alloc() to use it Tejun Heo
2008-08-28 16:47 ` Greg KH
2008-08-28 16:56   ` Tejun Heo
2008-08-28 17:38     ` Greg KH
2008-08-28 17:44       ` Tejun Heo [this message]
2008-08-28 17:48         ` Greg KH
2008-08-28 17:55           ` Tejun Heo
2008-08-28 18:17             ` Greg KH
2008-11-13  8:58               ` Tejun Heo
     [not found]                 ` <492136F5.8010903@kernel.org>
     [not found]                   ` <20081117171717.GB31306@kroah.com>
     [not found]                     ` <49221CE8.1050402@kernel.org>
2008-11-18  1:40                       ` Tejun Heo
2008-11-18 13:44                         ` Boaz Harrosh
2008-11-18 15:58                           ` Tejun Heo
2008-11-19 17:59                             ` Miklos Szeredi
2008-11-20  5:54                             ` Greg KH
2008-11-20  6:28                               ` Tejun Heo
2008-11-20 11:45                                 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48B6E417.5030605@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox