-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there again, I've been trying to understand what's going on here but I'm not sure: <mm/slab.c> 2047 static inline void * __cache_alloc (kmem_cache_t *cachep, int flags) 2048 { 2049 unsigned long save_flags; 2050 void* objp; 2051 struct array_cache *ac; 2052 2053 cache_alloc_debugcheck_before(cachep, flags); 2054 2055 local_irq_save(save_flags); 2056 ac = ac_data(cachep); 2057 if (likely(ac->avail)) { 2058 STATS_INC_ALLOCHIT(cachep); 2059 ac->touched = 1; 2060 objp = ac_entry(ac)[--ac->avail]; 2061 } else { 2062 STATS_INC_ALLOCMISS(cachep); 2063 objp = cache_alloc_refill(cachep, flags); 2064 } 2065 local_irq_restore(save_flags); 2066 objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0)); 2067 return objp; 2068 } What puzzles me is line 2060: ac_entry(ac) returns (void **)(ac+1), which, if I see it correctly, returns a pointer to the next array_cache struct in the per CPU *array in the kmem_cache_t struct. But what exactly do the array subscript brackets after it do and an object pointer of what kind gets written in objp? --ac->avail decrements the count of available slab objects in the cache but (ac+1)[--ac->avail] returns the ac->touched of the previous array_cache struct which has just been set to 1 in the previous line. hmm, mighty strange ?! Thanks in advance, Boris. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBD2lkiBySr3Fn37QRAoCbAJ90mndQqkoACusdpYLgng3zdqvRYwCfV6QL bPv2+7b8gp8uH7xPzejqftY= =5Eik -----END PGP SIGNATURE----- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/