Bug 11740 - Addressing memory leak in loadparm during reload services.
Summary: Addressing memory leak in loadparm during reload services.
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.3.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
: 10583 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-16 22:43 UTC by Hemanth
Modified: 2016-11-16 16:24 UTC (History)
2 users (show)

See Also:


Attachments
Patch for master. (3.54 KB, patch)
2016-02-16 22:59 UTC, Hemanth
no flags Details
git-am fix for 4.4.0, 4.3.next, 4.2.next. (3.66 KB, patch)
2016-02-17 21:50 UTC, Jeremy Allison
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hemanth 2016-02-16 22:43:20 UTC
Hi folks,

While investigating one of our memory buildup issues, we have found that loadparm
structures count getting increased on every time smbd receives SIGHUP.

Actually there was an issue with one of our internal modules. We were sending SIGHUP to all smbd processes every 5 mins even though there are no config changes.This has exposed the real problem in Samba. On every reload, samba removes all unused services including IPC$ and re-add them. But service ptrs are never freed(only marked as free), If we have hundreds of shares, this is going to cause huge buildup if there is a real need to send SIGHUPs to smbds.

Here are I have captured the growth of loadparm structures at various times while SIGHUPs being sent to smbds in between.

$ sudo smbcontrol 5317 pool-usage | grep "struct loadparm"
    struct loadparm_service *      contains   6852 bytes in 140 blocks (ref 0)
        struct loadparm_service        contains    907 bytes in  38 blocks (ref 0)
        struct loadparm_service        contains   1281 bytes in  49 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains   1240 bytes in  47 blocks (ref 0)
                            struct loadparm_context        contains     96 bytes in   1 blocks (ref 0)
$ sudo smbcontrol 5317 pool-usage | grep "struct loadparm"
    struct loadparm_service *      contains   8212 bytes in 142 blocks (ref 0)
        struct loadparm_service        contains    907 bytes in  38 blocks (ref 0)
        struct loadparm_service        contains   1281 bytes in  49 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains   1240 bytes in  47 blocks (ref 0)
                            struct loadparm_context        contains     96 bytes in   1 blocks (ref 0)
$ sudo smbcontrol 5317 pool-usage | grep "struct loadparm"
    struct loadparm_service *      contains   8892 bytes in 143 blocks (ref 0)
        struct loadparm_service        contains   1281 bytes in  49 blocks (ref 0)
        struct loadparm_service        contains    907 bytes in  38 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains    672 bytes in   1 blocks (ref 0)
        struct loadparm_service        contains   1240 bytes in  47 blocks (ref 0)
                            struct loadparm_context        contains     96 bytes in   1 blocks (ref 0)

To see this problem, you can send SIGHUP to any smbds(sudo kill -SIGHUP <smbd-pid>) and count the number of loadparm instances in pool-usage.

I have made some changes to resolve this issue. I will be posting that soon.
Comment 1 Hemanth 2016-02-16 22:59:02 UTC
Created attachment 11844 [details]
Patch for master.
Comment 2 Jeremy Allison 2016-02-16 23:24:36 UTC
Hemanth, can you also propose this on samba-technical please ?

Thanks,

Jeremy.
Comment 3 Hemanth 2016-02-17 00:16:37 UTC
(In reply to Jeremy Allison from comment #2)
Hi Jeremy,
I just did that. My earlier email went to some bounce list. I have sent to correct list now.
Comment 4 Jeremy Allison 2016-02-17 21:50:10 UTC
Created attachment 11847 [details]
git-am fix for 4.4.0, 4.3.next, 4.2.next.

Cherry-picked from the code that went into master.
Comment 5 Jeremy Allison 2016-02-18 17:01:36 UTC
Re-assigning to Karolin for inclusion in 4.4.0, 4.3.next, 4.2.next.
Comment 6 Karolin Seeger 2016-02-22 10:19:10 UTC
Pushed to autobuild-v4-[4|3|2]-test.
Comment 7 Karolin Seeger 2016-02-23 10:52:24 UTC
(In reply to Karolin Seeger from comment #6)
Pushed to all branches.
Closing out bug report.

Thanks!
Comment 8 Andreas Schneider 2016-11-16 16:24:22 UTC
*** Bug 10583 has been marked as a duplicate of this bug. ***