Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1711476

Re: [PATCH] slub: fix per memcg cache leak on css offline

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From David Rientjes <rientjes@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH] slub: fix per memcg cache leak on css offline
Date Mon, 14 Aug 2017 23:30:02 +0200
Message-ID <uev5U-Rc-7@gated-at.bofh.it> (permalink)
References <udJaW-4mD-9@gated-at.bofh.it>
X-Original-To Vladimir Davydov <vdavydov.dev@gmail.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=g5DONXUfcFtnovwi0wzeZUAJi7XVAE+TZ1TcLg47fco=; b=SuGk4kCkRr4DRHhB+Ls2fxpqToxsaK9G0XMTbM1Gpxijp9IzRUHxjsEQMprOfpgOi8 5exCpqU9cTlNQ00gfVZS4HQ/7Y6tMmx9rEV9pkwYAsA6Kw71+iQAggHemvSoXvmCV9MW Az8fDMEtBapLAfkm9oZT8VNvYZYn7wa6uMzdjB2iEta6ZjNxtaNrfsjdWhuYNlTQ8lwK +Hjt7uCfzBj+ziLy88aZ9vPBGobMaQhp9ZZVaHRAmQphdzPVdhdTB8ZQjOYg2q1j6YIW SnCkBFxZSywsOlnQydTGXh2r5v4yeV1q+6jJAjf/oQ3ZGmrbVOxnmwo+IB5tE1bJk1Wh uz4w==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=g5DONXUfcFtnovwi0wzeZUAJi7XVAE+TZ1TcLg47fco=; b=pDp4OPZMSnJAfyQsJegWpLbgUrN+jsWLGEZqGM9sPXT4oZQOYAx+vDl/PJM1JWFS1C SbgepklDL+puHKJgq4kmcTi+mrGvTTHSdjX4k7E/CFWTU/xDFWqutqkfmQmGz8JovK+w H0d+lq0nRy3uPF/r0TyVpT5UiusdvJqF6tV0y3wgdaD6F1Lvc430xe+YaO9Qtq3fUTdS NGEMtRnXLp/qTk7iWkxsktwE2FU+lHb3ypwepobeFrdyHyFUUx+RtRV304iCcLbw+7bn dyS16YkfsSqho/dyjTmHz+2TxaxjcL3o8FX4h6PtBZWpjrDi3F90XaIl3I/9G7Ce/SFF sajA==
X-Gm-Message-State AHYfb5ilrBd2cZvs1jIlu50OYJCibUcPzws1+0mlvsclIMju79db30rS 6y+r4/NR2p9gWe6U
X-Received by 10.84.232.207 with SMTP id x15mr28847400plm.18.1502746173054; Mon, 14 Aug 2017 14:29:33 -0700 (PDT)
X-X-Sender rientjes@chino.kir.corp.google.com
User-Agent Alpine 2.10 (DEB 1266 2009-07-14)
MIME-Version 1.0
Content-Type TEXT/PLAIN; charset=US-ASCII
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 64
Organization linux.* mail to news gateway
X-Original-Cc Andrew Morton <akpm@linux-foundation.org>, Michal Hocko <mhocko@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrei Vagin <avagin@gmail.com>, Tejun Heo <tj@kernel.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org
X-Original-Date Mon, 14 Aug 2017 14:29:31 -0700 (PDT)
X-Original-Message-ID <alpine.DEB.2.10.1708141429190.19280@chino.kir.corp.google.com>
X-Original-References <20170812181134.25027-1-vdavydov.dev@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1711476

Show key headers only | View raw


On Sat, 12 Aug 2017, Vladimir Davydov wrote:

> To avoid a possible deadlock, sysfs_slab_remove() schedules an
> asynchronous work to delete sysfs entries corresponding to the kmem
> cache. To ensure the cache isn't freed before the work function is
> called, it takes a reference to the cache kobject. The reference is
> supposed to be released by the work function. However, the work function
> (sysfs_slab_remove_workfn()) does nothing in case the cache sysfs entry
> has already been deleted, leaking the kobject and the corresponding
> cache. This may happen on a per memcg cache destruction, because sysfs
> entries of a per memcg cache are deleted on memcg offline if the cache
> is empty (see __kmemcg_cache_deactivate()).
> 
> The kmemleak report looks like this:
> 
>   unreferenced object 0xffff9f798a79f540 (size 32):
>     comm "kworker/1:4", pid 15416, jiffies 4307432429 (age 28687.554s)
>     hex dump (first 32 bytes):
>       6b 6d 61 6c 6c 6f 63 2d 31 36 28 31 35 39 39 3a  kmalloc-16(1599:
>       6e 65 77 72 6f 6f 74 29 00 23 6b c0 ff ff ff ff  newroot).#k.....
>     backtrace:
>       [<ffffffff9591d28a>] kmemleak_alloc+0x4a/0xa0
>       [<ffffffff9527a378>] __kmalloc_track_caller+0x148/0x2c0
>       [<ffffffff95499466>] kvasprintf+0x66/0xd0
>       [<ffffffff954995a9>] kasprintf+0x49/0x70
>       [<ffffffff952305c6>] memcg_create_kmem_cache+0xe6/0x160
>       [<ffffffff9528eaf0>] memcg_kmem_cache_create_func+0x20/0x110
>       [<ffffffff950cd6c5>] process_one_work+0x205/0x5d0
>       [<ffffffff950cdade>] worker_thread+0x4e/0x3a0
>       [<ffffffff950d5169>] kthread+0x109/0x140
>       [<ffffffff9592b8fa>] ret_from_fork+0x2a/0x40
>       [<ffffffffffffffff>] 0xffffffffffffffff
>   unreferenced object 0xffff9f79b6136840 (size 416):
>     comm "kworker/1:4", pid 15416, jiffies 4307432429 (age 28687.573s)
>     hex dump (first 32 bytes):
>       40 fb 80 c2 3e 33 00 00 00 00 00 40 00 00 00 00  @...>3.....@....
>       00 00 00 00 00 00 00 00 10 00 00 00 10 00 00 00  ................
>     backtrace:
>       [<ffffffff9591d28a>] kmemleak_alloc+0x4a/0xa0
>       [<ffffffff95275bc8>] kmem_cache_alloc+0x128/0x280
>       [<ffffffff9522fedb>] create_cache+0x3b/0x1e0
>       [<ffffffff952305f8>] memcg_create_kmem_cache+0x118/0x160
>       [<ffffffff9528eaf0>] memcg_kmem_cache_create_func+0x20/0x110
>       [<ffffffff950cd6c5>] process_one_work+0x205/0x5d0
>       [<ffffffff950cdade>] worker_thread+0x4e/0x3a0
>       [<ffffffff950d5169>] kthread+0x109/0x140
>       [<ffffffff9592b8fa>] ret_from_fork+0x2a/0x40
>       [<ffffffffffffffff>] 0xffffffffffffffff
> 
> Fix the leak by adding the missing call to kobject_put() to
> sysfs_slab_remove_workfn().
> 
> Signed-off-by: Vladimir Davydov <vdavydov.dev@gmail.com>
> Reported-and-tested-by: Andrei Vagin <avagin@gmail.com>
> Acked-by: Tejun Heo <tj@kernel.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Christoph Lameter <cl@linux.com>
> Cc: Pekka Enberg <penberg@kernel.org>
> Cc: David Rientjes <rientjes@google.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Fixes: 3b7b314053d02 ("slub: make sysfs file removal asynchronous")

Acked-by: David Rientjes <rientjes@google.com>

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] slub: fix per memcg cache leak on css offline Vladimir Davydov <vdavydov.dev@gmail.com> - 2017-08-12 20:20 +0200
  Re: [PATCH] slub: fix per memcg cache leak on css offline David Rientjes <rientjes@google.com> - 2017-08-14 23:30 +0200

csiph-web