LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   meaning of 'struct proto' .obj_size and it's use (https://www.linuxquestions.org/questions/linux-kernel-70/meaning-of-struct-proto-obj_size-and-its-use-890722/)

rrlangly 07-08-2011 11:28 PM

meaning of 'struct proto' .obj_size and it's use
 
I'm not clear on one of the network protocol structures and hoping someone can explain. In 'struct proto', what should the .obj_size member field refer to?

I see in much of the kernel source where protocols refer to their custom sturcture which always includes 'struct sock', but I'm not realy clear on how obj_size gets used.

PTrenholme 07-09-2011 05:45 PM

Looking at the sock.h file, I see that the obj_size member occurs in the /* Memory Pressure */ section:
Code:

        struct kmem_cache      *slab;
        unsigned int            obj_size;
        int                    slab_flags;

from which I would assume that size of the object to which the slab points. (In this context, the dynamically allocated kmem_cache buffer.) I believe that the memory slab is being used for transient storage for FIFO stacks of the various protocol handlers, and storing the size is more efficient then recomputing it every time it's needed.

Look at mempool.h and slab.h for details.

Note: I'm not an expert (or even a user) of this code, and my comments flow only from a brief look at some of it.


All times are GMT -5. The time now is 06:57 AM.