Yanyg - SAN Software Engineer

LINUX IDR/IDA算法分析

目录

1 介绍

idr.h: Small id to pointer translation service avoiding fixed sized tables.

1.1 loop示例

loop是最简单的使用。以loop.c使用为例阐述:

1.1.1 静态初始化

/*- idr.h -*/
/* Set the IDR flag and the IDR_FREE tag */
#define IDR_RT_MARKER           ((__force gfp_t)(3 << __GFP_BITS_SHIFT))

#define IDR_INIT                                                        \
{                                                                       \
        .idr_rt = RADIX_TREE_INIT(IDR_RT_MARKER)                        \
}
#define DEFINE_IDR(name)        struct idr name = IDR_INIT

/*- loop.c -*/
static DEFINE_IDR(loop_index_idr);

2 References

LWN A simplified IDR API
https://lwn.net/Articles/536293/