From patchwork Thu Sep 18 01:38:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 37580 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F3C552054D for ; Thu, 18 Sep 2014 01:51:12 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf172277wid.0 for ; Wed, 17 Sep 2014 18:51:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=IOpxH1sW+0/OAozBYMF00AqtJ/e7bn5jQfyRkE+U26E=; b=Go8nrskpNMRhMs/J+YIah/41Ag4qSll+w9pO+PD5vxR/wPlkCv0lRX0tijnJA7hgxV tmG1kBoKrv6wgUkGDwXr7kyHfce+x0pJXaXG3v3Om+fyiF/tQutmAL6GA0U6qjTGyPIY xG2ygd7oKfbPFr1eRtMULDngeRFL4oMNC4PO/nAYPEHWckjW06OJoXSGztZ7DSKh0yfc JzCqX0PCocWWPr+EOu8E0upSyVQKcamKHs+YENZ1vqLSc4P3axPK6iXQQ3+dB3+07FCI CbMQy4pgoIeXKsnR16dYcDw58GnlbQEX+CHCWokqr+EkocrhIHeYgVgu2DM6rJUSlhVZ bWbA== X-Gm-Message-State: ALoCoQk2uFfBe8HUEJQrJgSG2Sz9q8oo06s26GY2yw0TwcsVchU9zq9m4Mjkfez/Tvi052WF+RGN X-Received: by 10.152.42.229 with SMTP id r5mr29026lal.8.1411005072181; Wed, 17 Sep 2014 18:51:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.169 with SMTP id k9ls175425laa.91.gmail; Wed, 17 Sep 2014 18:51:11 -0700 (PDT) X-Received: by 10.152.27.66 with SMTP id r2mr1344211lag.84.1411005071913; Wed, 17 Sep 2014 18:51:11 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id e3si30760407lbs.17.2014.09.17.18.51.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 18:51:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id l4so220060lbv.16 for ; Wed, 17 Sep 2014 18:51:11 -0700 (PDT) X-Received: by 10.112.224.9 with SMTP id qy9mr866924lbc.57.1411005071811; Wed, 17 Sep 2014 18:51:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp681047lbb; Wed, 17 Sep 2014 18:51:11 -0700 (PDT) X-Received: by 10.68.134.71 with SMTP id pi7mr1701808pbb.86.1411005070293; Wed, 17 Sep 2014 18:51:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qw8si10643286pab.226.2014.09.17.18.51.09 for ; Wed, 17 Sep 2014 18:51:10 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757364AbaIRBux (ORCPT + 27 others); Wed, 17 Sep 2014 21:50:53 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:45576 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757154AbaIRBuv (ORCPT ); Wed, 17 Sep 2014 21:50:51 -0400 Received: from 172.24.2.119 (EHLO lggeml421-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBV01076; Thu, 18 Sep 2014 09:50:47 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml421-hub.china.huawei.com (10.72.61.31) with Microsoft SMTP Server id 14.3.158.1; Thu, 18 Sep 2014 09:50:37 +0800 From: Wang Nan To: Johannes Weiner , Michal Hocko , Steven Rostedt CC: , , , Li Zefan Subject: [PATCH] cgroup/kmemleak: add kmemleak_free() for cgroup deallocations. Date: Thu, 18 Sep 2014 09:38:05 +0800 Message-ID: <1411004285-42101-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Commit ff7ee93f4 introduces kmemleak_alloc() for alloc_page_cgroup(), but corresponding kmemleak_free() is missing, which makes kmemleak be wrongly disabled after memory offlining. Log is pasted at the end of this commit message. This patch add kmemleak_free() into free_page_cgroup(). During page offlining, this patch removes corresponding entries in kmemleak rbtree. After that, the freed memory can be allocated again by other subsystems without killing kmemleak. bash # for x in 1 2 3 4; do echo offline > /sys/devices/system/memory/memory$x/state ; sleep 1; done ; dmesg | grep leak [ 45.537934] Offlined Pages 32768 [ 46.617892] kmemleak: Cannot insert 0xffff880016969000 into the object search tree (overlaps existing) [ 46.617892] CPU: 0 PID: 412 Comm: sleep Not tainted 3.17.0-rc5+ #86 [ 46.617892] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 46.617892] ffff880016823d10 ffff880018bdfc38 ffffffff81725d2c ffff88001780e950 [ 46.617892] ffff880016969000 ffff880018bdfc88 ffffffff8117a9e6 ffff880018bdfc78 [ 46.617892] 0000000000000096 ffff880017812800 ffffffff81c2eda0 ffff880016969000 [ 46.617892] Call Trace: [ 46.617892] [] dump_stack+0x46/0x58 [ 46.617892] [] create_object+0x266/0x2c0 [ 46.617892] [] kmemleak_alloc+0x26/0x50 [ 46.617892] [] kmem_cache_alloc+0xd3/0x160 [ 46.617892] [] __sigqueue_alloc+0x49/0xd0 [ 46.617892] [] __send_signal+0xcb/0x410 [ 46.617892] [] send_signal+0x45/0x90 [ 46.617892] [] __group_send_sig_info+0x13/0x20 [ 46.617892] [] do_notify_parent+0x1bb/0x260 [ 46.617892] [] ? sched_move_task+0xaa/0x130 [ 46.617892] [] do_exit+0x767/0xa40 [ 46.617892] [] do_group_exit+0x44/0xa0 [ 46.617892] [] SyS_exit_group+0x17/0x20 [ 46.617892] [] system_call_fastpath+0x16/0x1b [ 46.617892] kmemleak: Kernel memory leak detector disabled [ 46.617892] kmemleak: Object 0xffff880016900000 (size 524288): [ 46.617892] kmemleak: comm "swapper/0", pid 0, jiffies 4294667296 [ 46.617892] kmemleak: min_count = 0 [ 46.617892] kmemleak: count = 0 [ 46.617892] kmemleak: flags = 0x1 [ 46.617892] kmemleak: checksum = 0 [ 46.617892] kmemleak: backtrace: [ 46.617892] [] log_early+0x63/0x77 [ 46.617892] [] kmemleak_alloc+0x4b/0x50 [ 46.617892] [] init_section_page_cgroup+0x7f/0xf5 [ 46.617892] [] page_cgroup_init+0xc5/0xd0 [ 46.617892] [] start_kernel+0x333/0x408 [ 46.617892] [] x86_64_start_reservations+0x2a/0x2c [ 46.617892] [] x86_64_start_kernel+0xf5/0xfc [ 46.617892] [] 0xffffffffffffffff Signed-off-by: Wang Nan Cc: Steven Rostedt Acked-by: Johannes Weiner Acked-by: Michal Hocko --- mm/page_cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 3708264..5331c2b 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c @@ -171,6 +171,7 @@ static void free_page_cgroup(void *addr) sizeof(struct page_cgroup) * PAGES_PER_SECTION; BUG_ON(PageReserved(page)); + kmemleak_free(addr); free_pages_exact(addr, table_size); } }