From patchwork Fri Nov 14 12:26:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 40826 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FC9A240ED for ; Fri, 14 Nov 2014 12:36:11 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id a1sf561753wgh.11 for ; Fri, 14 Nov 2014 04:36:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=7SawPeGtDLCgaeLvNzgKm1SShIzjfhr3njjPjxtcZzk=; b=NZM5QVnv10KR063x9+NBfPnFpeNf0VKlXua9DGtqcGGmndtNeG6zEqZzlCKEm9/Lrb tgYiD+EXQCgvFAxfblSWKodS2zEjgEtGFSlu4cIm/JrOMg9zKkYjuqeBmewKo7WPrmNH MJpCWvMDPYKXNUOH3kZ0vhAoBDf9uY2a0HQ8nc2uIlhE/DRQoVVd5l1xx9xZ+tXq7KLm CTf71OJY9oIoMxByPcWqhYwfrvJdd4hx+QYfFYstyWkZzAkU/fmAabMNdBbO+e5yYg24 uNt1PGkLndNymMFfM9mi12RYvpo4iSphB+QgoG1ShhmVlGkqYILDf/W4pAXPaFlLf7pl 412A== X-Gm-Message-State: ALoCoQlnJVfVFM5Uxt/4GzAbA9NvREsQkQxhsXfr4K8VlzC6ug3YwxvgDwnssVBt6hKApkVHHrOH X-Received: by 10.152.10.233 with SMTP id l9mr2588082lab.0.1415968570751; Fri, 14 Nov 2014 04:36:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.227 with SMTP id ap3ls913416lac.60.gmail; Fri, 14 Nov 2014 04:36:10 -0800 (PST) X-Received: by 10.112.159.129 with SMTP id xc1mr8159845lbb.24.1415968570576; Fri, 14 Nov 2014 04:36:10 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id w6si41525895lad.65.2014.11.14.04.36.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 04:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id mc6so15113891lab.12 for ; Fri, 14 Nov 2014 04:36:10 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr7998594laa.71.1415968570473; Fri, 14 Nov 2014 04:36:10 -0800 (PST) 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.184.201 with SMTP id ew9csp756211lbc; Fri, 14 Nov 2014 04:36:09 -0800 (PST) X-Received: by 10.68.249.133 with SMTP id yu5mr9689751pbc.31.1415968081299; Fri, 14 Nov 2014 04:28:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tf10si28257803pab.175.2014.11.14.04.28.00 for ; Fri, 14 Nov 2014 04:28:01 -0800 (PST) Received-SPF: none (google.com: stable-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 S933506AbaKNM1u (ORCPT + 1 other); Fri, 14 Nov 2014 07:27:50 -0500 Received: from cantor2.suse.de ([195.135.220.15]:59447 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935327AbaKNM1Z (ORCPT ); Fri, 14 Nov 2014 07:27:25 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7178D75053; Fri, 14 Nov 2014 12:26:59 +0000 (UTC) Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.83) (envelope-from ) id 1XpFxe-0002bp-Qc; Fri, 14 Nov 2014 13:26:46 +0100 From: Jiri Slaby To: stable@vger.kernel.org Cc: Wang Nan , Steven Rostedt , Andrew Morton , Linus Torvalds , Jiri Slaby Subject: [patch added to the 3.12 stable tree] cgroup/kmemleak: add kmemleak_free() for cgroup deallocations. Date: Fri, 14 Nov 2014 13:26:14 +0100 Message-Id: <1415968006-9521-74-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1415968006-9521-1-git-send-email-jslaby@suse.cz> References: <1415968006-9521-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 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: , From: Wang Nan This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 401507d67d5c2854f5a88b3f93f64fc6f267bca5 upstream. Commit ff7ee93f4715 ("cgroup/kmemleak: Annotate alloc_page() for cgroup allocations") 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 Offlined Pages 32768 kmemleak: Cannot insert 0xffff880016969000 into the object search tree (overlaps existing) CPU: 0 PID: 412 Comm: sleep Not tainted 3.17.0-rc5+ #86 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x46/0x58 create_object+0x266/0x2c0 kmemleak_alloc+0x26/0x50 kmem_cache_alloc+0xd3/0x160 __sigqueue_alloc+0x49/0xd0 __send_signal+0xcb/0x410 send_signal+0x45/0x90 __group_send_sig_info+0x13/0x20 do_notify_parent+0x1bb/0x260 do_exit+0x767/0xa40 do_group_exit+0x44/0xa0 SyS_exit_group+0x17/0x20 system_call_fastpath+0x16/0x1b kmemleak: Kernel memory leak detector disabled kmemleak: Object 0xffff880016900000 (size 524288): kmemleak: comm "swapper/0", pid 0, jiffies 4294667296 kmemleak: min_count = 0 kmemleak: count = 0 kmemleak: flags = 0x1 kmemleak: checksum = 0 kmemleak: backtrace: log_early+0x63/0x77 kmemleak_alloc+0x4b/0x50 init_section_page_cgroup+0x7f/0xf5 page_cgroup_init+0xc5/0xd0 start_kernel+0x333/0x408 x86_64_start_reservations+0x2a/0x2c x86_64_start_kernel+0xf5/0xfc Fixes: ff7ee93f4715 (cgroup/kmemleak: Annotate alloc_page() for cgroup allocations) Signed-off-by: Wang Nan Acked-by: Johannes Weiner Acked-by: Michal Hocko Cc: Steven Rostedt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Jiri Slaby --- mm/page_cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index 6d757e3a872a..e007236f345a 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c @@ -170,6 +170,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); } }