A confusion about `slab allocator` 's initialization
alecdu at gmail.com
Wed Jul 17 15:04:35 UTC 2013
I find a couple of lines confusing while reading the slab allocator's code.
96 p = (u_char *) pool + sizeof(ngx_slab_pool_t);
97 size = pool->end - p;
110 p += n * sizeof(ngx_slab_page_t);
112 pages = (ngx_uint_t) (size / (ngx_pagesize +
114 ngx_memzero(p, pages * sizeof(ngx_slab_page_t));
125 pool->start = (u_char *)
126 ngx_align_ptr((uintptr_t) p + pages *
The `size` takes space occupied by *slots* into account, that'll make
a little bit larger. Then,
* because `p` is already advanced by sizeof *slots*, the following
will operates on more `ngx_slab_page_t`'s than expected.
* also `pool->start` will start at a higher postion before aligned by
`ngx_pagesize`. One more page maybe available if `pages` is a little
Can someone please tell me these lines's true intention? I must get it
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx-devel