Re: free a slab object

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

 



Hi...
there
are codes like the following which I can not understand:
        unsigned int objnr = obj_to_index(cachep, slabp, objp);
        slab_bufctl(slabp)[objnr] = slabp->free;
        slabp->free = objnr;
        slabp->inuse--;

and  slab_bufctl(slabp) is (kmem_bufctl_t *)(slabp + 1).
Since slabp is a pointer to struct slab, then what does slabp + 1 point to?
the next slab? what is the meaning of slab_bufctl(slabp)[objnr] ?

Interesting ... I read UTLK and here's my understanding. slabp+1 points to the object descriptor array ( +1 here means an address right after slab descriptor). On the freed object descriptor (slab_bufctl(slabp)[objnr] ), it is assigned the number of last freed object's descriptor. In the slab-> free itself, it will be assigned the current freed object descriptor number.

So, in ASCII art, it's like below:

slabp-> free ====pointing to === > current freed object descriptor ====pointing to==> second to last freed object

That way, the last freed will be the first one used again when a similar object is allocated. The ASCII art itself, as you can guess, depict a linked list LIFO style.

I can give wrong impression here, so feel free to argue.

regards,

Mulyadi.


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux