linux-4.9.37/include/linux/percpu_ida.h
用于管理percpu ID分配器的数据结构,主要用于在多处理器系统中为每个CPU分配唯一的标识符。
percpu ID分配器(percpu_ida)用于为每个CPU分配一个唯一的标识符。这通常用于创建内核线程时为线程命名。例如,在创建工作线程时,每个线程需要一个唯一的ID来区分不同的工作线程。
struct percpu_ida {
/*
* number of tags available to be allocated, as passed to
* percpu_ida_init()
*/
unsigned nr_tags;
unsigned percpu_max_size;
unsigned percpu_batch_size;
struct percpu_ida_cpu __percpu *tag_cpu;
/*
* Bitmap of cpus that (may) have tags on their percpu freelists:
* steal_tags() uses this to decide when to steal tags, and which cpus
* to try stealing from.
*
* It's ok for a freelist to be empty when its bit is set - steal_tags()
* will just keep looking - but the bitmap _must_ be set whenever a
* percpu freelist does have tags.
*/
cpumask_t cpus_have_tags;
struct {
spinlock_t lock;
/*
* When we go to steal tags from another cpu (see steal_tags()),
* we want to pick a cpu at random. Cycling through them every
* time we steal is a bit easier and more or less equivalent:
*/
unsigned cpu_last_stolen;
/* For sleeping on allocation failure */
wait_queue_head_t wait;
/*
* Global freelist - it's a stack where nr_free points to the
* top
*/
unsigned nr_free;
unsigned *freelist;
} ____cacheline_aligned_in_smp;
};

被折叠的 条评论
为什么被折叠?



