Returns the number of pages in the slab. */
| 22 | |
| 23 | /* Returns the number of pages in the slab. */ |
| 24 | static int |
| 25 | slab_size(int lg_page, int lg_base, int lg_delta, int ndelta) { |
| 26 | size_t page = (ZU(1) << lg_page); |
| 27 | size_t reg_size = reg_size_compute(lg_base, lg_delta, ndelta); |
| 28 | |
| 29 | size_t try_slab_size = page; |
| 30 | size_t try_nregs = try_slab_size / reg_size; |
| 31 | size_t perfect_slab_size = 0; |
| 32 | bool perfect = false; |
| 33 | /* |
| 34 | * This loop continues until we find the least common multiple of the |
| 35 | * page size and size class size. Size classes are all of the form |
| 36 | * base + ndelta * delta == (ndelta + base/ndelta) * delta, which is |
| 37 | * (ndelta + ngroup) * delta. The way we choose slabbing strategies |
| 38 | * means that delta is at most the page size and ndelta < ngroup. So |
| 39 | * the loop executes for at most 2 * ngroup - 1 iterations, which is |
| 40 | * also the bound on the number of pages in a slab chosen by default. |
| 41 | * With the current default settings, this is at most 7. |
| 42 | */ |
| 43 | while (!perfect) { |
| 44 | perfect_slab_size = try_slab_size; |
| 45 | size_t perfect_nregs = try_nregs; |
| 46 | try_slab_size += page; |
| 47 | try_nregs = try_slab_size / reg_size; |
| 48 | if (perfect_slab_size == perfect_nregs * reg_size) { |
| 49 | perfect = true; |
| 50 | } |
| 51 | } |
| 52 | return (int)(perfect_slab_size / page); |
| 53 | } |
| 54 | |
| 55 | static void |
| 56 | size_class( |
no test coverage detected