Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

9675 memory leak from cpupart_create #669

Closed
wants to merge 1 commit into from

Conversation

brad-lewis
Copy link

Reviewed by: George Wilson george.wilson@delphix.com
Reviewed by: Pavel Zakharov pavel.zakharov@delphix.com

In usr/src/uts/common/disp/cpupart.c, cpupart_create() allocates a buffer and assigns it to the
cp_lgrploads member of a cpupart_t struct:

pp->cp_nlgrploads = lgrp_plat_max_lgrps();
pp->cp_lgrploads = kmem_zalloc(sizeof (lpl_t) * pp->cp_nlgrploads,
KM_SLEEP);

The function then goes on to call cpupart_lpl_initialize(), which allocates an identical buffer and
assigns it to the same field, leaking the original buffer:

sz = cp->cp_nlgrploads = lgrp_plat_max_lgrps();
cp->cp_lgrploads = kmem_zalloc(sizeof (lpl_t) * sz, KM_SLEEP);

We should be able to just remove the initial allocation.

Upstream bug: DLPX-56280

Copy link

@rmustacc rmustacc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks.

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>

In usr/src/uts/common/disp/cpupart.c, cpupart_create() allocates a
buffer and assigns it to the cp_lgrploads member of a cpupart_t struct:

    pp->cp_nlgrploads = lgrp_plat_max_lgrps();
        pp->cp_lgrploads = kmem_zalloc(sizeof (lpl_t) * pp->cp_nlgrploads,
            KM_SLEEP);

The function then goes on to call cpupart_lpl_initialize(), which
allocates an identical buffer and assigns it to the same field, leaking
the original buffer:

    sz = cp->cp_nlgrploads = lgrp_plat_max_lgrps();
        cp->cp_lgrploads = kmem_zalloc(sizeof (lpl_t) * sz, KM_SLEEP);

We should be able to just remove the initial allocation.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants