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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Qing,

On 4/5/07, qingxiaoming <qing_xiaoming@xxxxxxxxx> wrote:
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)?


IMHO, the linked list is not headed by shrinker->list, rather by
shrinker_list. So the statement

list_add_tail(&shrinker->list, &shrinker_list);

is actually adding shrinker to the list shrinker_list. The shrinker->
list is merely a pointer to help in atttaching the node to the list.

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" 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.linux-learn.org/faqs

[Index of Archives]     [Audio]     [Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Fedora Users]

  Powered by Linux