From: Luben Tuikov <ltuikov@yahoo.com>
To: Tejun Heo <htejun@gmail.com>, Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: gregkh@suse.de, hugh@veritas.com, dmitry.torokhov@gmail.com,
oneukum@suse.de, maneesh@in.ibm.com, rpurdie@rpsys.net,
James.Bottomley@SteelEye.com, Jeff Garzik <jgarzik@pobox.com>,
lkml <linux-kernel@vger.kernel.org>,
"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [RFD driver-core] Lifetime problems of the current driver model
Date: Mon, 2 Apr 2007 12:24:28 -0700 (PDT) [thread overview]
Message-ID: <875017.73166.qm@web31811.mail.mud.yahoo.com> (raw)
In-Reply-To: <460DD1B0.4080605@gmail.com>
--- Tejun Heo <htejun@gmail.com> wrote:
> Cornelia Huck wrote:
> > On Sat, 31 Mar 2007 00:08:19 +0900,
> > Tejun Heo <htejun@gmail.com> wrote:
> >
> >> (3) make sure all existing kobjects are released by module exit function.
> >>
> >> For example, let's say there is a hypothetical disk device /dev/dk0
> >> driven by a hypothetical driver mydrv. /dev/dk0 is represented like the
> >> following in the sysfs tree.
> >>
> >> /sys/devices/pci0000:00/0000:00:1f.0/dk0/{myknob0,myknob1}
> >>
> >> Owner of both attrs myknob0 and myknob1 is mydrv and opening either
> >> increases the reference counts of dk0 and mydrv and closing does the
> >> opposite.
> >>
> >> * When there is no opener of either knob and the /dev/dk0 isn't used by
> >> anyone. Reference count of dk0 is 1, mydrv 0.
> >
> > Hm, but as long as dk0 is registered, it can be looked up and someone
> > could get a reference on it.
>
> Yeah, exactly. That's why any getting any kobject reference backed by a
> module must be accompanied by try_module_get().
Tejun,
This has always been the case.
By design, the kobject infrastructure is one such that allows for
different behavior implementations. You could use it to accomplish
what you want and describe in your RFD, or you could use it to implement
what we have today or you could use it to implement completely different
(refcount) infrastructure.
Luben
>
> int mydrv_get_dk(struct dk *dk)
> {
> rc = try_module_get(mydrv);
> if (rc)
> return rc;
> kobject_get(&dk->kobj);
> return 0;
> }
>
> >> * User issues rmmod mydrv. As mydrv's reference count is zero, unload
> >> proceeds and mydrv's exit function is called.
> >>
> >> * mydrv's exit function looks like the following.
> >>
> >> mydrv_exit()
> >> {
> >> sysfs_remove_file(dk0, myknob0);
> >> sysfs_remove_file(dk1, myknob1);
> >> device_del(dk0);
> >> deinit controller;
> >> release all resources;
> >> }
> >>
> >> The device_del(dk0) drops dk0's reference count to zero and its
> >> ->release is invoked immediately.
> >
> > And here is the problem if someone else still has a reference. The
> > module will be unloaded, but ->release will not be called until the
> > "someone else" gives up the reference...
>
> Exactly, in that case, module reference count must not be zero. You and
> I are saying the same thing. Why are we running in circle?
>
> --
> tejun
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2007-04-02 19:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <460CDBA6.5030608@gmail.com>
2007-03-30 12:29 ` [RFD driver-core] Lifetime problems of the current driver model James Bottomley
2007-03-30 13:15 ` Dmitry Torokhov
2007-03-30 13:38 ` Tejun Heo
[not found] ` <460D12B8.6050101@gmail.com>
2007-03-30 17:41 ` Greg KH
2007-03-30 18:19 ` James Bottomley
2007-04-01 19:59 ` Tejun Heo
2007-04-02 9:20 ` Cornelia Huck
2007-04-02 15:34 ` Cornelia Huck
2007-04-03 3:08 ` Tejun Heo
2007-04-02 9:33 ` Greg KH
2007-04-02 12:10 ` Maneesh Soni
2007-04-02 19:33 ` Luben Tuikov
[not found] ` <d120d5000703300615y7b367d82hb42f1c58ca8a6328@mail.gmail.com>
2007-03-30 17:58 ` James Bottomley
2007-03-30 18:18 ` Dmitry Torokhov
2007-03-30 13:19 ` Cornelia Huck
2007-03-30 13:19 ` Tejun Heo
2007-03-30 13:40 ` Cornelia Huck
2007-03-30 13:58 ` Tejun Heo
2007-03-30 14:52 ` Cornelia Huck
2007-03-30 15:08 ` Tejun Heo
2007-03-30 19:31 ` Cornelia Huck
2007-03-31 3:12 ` Tejun Heo
2007-03-31 3:15 ` Tejun Heo
2007-03-31 16:08 ` Cornelia Huck
2007-03-31 16:14 ` Tejun Heo
2007-04-02 19:24 ` Luben Tuikov [this message]
2007-03-30 17:38 ` Greg KH
2007-03-30 9:43 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=875017.73166.qm@web31811.mail.mud.yahoo.com \
--to=ltuikov@yahoo.com \
--cc=James.Bottomley@SteelEye.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@suse.de \
--cc=htejun@gmail.com \
--cc=hugh@veritas.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=maneesh@in.ibm.com \
--cc=oneukum@suse.de \
--cc=rpurdie@rpsys.net \
/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;
as well as URLs for NNTP newsgroup(s).