From: Matthew Wilcox <willy@infradead.org>
To: Christoph Hellwig <hch@lst.de>
Cc: gregkh@linuxfoundation.org, 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 20:58:18 +0000 [thread overview]
Message-ID: <20210111205818.GJ35215@casper.infradead.org> (raw)
In-Reply-To: <20210111170513.1526780-1-hch@lst.de>
On Mon, Jan 11, 2021 at 06:05:13PM +0100, Christoph Hellwig wrote:
> @@ -486,14 +491,22 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count)
> if (WARN_ON(dev == WHITEOUT_DEV))
> return -EBUSY;
>
> - error = kobj_map(cdev_map, dev, count, NULL,
> - exact_match, exact_lock, p);
> - if (error)
> - return error;
> + mutex_lock(&chrdevs_lock);
> + for (i = 0; i < count; i++) {
> + error = xa_insert(&cdev_map, dev + i, p, GFP_KERNEL);
> + if (error)
> + goto out_unwind;
> + }
> + mutex_unlock(&chrdevs_lock);
Looking at some of the users ...
#define BSG_MAX_DEVS 32768
...
ret = cdev_add(&bsg_cdev, MKDEV(bsg_major, 0), BSG_MAX_DEVS);
So this is going to allocate 32768 entries; at 8 bytes each, that's 256kB.
With XArray overhead, it works out to 73 pages or 292kB. While I don't
have bsg loaded on my laptop, I imagine a lot of machines do.
drivers/net/tap.c:#define TAP_NUM_DEVS (1U << MINORBITS)
include/linux/kdev_t.h:#define MINORBITS 20
drivers/net/tap.c: err = cdev_add(tap_cdev, *tap_major, TAP_NUM_DEVS);
That's going to be even worse -- 8MB plus the overhead to be closer to 9MB.
I think we do need to implement the 'store a range' option ;-(
next prev parent reply other threads:[~2021-01-11 20:59 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
2021-01-11 18:10 ` Greg KH
2021-01-11 20:58 ` Matthew Wilcox [this message]
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=20210111205818.GJ35215@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).