John Taylor has uploaded a new change for review.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
vdsm: Fix memory leak in netlink.py
The documentation for libnl says that calls to rtnl_link_get_by_name increment the reference counter and should be released by a call to rtnl_link_put(). That's not done in the get_link(name) function where it is used and causes a memory leak.
Add a C function prototype for the libnl rtnl_link_put function, construct the link_info, and call rtnl_link_put before returning from get_link(name).
Change-Id: I6e4dc72bd77e46ba4f95dd8a622f5c3288115315 Signed-off-by: John Taylor jtt77777@yahoo.com --- M lib/vdsm/netlink.py 1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/39372/1
diff --git a/lib/vdsm/netlink.py b/lib/vdsm/netlink.py index afae5ce..d822944 100644 --- a/lib/vdsm/netlink.py +++ b/lib/vdsm/netlink.py @@ -64,8 +64,9 @@ if not link: raise IOError(errno.ENODEV, '%s is not present in the system' % name) - return _link_info(cache, link) - + link_info = _link_info(cache, link) + _rtnl_link_put(link) + return link_info
class NLSocketPool(object): """Pool of netlink sockets.""" @@ -332,5 +333,7 @@ _nl_af2str = _int_char_proto(('nl_af2str', LIBNL)) _rtnl_scope2str = _int_char_proto(('rtnl_scope2str', LIBNL_ROUTE))
+_rtnl_link_put = _none_proto(('rtnl_link_put', LIBNL_ROUTE)) + _nl_link_cache = partial(_cache_manager, _rtnl_link_alloc_cache) _nl_addr_cache = partial(_cache_manager, _rtnl_addr_alloc_cache)
automation@ovirt.org has posted comments on this change.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
Patch Set 1: Verified-1
* Update tracker::IGNORE, no Bug-Url found
* Check Bug-Url::ERROR, At least one bug-url is required for the stable branch * warn_if_not_merged_to_previous_branch: OK
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Thanks again for the research and suggested fix. This patch should be first resolved on the master branch.
https://gerrit.ovirt.org/#/c/39372/1/lib/vdsm/netlink.py File lib/vdsm/netlink.py:
Line 63: link_get_by_name based only on cursory review of the libnl docs, it seems that this function too requires refcount maintenance.
John Taylor has posted comments on this change.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/39372/1/lib/vdsm/netlink.py File lib/vdsm/netlink.py:
Line 63: link_get_by_name
based only on cursory review of the libnl docs, it seems that this function
the _rtnl_link_put on line 68 is the call that will decrement the refcount, allowing the later call to _nl_cache_free(cache), done in the _cache_manager @contextmanager finally block, to be able to free the links in the cache. It might make more sense to do it like in master https://gerrit.ovirt.org/#/c/39416/ where it is immediately following the call to get the link.
Dan Kenigsberg has abandoned this change.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
Abandoned
taken https://gerrit.ovirt.org/40134 instead
automation@ovirt.org has posted comments on this change.
Change subject: vdsm: Fix memory leak in netlink.py ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org