public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@home-tj.org>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: Greg KH <greg@kroah.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.10-rc1 2/5] driver-model: bus_recan_devices() locking fix
Date: Wed, 10 Nov 2004 16:13:15 +0900	[thread overview]
Message-ID: <20041110071315.GA17026@home-tj.org> (raw)
In-Reply-To: <200411082043.21818.dtor_core@ameritech.net>

 Hello, Dmitry.

On Mon, Nov 08, 2004 at 08:43:21PM -0500, Dmitry Torokhov wrote:
> On Monday 08 November 2004 08:27 pm, Tejun Heo wrote:
> >  Are you suggesting splitting every bus implementation into two
> > separate modules?  Otherwise, we will have to move kobj field of every
> > bus-specific device structure to the head (to use the common release
> > function).  Either way, it can be done, but it just seems another
> > twist added to the already twisted refcounting.  Moreoever, not only
> > the devices are problematic, refcounting in class devices and block
> > device hierarchy seems broken too.
> >
> 
> It is already defacto implementation standard - every subsystem has a core
> modules (pci, usbcore, serio) plus modules (drivers) actually talking to
> hardware and registering devices (ports, whatever) with the corresponding
> core. It is just a matter of splitting cleanup functions into core and
> device-specific parts.

 AFAIK, PCI isn't compiled as modules and USB has ohci/uhci/ehci stuff
and serio has ports stuff.  But still, I cannot agree with you.

 1. It's too twisted.
	a. to prevent premature unload, we depend on
	   - attr -> kobj -> module_ref to bus core module.  By doing
	   this, we're making a chain of two different types of
	   reference counts.  IMHO, it's just a bit too subtle.
	b. to enable bus module unload, we depend on
	   - device creation/detach operations are done in a separate
	     module than device release.

 2. too restrictive.
	a. any bus implementation must be implemented as two separate
	   modules just to enable peaceful module unloading
	b. all other places which make use of kobject and any type of
	   generic attr must use only the release routine proper to
	   the core module.  No callbacks, no data dereferences....
	   (for example, scsi_host class uses scsi_host_template
	    structure which contain class device specific callbacks
	    when releaseing scsi_host class device.  This is
	    currently broken and won't be fixed by your method.)

 3. not intutive.  Maybe this is the most important.
	a. it's natural to expect the release code has access to
	   codes & data of whatever it's releasing.
	b. children bypassing dependency hierarchy and depending
	   directly on indirect ancestor is just difficult to
           track, memorize and do correctly.
    IMO, above a and b are the primary reasons for why kobject/attr
    refcountings are currently done incorrectly in many places.

> >  But all attrs will be deflated and it just seems the right thing to
> > do(tm).
> > 
> 
> I think there are much more kobjects than attrs.

 Yes, there are.  But many objects which contain kobjs keep separate
owner field anyway, which can be removed after kobj can handle module
refcounting, and even without that, I think 4 or 8 bytes addition to
struct kobject is worth it if we can get the refcounting straight.

 Thanks.

-- 
tejun


  reply	other threads:[~2004-11-10  7:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-04  7:01 [PATCH 2.6.10-rc1 0/5] driver-model: misc bug fixes Tejun Heo
2004-11-04  7:02 ` [PATCH 2.6.10-rc1 1/5] driver-model: comment fix in bus.c Tejun Heo
2004-11-04 18:35   ` Greg KH
2004-11-04  7:02 ` [PATCH 2.6.10-rc1 2/5] driver-model: bus_recan_devices() locking fix Tejun Heo
2004-11-04 18:58   ` Greg KH
2004-11-04 19:12     ` Dmitry Torokhov
2004-11-05  6:14       ` Tejun Heo
2004-11-05 16:33         ` Dmitry Torokhov
2004-11-09  1:27           ` Tejun Heo
2004-11-09  1:43             ` Dmitry Torokhov
2004-11-10  7:13               ` Tejun Heo [this message]
2004-11-10  0:40           ` Greg KH
2004-11-10  4:17             ` Dmitry Torokhov
2004-11-16  5:52               ` Greg KH
2004-11-04  7:03 ` [PATCH 2.6.10-rc1 3/5] driver-model: sysfs_release() dangling pointer reference fix Tejun Heo
2004-11-04 18:59   ` Greg KH
2004-11-04  7:04 ` [PATCH 2.6.10-rc1 4/5] driver-model: kobject_add() error path reference counting fix Tejun Heo
2004-11-04 19:00   ` Greg KH
2004-11-04  7:05 ` [PATCH 2.6.10-rc1 5/5] driver-model: device_add() " Tejun Heo
2004-11-04 20:07   ` Greg KH

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=20041110071315.GA17026@home-tj.org \
    --to=tj@home-tj.org \
    --cc=dtor_core@ameritech.net \
    --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