public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli•us>
To: Hannes Frederic Sowa <hannes@stressinduktion•org>
Cc: Chris Mi <chrism@mellanox•com>,
	netdev@vger•kernel.org, jhs@mojatatu•com,
	xiyou.wangcong@gmail•com, 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:56:02 +0200	[thread overview]
Message-ID: <20170829075601.GD1977@nanopsycho.orion> (raw)
In-Reply-To: <87y3q27sn7.fsf@stressinduktion.org>

Tue, Aug 29, 2017 at 09:14:04AM CEST, hannes@stressinduktion•org wrote:
>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).

Agreed. Same for free function.


>
>[...]
>
>Thanks,
>Hannes

  parent reply	other threads:[~2017-08-29  7:56 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
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 [this message]
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=20170829075601.GD1977@nanopsycho.orion \
    --to=jiri@resnulli$(echo .)us \
    --cc=chrism@mellanox$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=hannes@stressinduktion$(echo .)org \
    --cc=jhs@mojatatu$(echo .)com \
    --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