kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: confused by char dev registration in a gpio driver
Date: Fri, 13 May 2011 12:05:02 -0700	[thread overview]
Message-ID: <20110513190502.GE4303@kroah.com> (raw)
In-Reply-To: <BANLkTimfiqwNfurTVwwmTFYAgXmn=GQFqw@mail.gmail.com>

On Fri, May 13, 2011 at 11:05:08AM -0600, Jim Cromie wrote:
> On Tue, May 10, 2011 at 12:40 PM, Greg KH <greg@kroah.com> wrote:
> > On Tue, May 10, 2011 at 11:26:59AM -0600, Jim Cromie wrote:
> >> lets start with a list of grumbles about current api ?
> >>
> ...
> >> Are the insanities you alluded to of a different sort,
> >> ie internal suboptimalities ?
> >
> > No, those you have listed are all things I was talking about.
> >
> > And yes, there are also some internal issues as well (see the kobject
> > mapping stuff).
> 
> >> static struct char_device_struct {
> >> ...} *chrdevs[CHRDEV_MAJOR_HASH_SIZE];
> >> ie 255 elements.
> >>
> >> This is ?== to legacy MAJOR number space,
> >> and is scanned 255..0 to find unused MAJOR number.
> >> It will need new const if MAJOR range increases,
> >> but doesnt waste much memory currently
> >>
> >> My 32bit laptop uses 48 devices, so ~200 major slots are
> >> empty/wasted (800 bytes) and ISTM like over-engineering
> >> to fix this preemptively if >255 is unneeded.
> >> OTOH, a hash or rb-tree could use only whats needed.
> >> is there a 'library' hash implementation in the kernel ?
> >
> > The kobject map stuff should handle most of this, but really, 800 bytes
> > isn't that much overhead for the speed you get, right? ?Changing the
> > code to use something else would take more than 800 bytes from what I
> > can see.
> >
> 
> cool.  Im pleased that I agree with you :-) regarding the 800 byte cost.
> 
> but is speed even an issue ?
> registering char drivers isnt exactly a hot path.
> of course, simplicity is good too..

Speed is an issue on open() for some things, so yes, it can be
important (meaning, don't make it a linked list that you need to walk
all of them to find the last character device in the system if opening
just that one.)

> > Let's get the api fixed up first, that's the most important thing as
> > it's what people use all the time.
> >
> 
> Ive gone and done this.
> Im currently messing with coccinelle / spatch to try to automate
> the API - user conversion.
> will send when the spatch transforms are a bit more sane.

Ok, sounds good, looking forward to it.

> > I'm going to have some long-distance flights soon, so I'll try to work
> > on this then, thanks for the great summary above, I appreciate it.
> 
> Hope Ive beaten you to it,
> or hold off on actually doing the work

Well, my trip isn't for another week or so (depending on some changing
plans), so you might beat me to it, which is fine with me :)

thanks,

greg k-h

  reply	other threads:[~2011-05-13 19:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-03 21:21 confused by char dev registration in a gpio driver Robert P. J. Day
2011-05-03 22:06 ` Greg KH
2011-05-10 17:26   ` Jim Cromie
2011-05-10 18:40     ` Greg KH
2011-05-13 17:05       ` Jim Cromie
2011-05-13 19:05         ` Greg KH [this message]
2011-05-09 19:54 ` Jim Cromie

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=20110513190502.GE4303@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).