From: Greg KH <gregkh@suse.de>
To: Tejun Heo <htejun@gmail.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
hugh@veritas.com, cornelia.huck@de.ibm.com,
dmitry.torokhov@gmail.com, oneukum@suse.de, maneesh@in.ibm.com,
rpurdie@rpsys.net, 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 02:33:24 -0700 [thread overview]
Message-ID: <20070402093324.GA21857@suse.de> (raw)
In-Reply-To: <20070401195943.GA29627@htj.dyndns.org>
On Mon, Apr 02, 2007 at 04:59:43AM +0900, Tejun Heo wrote:
>
> Dependencies between sysfs/kobject objects are clearer now and I think
> I got the locking and referencing correct. This patch immediately
> fixes 'sysfs attr grabbing the wrong kobject and module' problem -
> sysfs and module lifetimes are unrelated now. We can drop
> half-working attr->owner.
>
> * A sysfs node no longer hold reference to its kobject. It just
> attaches itself to the kobject on creation and detaches on deletion.
>
> * For a dir node, sysfs_dirent no longer directly points to kobject.
> It points to sysfs_dir which contains pointer to kobject and a rwsem
> to protect it.
>
> * An open file doesn't hold a reference to kobject. It holds a
> reference to sysfs_dirent. kobject pointer is verified and
> show/store are performed with rwsem read-locked. Deletion
> disconnects the sysfs from its kobject while the rwsem is
> write-locked. This mechanism replaces buffer orphaning and kobject
> validation during open.
Ah, very nice.
> * attr ops is determined on sysfs node creation not on open. This is
> a step toward making kobject opaque in sysfs.
>
> * bin files are handled similarly but mmap makes the open file hold
> reference to the kobject till it's closed. Any better ideas?
This is probably needed, and might be acceptable, and I think we can
live with it as there is only a very small number of sysfs files that
fall into this category.
> * symlink is reimplemented in terms of sysfs_dirents instead of
> kobjects. sysfs_dirent->s_parent is added and each sysfs_dirent
> holds reference to its parent. Currently walking up the tree
> requires read locking and unlocking sysfs_dir at each level. This
> can be removed if name is added to sysfs_dirent.
>
> * As kobject can be disconnected anytime and sysfs code still needs to
> look follow dentry link in kobject, kobject->dentry is protected by
> dcache_lock. Once kobject becomes opaque to sysfs, this hack can go
> away. All in all, making kobject completely opaque in sysfs isn't
> too far away after this patch although it would require mass code
> update.
What would need to be updated after this?
> What do you think about this approach? If it's acceptable, I'll test
> further and split the patch into logical steps to get it reviewed
> better.
At first glance, I think it looks fine, but Maneesh is the one who
understands this code better than anyone, so I would like to get his
opinion on it.
I think you should start splitting it all up into steps, which will help
us review it a whole lot easier, as overall, I think this is a very
worthy goal.
thanks so much for doing this work,
greg k-h
next prev parent reply other threads:[~2007-04-02 9:33 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] ` <d120d5000703300615y7b367d82hb42f1c58ca8a6328@mail.gmail.com>
2007-03-30 17:58 ` James Bottomley
2007-03-30 18:18 ` Dmitry Torokhov
[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 [this message]
2007-04-02 12:10 ` Maneesh Soni
2007-04-02 19:33 ` Luben Tuikov
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
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=20070402093324.GA21857@suse.de \
--to=gregkh@suse.de \
--cc=James.Bottomley@SteelEye.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dmitry.torokhov@gmail.com \
--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).