public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Hannes Frederic Sowa <hannes@stressinduktion•org>
To: Chris Mi <chrism@mellanox•com>
Cc: netdev@vger•kernel.org, jhs@mojatatu•com,
	xiyou.wangcong@gmail•com, jiri@resnulli•us, davem@davemloft•net,
	mawilcox@microsoft•com
Subject: Re: [patch net-next 1/3] idr: Add new APIs to support unsigned long
Date: Tue, 29 Aug 2017 09:14:04 +0200	[thread overview]
Message-ID: <87y3q27sn7.fsf@stressinduktion.org> (raw)
In-Reply-To: <1503902477-39829-2-git-send-email-chrism@mellanox.com> (Chris Mi's message of "Mon, 28 Aug 2017 02:41:15 -0400")

Hello,

Chris Mi <chrism@mellanox•com> writes:

> The following new APIs are added:
>
> int idr_alloc_ext(struct idr *idr, void *ptr, unsigned long *index,
>                   unsigned long start, unsigned long end, gfp_t gfp);
> static inline void *idr_remove_ext(struct idr *idr, unsigned long id);
> static inline void *idr_find_ext(const struct idr *idr, unsigned long id);
> void *idr_replace_ext(struct idr *idr, void *ptr, unsigned long id);
> void *idr_get_next_ext(struct idr *idr, unsigned long *nextid);
>
> Signed-off-by: Chris Mi <chrism@mellanox•com>
> Signed-off-by: Jiri Pirko <jiri@mellanox•com>
> ---
>  include/linux/idr.h        | 16 ++++++++++
>  include/linux/radix-tree.h |  3 ++
>  lib/idr.c                  | 56 +++++++++++++++++++++++++++++++++++
>  lib/radix-tree.c           | 73 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 148 insertions(+)
>

[...]

> +int idr_alloc_ext(struct idr *idr, void *ptr, unsigned long *index,
> +		  unsigned long start, unsigned long end, gfp_t gfp)
> +{
> +	void __rcu **slot;
> +	struct radix_tree_iter iter;
> +
> +	if (WARN_ON_ONCE(radix_tree_is_internal_node(ptr)))
> +		return -EINVAL;
> +
> +	radix_tree_iter_init(&iter, start);
> +	slot = idr_get_free_ext(&idr->idr_rt, &iter, gfp, end);
> +	if (IS_ERR(slot))
> +		return PTR_ERR(slot);
> +
> +	radix_tree_iter_replace(&idr->idr_rt, &iter, slot, ptr);
> +	radix_tree_iter_tag_clear(&idr->idr_rt, &iter, IDR_FREE);
> +
> +	if (index)
> +		*index = iter.index;
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(idr_alloc_ext);

Can you express idr_alloc in terms of idr_alloc_ext? Same for most of
the other functions (it seems that signed int was used as return value
to indicate error cases, thus it should be easy to map those).

[...]

Thanks,
Hannes

  reply	other threads:[~2017-08-29  7:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  6:41 [patch net-next 0/3] net/sched: Improve getting objects by indexes Chris Mi
2017-08-28  6:41 ` [patch net-next 1/3] idr: Add new APIs to support unsigned long Chris Mi
2017-08-29  7:14   ` Hannes Frederic Sowa [this message]
2017-08-29  7:34     ` Chris Mi
2017-08-29  7:57       ` Jiri Pirko
2017-08-29  8:00         ` Chris Mi
2017-08-29  7:56     ` Jiri Pirko
2017-08-28  6:41 ` [patch net-next 2/3] net/sched: Change cls_flower to use IDR Chris Mi
2017-08-28 11:37   ` Simon Horman
2017-08-29  3:25     ` Chris Mi
2017-08-30 10:30       ` Simon Horman
2017-08-28 21:55   ` Jamal Hadi Salim
2017-08-29  1:34     ` Chris Mi
2017-08-28  6:41 ` [patch net-next 3/3] net/sched: Change act_api and act_xxx modules " Chris Mi
2017-08-28 21:56   ` Jamal Hadi Salim

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=87y3q27sn7.fsf@stressinduktion.org \
    --to=hannes@stressinduktion$(echo .)org \
    --cc=chrism@mellanox$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=mawilcox@microsoft$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=xiyou.wangcong@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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