From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752003AbcFZBRA (ORCPT ); Sat, 25 Jun 2016 21:17:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:58286 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751731AbcFZBQ6 convert rfc822-to-8bit (ORCPT ); Sat, 25 Jun 2016 21:16:58 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,528,1459839600"; d="scan'208";a="835234895" From: "Chen, Yu C" To: Pavel Machek CC: "linux-pm@vger.kernel.org" , "x86@kernel.org" , "Rafael J. Wysocki" , Len Brown , Peter Zijlstra , "H. Peter Anvin" , Borislav Petkov , Brian Gerst , Thomas Gleixner , Ingo Molnar , Varun Koyyalagunta , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 1/4][RFC v2] PM / sleep: Avoid accessing frozen_cpus if it is NULL Thread-Topic: [PATCH 1/4][RFC v2] PM / sleep: Avoid accessing frozen_cpus if it is NULL Thread-Index: AQHRzvxBnR8pp2nqjkmsX9Y/TmO1CJ/533uAgAEREtA= Date: Sun, 26 Jun 2016 01:16:54 +0000 Message-ID: <36DF59CE26D8EE47B0655C516E9CE6402877B7D6@shsmsx102.ccr.corp.intel.com> References: <20160625165113.GA4362@amd> In-Reply-To: <20160625165113.GA4362@amd> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2ZmOWQ2YzMtMzM2MS00ZWFhLTk5ZDAtMjZkY2U3YTY5ZTc2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlNuQzRYZmUrMFVtVnIwaTdTRXROSDIzOGVlMnJRVzdTTTVtUFVIT0NIVGs9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > -----Original Message----- > From: Pavel Machek [mailto:pavel@ucw.cz] > Sent: Sunday, June 26, 2016 12:51 AM > To: Chen, Yu C > Cc: linux-pm@vger.kernel.org; x86@kernel.org; Rafael J. Wysocki; Len Brown; > Peter Zijlstra; H. Peter Anvin; Borislav Petkov; Brian Gerst; Thomas Gleixner; > Ingo Molnar; Varun Koyyalagunta; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/4][RFC v2] PM / sleep: Avoid accessing frozen_cpus if it > is NULL > > On Sun 2016-06-26 00:18:30, Chen Yu wrote: > > frozen_cpus might be NULL if the allocation in previous > > alloc_frozen_cpus failed, when CONFIG_CPUMASK_OFFSTACK is set. > > > > This patch avoid accessing this cpumask if it is NULL. > > > > Signed-off-by: Chen Yu > > --- > > kernel/cpu.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/kernel/cpu.c b/kernel/cpu.c index d948e44..d25266e 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -1021,6 +1021,8 @@ int disable_nonboot_cpus(void) { > > int cpu, first_cpu, error = 0; > > > > + if (frozen_cpus == NULL) > > + return -ENOMEM; > > cpu_maps_update_begin(); > > first_cpu = cpumask_first(cpu_online_mask); > > /* > > I'd say that whoever allocates frozen_cpus should just abort the hibernation if > there's not enough memory for the operation...? This seems like checking for > the problem too late. > The allocation of frozen_cpus is alloc_frozen_cpus, which is in core_initcall, and do_initcall during boot up seems not to care about the return value from these functions. So I think either we add the check in disable_nonboot_cpus, or we can set noresume = 1 and nohibernate = 1 if alloc_frozen_cpus fails. thanks, Yu