public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Andries Brouwer <aebr@win.tue.nl>
Cc: linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: Re: [CFT] more kdev_t-ectomy
Date: Sun, 20 Apr 2003 20:24:34 +0100	[thread overview]
Message-ID: <20030420192434.GI10374@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20030420160034.GA20123@win.tue.nl>

[cc fixed - my apologies]

On Sun, Apr 20, 2003 at 06:00:34PM +0200, Andries Brouwer wrote:
 
> So, the interface with filesystems and with userspace has dev_t.
> For kernel-internal numbers kdev_t is better than dev_t.
> 
> Of course it may be possible to avoid kernel-internal numbers altogether.
> Sometimes that is an improvement, sometimes not. Pointers are more
> complicated than numbers - they point at something that must be allocated
> and freed and reference counted. A number is like a pointer without the
> reference counting.

Sigh...   And what, pray tell, do we do with these numbers?  That's
right, at some point(s) we use them to obtain <drumroll> pointers
to driver-supplied objects.  And that's where the lack of refcounting,
locking, etc. bites you.

Let's sort that mess out for good.  Papering over this stuff won't do
us any good and will only bring more kludgy interfaces.  $DEITY witness,
we already have enough of those.

It's not about pointers vs. numbers - we certainly have enough cases when
we really deal with the latter.  However, I'd rather have clear separation
between "32bit value presented to/by userland to identify device node"
and "value in range 0--7, representing the number of channel on a multiport
card FooLink-8X".  The latter makes perfect sense for a driver.  As does
"structure that represents given instance of FooLink-8X".  The former belongs
to interaction with userland and using it outside of that context is a kludge.
Dangerous kludge in case if it masks the aforementioned complications.
It also breeds all sorts of ugliness in the code - see the crap around
reassigning ->f_op and problems with clean implementation of revoke(2)
analogs for instance.  Or a buttload of fun induced by (completely
artificial) separation into major and minor - see the mess around UNIX98
ptys implementation, etc.

By now all uses of mk_kdev()/major()/minor()/MAJOR()/MINOR() in the drivers
are either trivially removable or represent very real problems.  And it's
not that there was a lot of them - in my current tree there's ~85 instances
of kdev_t in the source.  And only one of them (->i_rdev) is widely used -
~500 instances, most of them go away as soon as CIDR patch gets merged.
The rest is part noise, part real bugs that need to be fixed anyway (~40--80
of those).

  reply	other threads:[~2003-04-20 19:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-20 13:31 [CFT] more kdev_t-ectomy viro
2003-04-20 15:26 ` Muli Ben-Yehuda
2003-04-20 16:00 ` Andries Brouwer
2003-04-20 19:24   ` viro [this message]
2003-04-20 21:10   ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2003-04-20 21:17 Andries.Brouwer
2003-04-20 21:26 ` viro
2003-04-20 21:58 Andries.Brouwer
2003-04-20 22:35 ` viro
2003-04-20 23:56 Andries.Brouwer
2003-04-21  0:15 ` H. Peter Anvin
2003-04-21  0:35 ` viro
2003-04-21  1:32 Andries.Brouwer
2003-04-21  3:54 ` H. Peter Anvin

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=20030420192434.GI10374@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=aebr@win.tue.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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