Re: [PATCH 25/62] infiniband/cxgb4: convert to idr_alloc()

From: Tejun Heo
Date: Sun Feb 03 2013 - 09:28:55 EST


Hello,

On Sun, Feb 3, 2013 at 6:18 AM, Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Is there a git tree somewhere that I can use to test these patches out?

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git convert-to-idr_alloc

>> - return ret;
>> + if (lock) {
>> + idr_preload(GFP_KERNEL);
>> + spin_lock_irq(&rhp->lock);
>> + }
>
> The idr_preload() needs to be above the 'if (lock)', no?

No reason to preload for ATOMIC allocation. idr_alloc() can be called
by itself.

>> +
>> + ret = idr_alloc(idr, handle, id, id + 1, GFP_ATOMIC);
>> +
>> + if (lock) {
>> + spin_unlock_irq(&rhp->lock);
>> + idr_preload_end();
>> + }
>
> And idr_preload_end() should be after the 'if (lock)' block methinks...

Ditto.

>> +
>> + BUG_ON(ret == -ENOSPC);
>> + return ret < 0 ? ret : 0;
>
> What would cause ret > 0?

It's the allocated id. In this case, ret would either be @id or -errno.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/