#3572 mmap cache: memory mapped cache cannot use all allocated memory in the data table

Created 8 months ago by sbose
Modified 7 months ago

In sss_mmap_cache_init() we set a payload depending of the type of
cached data, e.g. for passwd data 4 * MC_SLOT_SIZE or for group data 3 *
MC_SLOT_SIZE. This value is used to calculate the data table size:

#define MC_DT_SIZE(elems, payload) ( (elems) * (payload) )

    mc_ctx->dt_size = MC_DT_SIZE(n_elem, payload);

since this does not change the slot size there is now room for e.g
(n_elem * 4) slots for passwd data, which makes sense since we assume
that a typical passwd entry will occupy 4 slot and we want the cache to
be able to store n_elem passwd entries.

But the memory for the tree table is calculated only with n_elem

#define MC_FT_SIZE(elems) ( (elems) / 8 )

    mc_ctx->ft_size = MC_FT_SIZE(n_elem);

This means that although we allocated memory for e.g. (4 * n_elem) slots
we can only handle n_elem slots because there are only n_elem bits in
the free table. As a result 3/4 of the allocate memory for the data is
unused and entries in the cache are overwritten earlier than needed.

I would suggest to just use a factor for the payload and increase the free table wih this factor as well.

Since this is not a pressing issue, but just not all the space is used, I'm filing the bug into the milestone after the next one. It might be a good idea to fix along with the refactoring of the memory cache in sssd-2.0.

8 months ago

Metadata Update from @jhrozek:
- Issue set to the milestone: SSSD 2.0

7 months ago

Metadata Update from @jhrozek:
- Issue priority set to: minor
- Issue tagged with: bug

Login to comment on this ticket.

cancel