From patchwork Sun Aug 13 03:50:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 9897559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 992BB60351 for ; Sun, 13 Aug 2017 03:50:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7146428687 for ; Sun, 13 Aug 2017 03:50:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64DD628691; Sun, 13 Aug 2017 03:50:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 953ED28687 for ; Sun, 13 Aug 2017 03:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752233AbdHMDuv (ORCPT ); Sat, 12 Aug 2017 23:50:51 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:34837 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752227AbdHMDuu (ORCPT ); Sat, 12 Aug 2017 23:50:50 -0400 Received: by mail-wm0-f41.google.com with SMTP id m85so16598281wma.0 for ; Sat, 12 Aug 2017 20:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=nWA/PXiF0oJ/Gys1JcAAmIXWZEtq9Yf2sKry1l9uHeg=; b=aYH5zchweaFVqD0sh8eZJXUl5/ULrW47RXqVulaHrjcQc36/FItyPl1aFrN1Mg7ENp 7ZjQG8aoMQjZ+IAnADVn9VmbpQMBw+3LO4Bko+OU86oR7+M7nI/uQep81JKJMo3NuGPb 4QzS5ZkCTt+B+ug3lEUPEf9QByWzmV5Rlv68U= 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=nWA/PXiF0oJ/Gys1JcAAmIXWZEtq9Yf2sKry1l9uHeg=; b=Rrtp7GtxzIXqK6n+ZvMSdzHvPMdIcFJNOH/K4SQ0+gTzdNtItAu9q2vnrRzM1C+GmC OaXS+I0w8zcgwwA0kDN9wSK0pLjhq4spRAkap1ive35wBOHzKD8RaPhsitVnmlO3wYVZ Ykh/Ab0HReHEsDqMt0DvkPbo75lo9koCgo3xdCRg8GJbywb2ClJlE4KDNXKurfIp+x5w nnc2z4S30BZetJEVU8VlqyGDj9nkM1LJQrgaHqnS1vzZDoxG5s+JePOIYJl10na5v8qM xU+ZDD/smu2OF4Edejhwia8Er7XWdk0cP3AjlKmMm6LurI05OeDTxH5N/03vQBFO68DN yGJQ== X-Gm-Message-State: AHYfb5h2YhiYwRfcpdb4LjqEmAXQOL9PG1lWSaQNS4eKWs/OYaf+HXqF BD2IBF6x0/xvZuIu X-Received: by 10.80.166.37 with SMTP id d34mr20338696edc.94.1502596248726; Sat, 12 Aug 2017 20:50:48 -0700 (PDT) Received: from leoy-linaro (li524-22.members.linode.com. [176.58.122.22]) by smtp.gmail.com with ESMTPSA id g54sm2821634eda.19.2017.08.12.20.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Aug 2017 20:50:47 -0700 (PDT) Date: Sun, 13 Aug 2017 11:50:40 +0800 From: Leo Yan To: Stefan Wahren Cc: "Rafael J. Wysocki" , Daniel Lezcano , Sudeep Holla , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [Bug] ARM: cpuidle: possible memleak Message-ID: <20170813035040.GA13637@leoy-linaro> References: <1980049531.494543.1502543973258@email.1und1.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1980049531.494543.1502543973258@email.1und1.de> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Stefan, On Sat, Aug 12, 2017 at 03:19:33PM +0200, Stefan Wahren wrote: > Hi, > > if i additionally enable kmemleak (on top of multi_v7_defconfig) on RPi 3 (4 cores) with 4.13-rc4, i get the following output from kmemleak: > > unreferenced object 0xede0dc00 (size 1024): > comm "swapper/0", pid 1, jiffies 4294937431 (age 744.510s) > hex dump (first 32 bytes): > 94 9e 0b c1 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 57 46 49 00 00 00 00 00 00 00 00 00 00 00 00 00 WFI............. > backtrace: > [] arm_idle_init+0x44/0x1ac > [] do_one_initcall+0x3c/0x16c > [] kernel_init_freeable+0x110/0x1d0 > [] kernel_init+0x8/0x114 > [] ret_from_fork+0x14/0x3c > [] 0xffffffff > > If i revert the last commit in cpuidle-arm d50a7d8acd78 ("ARM: cpuidle: Support asymmetric idle definition") then kmemleak stays calm. I cannot reproduce the error at my side, I also tried to disable idle states but cannot trigger the failure. So first thing is to know the reason for registeration failure and finally introduce the memory leaking. Could you point out the dts you are using for idle states binding? Also reviewed a bit for the idle driver, it does have issue to handle failure case. I tweaked a bit for it, could you try it? Also would like to hear the comments from Daniel. > > Best regards > Stefan diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 7080c38..80dc86f 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -152,11 +152,13 @@ static int __init arm_idle_init(void) out_fail: while (--cpu >= 0) { dev = per_cpu(cpuidle_devices, cpu); - cpuidle_unregister_device(dev); - kfree(dev); - drv = cpuidle_get_driver(); + drv = cpuidle_get_cpu_driver(dev); + cpuidle_unregister_driver(drv); kfree(drv); + + cpuidle_unregister_device(dev); + kfree(dev); } return ret;