linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] char_dev: replace cdev_map with an xarray
Date: Mon, 11 Jan 2021 18:51:11 +0000	[thread overview]
Message-ID: <20210111185111.GI35215@casper.infradead.org> (raw)
In-Reply-To: <X/yZ6wtNYJEniwC0@kroah.com>

On Mon, Jan 11, 2021 at 07:33:15PM +0100, Greg KH wrote:
> On Mon, Jan 11, 2021 at 06:20:29PM +0000, Matthew Wilcox wrote:
> > > efficient in what way?  Space or faster lookup?
> > 
> > Both, but primarily space.
> > 
> > The radix tree underlying the xarray allows N consecutive entries with
> > the same value to be represented as a single entry; if there are at
> > least 64 entries then we get to skip an entire level of the tree (saving
> > 1/7 of a page).  Of course, we'd need to go from the 'head' pointer to
> > the correct pointer, something like p += rdev - p->rdev.
> 
> How much "space" are you talking about here?

576 bytes -- 1/7 of a page.

> A "normal" machine has about 100-200 char devices.  Servers, maybe more,
> but probably not.
> 
> The kobject being used previously wasn't really "small" at all, so odds
> are any conversion to not use it like this will be better overall.

Yes.

> > > THis shouldn't be on a "fast" lookup path, so I doubt that's worth
> > > optimizing for.  Space, maybe, for systems with thousands of scsi
> > > devices, but usually they just stick to the block device, not a char
> > > device from what I remember.
> > 
> > /dev/sgX is a chardev?
> 
> I sure hope no one is using /dev/sgX for tens of thousands of block
> device accesses, if so, they have bigger problems than this :)

There is one sgX char dev for every /dev/sdN, so anyone with a thousand
SCSI devices also has a thousand char devices.  On the other hand,
they're added one at a time, so there is no chance to optimise here:

        cdev = cdev_alloc();
...
        error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), 1);


  reply	other threads:[~2021-01-11 18:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 17:05 [PATCH] char_dev: replace cdev_map with an xarray Christoph Hellwig
2021-01-11 17:35 ` Matthew Wilcox
2021-01-11 18:11   ` Greg KH
2021-01-11 18:20     ` Matthew Wilcox
2021-01-11 18:33       ` Greg KH
2021-01-11 18:51         ` Matthew Wilcox [this message]
2021-01-11 18:10 ` Greg KH
2021-01-11 20:58 ` Matthew Wilcox
2021-01-12  9:35   ` Greg KH
2021-01-12 10:00     ` David Laight
2021-01-12 10:25       ` '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=20210111185111.GI35215@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).