From: Andrew Morton <akpm@linux-foundation.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: davem@davemloft.net, paulus@samba.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
xemul@openvz.org
Subject: Re: [PATCH] net: ppp_generic - use idr technique instead of cardmaps
Date: Wed, 17 Dec 2008 17:16:25 -0800 [thread overview]
Message-ID: <20081217171625.776d4e46.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081216192000.GF26390@localhost>
On Tue, 16 Dec 2008 22:20:00 +0300
Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> Here is an attempt to convert cardmaps into ird.
> I would really appreciate any feedback.
>
> I've tested ird under qemu (by some hacks not real ppp connection)
> so real loadings could reveal problems with the patch - review
> carefully please. (i'm not subcribed for netdev list CC me).
>
> Any comments are _quite_ welcome! Paul?
>
> ---
> From: Cyrill Gorcunov <gorcunov@openvz.org>
> Date: Tue, 16 Dec 2008 19:39:08 +0300
> Subject: [PATCH] net: ppp_generic - use idr technique instead of cardmaps
>
> Use idr technique instead of own implemented cardmaps.
> It saves us a number of lines and gives an ability
> to use library functions.
>
> ...
>
> +static struct idr ppp_units_idr;
Could use DEFINE_IDR()
> @@ -859,6 +841,8 @@ static int __init ppp_init(void)
> device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
> }
>
> + idr_init(&ppp_units_idr);
then remove this.
> out:
> if (err)
> printk(KERN_ERR "failed to register PPP device (%d)\n", err);
> @@ -2431,10 +2415,22 @@ ppp_create_interface(int unit, int *retp)
>
> ret = -EEXIST;
> mutex_lock(&all_ppp_mutex);
> - if (unit < 0)
> - unit = cardmap_find_first_free(all_ppp_units);
> - else if (cardmap_get(all_ppp_units, unit) != NULL)
> - goto out2; /* unit already exists */
> +
> + if (unit < 0) {
> + unit = unit_get(&ppp_units_idr, ppp);
> + if (unit < 0) {
> + *retp = unit;
> + goto out2;
> + }
> + } else {
> + if (unit_find(&ppp_units_idr, unit))
> + goto out2; /* unit already exists */
> + else {
> + /* darn, someone is cheatting us? */
"cheating" ;)
> + *retp = -EINVAL;
> + goto out2;
> + }
> + }
It certainly cleaned things up.
What is the locking for the IDR tree? all_ppp_mutex?
next prev parent reply other threads:[~2008-12-18 1:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-16 19:20 [PATCH] net: ppp_generic - use idr technique instead of cardmaps Cyrill Gorcunov
2008-12-17 8:32 ` David Miller
2008-12-18 1:16 ` Andrew Morton [this message]
2008-12-18 1:41 ` David Miller
2008-12-18 4:20 ` Cyrill Gorcunov
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=20081217171625.776d4e46.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=gorcunov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.org \
--cc=xemul@openvz.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).