Skip to contentSkip to conversation

Not Initialize the shrinker->list after kmalloc() in mm/vmscan.c(V2.6.12)?

DISCUSSION qingxiaoming 1 participant 1 message Apr 5, 2007

lore
Share & tools
lore
#0 lore raw

Dear all:
I am reading the function set_shrinker() in mm/vmscan.c of V2.6.12, and I have a question about the not initialization of list_head,

/*
* Add a shrinker callback to be called from the vm
*/
struct shrinker *set_shrinker(int seeks, shrinker_t theshrinker)

{
        struct shrinker *shrinker;

        shrinker = kmalloc(sizeof(*shrinker), GFP_KERNEL);
        if (shrinker) {
	        shrinker->shrinker = theshrinker;
	        shrinker->seeks = seeks;
	        shrinker->nr = 0;
	        down_write(&shrinker_rwsem);
	        list_add_tail(&shrinker->list, &shrinker_list);
	        up_write(&shrinker_rwsem);
	}
	return shrinker;
}

As above, the shrinker is allocated from kmalloc, coming from slab allocator,the list in shrinker is not initialized, directly list_add_tail() to shrinker_list, don't need to INIT_LIST_HEAD(shrinker->list)?

Thanks,
Best Regards!
Xiaoming.Qing