From patchwork Thu Oct 15 13:26:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 7406111 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6A6D49F506 for ; Thu, 15 Oct 2015 13:27:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C781220762 for ; Thu, 15 Oct 2015 13:27:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0866F2086A for ; Thu, 15 Oct 2015 13:27:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752727AbbJON1B (ORCPT ); Thu, 15 Oct 2015 09:27:01 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36074 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbbJON07 (ORCPT ); Thu, 15 Oct 2015 09:26:59 -0400 Received: by padcn9 with SMTP id cn9so6619831pad.3; Thu, 15 Oct 2015 06:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=2vSo2Vl3okB6m6rhsfMpe3ddur5b8rbUeTY1SJ2bezs=; b=DfTv03vNuKdEuzlX+n5t8KQ3nQU7tyXAHx/1Ax+303xCgBQYkxLKYcYhcQJVzqrAcj auH28ApY6RgoaSugFsGNWRJ/hG7k5uACW0nUkPy+mrrvw91eL3lXZIBKGc1YEwrG+mQp PgXk+OGOT9lGtEK3e+H+R6UTVzFv4VumDfRFvqLRW5BL9i6WfK2gIyifVlPp83zxuMUK ZPDHyqO8cH0/ySER/9DIVXiXcRcIzdOw+6JF81lEFMIH7BKrB8/uW4vNCvZhxsppAw0W 97uY4pWPVQjI01U6z9gZKNZASIwapiTUKeV3w7vYxngUm76BLUFmi6k3ECUVs/K2eyGA EWKQ== X-Received: by 10.66.228.97 with SMTP id sh1mr9961919pac.91.1444915619132; Thu, 15 Oct 2015 06:26:59 -0700 (PDT) Received: from localhost (port-55390.pppoe.wtnet.de. [46.59.217.16]) by smtp.gmail.com with ESMTPSA id rc5sm15517267pbc.95.2015.10.15.06.26.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 06:26:58 -0700 (PDT) Date: Thu, 15 Oct 2015 15:26:55 +0200 From: Thierry Reding To: Michael Ellerman Cc: "Rafael J. Wysocki" , Wonhong Kwon , Len Brown , Pavel Machek , linux-next@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Runtime PM causes oops on next-20151015 Message-ID: <20151015132655.GA20406@ulmo.nvidia.com> References: <20151015092213.GA26614@ulmo.nvidia.com> <1444903494.8464.5.camel@ellerman.id.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1444903494.8464.5.camel@ellerman.id.au> User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Oct 15, 2015 at 09:04:54PM +1100, Michael Ellerman wrote: > On Thu, 2015-10-15 at 11:22 +0200, Thierry Reding wrote: > > Hi Rafael, Wonhong, > > > > Todays linux-next breaks rather spectacularly for drivers using runtime > > PM. The culprit seems to be this commit: > > > > commit 7d24068e144adc03b805806645d732cf79488717 > > Author: Wonhong Kwon > > Date: Tue Oct 6 10:10:20 2015 +0900 > > > > PM / hibernate: Move pm_init/pm_disk_init to late_initcall_sync > > > > pm_init is being invoked by core_initcall and hibernate_image_size_init > > calculates preferred image size (image_size) based on total pages > > (totalram_pages). This totalram_pages can be modified during various > > initcall-s phase and this can cause miscalculated image_size. > > > > For example, when CMA is being used, init_cma_reserved_pageblock tries > > to change the totalram_pages and this job is done during core_initcall. > > In order words, the totalram_pages doesn't take CMA reserved pages into > > account when image_size is calculated and it can be too small. > > > > Move pm_init and pm_disk_init to late_initcall_sync so that it happens > > after all other initcall-s change the totalram_pages. > > > > Reported-by: Sangseok Lee > > Signed-off-by: Wonhong Kwon > > Signed-off-by: Rafael J. Wysocki > > > > I'm seeing one too on powerpc: > > Unable to handle kernel paging request for data at address 0x00000030 > Faulting instruction address: 0xc0000000002e4094 > Oops: Kernel access of bad area, sig: 11 [#1] > SMP NR_CPUS=2048 NUMA pSeries > Modules linked in: > CPU: 5 PID: 1 Comm: swapper/0 Not tainted 4.3.0-rc5-next-20151015-50217-ge2be40d-dirty #37 > task: c0000001fefc0000 ti: c0000001fb000000 task.ti: c0000001fb000000 > NIP: c0000000002e4094 LR: c000000000c79dd4 CTR: c000000000c79d90 > REGS: c0000001fb003900 TRAP: 0300 Not tainted (4.3.0-rc5-next-20151015-50217-ge2be40d-dirty) > MSR: 8000000100009032 CR: 28000882 XER: 20000000 > CFAR: c0000000000d117c DAR: 0000000000000030 DSISR: 40000000 SOFTE: 1 > GPR00: c00000000000b074 c0000001fb003b80 c000000000e93800 0000000000000000 > GPR04: c000000000d15c80 0000000000000000 00000001ff150000 0000000000000026 > GPR08: c000000000d0f748 c000000000f41a10 c000000000d0f8e8 c000000000abc59d > GPR12: c000000000b42400 c00000000fdc1680 c00000000000b960 0000000000000000 > GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR24: 0000000000000000 c000000000de0360 c000000000c45d28 0000000000000000 > GPR28: c000000000deca80 c000000000d103c0 c0000001fbc905c0 c000000000d103c0 > NIP [c0000000002e4094] .sysfs_create_file_ns+0x4/0x50 > LR [c000000000c79dd4] .__machine_initcall_pseries_apo_pm_init+0x44/0x60 > Call Trace: > [c0000001fb003b80] [c0000000004852cc] .kasprintf+0x2c/0x40 (unreliable) > [c0000001fb003bf0] [c00000000000b074] .do_one_initcall+0xc4/0x250 > [c0000001fb003ce0] [c000000000c64560] .kernel_init_freeable+0x268/0x348 > [c0000001fb003db0] [c00000000000b97c] .kernel_init+0x1c/0x140 > [c0000001fb003e30] [c0000000000095ac] .ret_from_kernel_thread+0x58/0xac > Instruction dump: > 419e001c 3ce2ffa8 38e7be60 4bfffea4 3ce2ffa8 38e7bea8 4bfffe9c 3ce2ffa8 > 38e7bea8 4bfffe8c 60000000 2c230000 41820028 2fa30000 419e0020 > ---[ end trace d2a742ce359651dd ]--- > > Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b > > > Which starts at: > > static int __init apo_pm_init(void) > { > return (sysfs_create_file(power_kobj, &auto_poweron_attr.attr)); > } > machine_device_initcall(pseries, apo_pm_init); > > And seems to be caused by power_kobj being NULL: > > 0:mon> d $power_kobj > c000000000f41a10 0000000000000000 0000000000000000 |................| Yes, power_kobj is one of the other objects created by pm_init() and which, evidently, needs to be available much earlier than late_initcall. The patch below works for me, though I don't use hibernate on this machine, so that part is untested. Thierry --- >8 --- diff --git a/kernel/power/main.c b/kernel/power/main.c index b2dd4d999900..2f66453e3a9b 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -648,8 +648,6 @@ static int __init pm_init(void) int error = pm_start_workqueue(); if (error) return error; - hibernate_image_size_init(); - hibernate_reserved_size_init(); power_kobj = kobject_create_and_add("power", NULL); if (!power_kobj) return -ENOMEM; @@ -661,3 +659,13 @@ static int __init pm_init(void) } core_initcall(pm_init); + +static int __init hibernate_init(void) +{ + hibernate_image_size_init(); + hibernate_reserved_size_init(); + + return 0; +} + +late_initcall_sync(hibernate_init);