From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751753AbcFZBe2 (ORCPT ); Sat, 25 Jun 2016 21:34:28 -0400 Received: from mga09.intel.com ([134.134.136.24]:28223 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751410AbcFZBe0 convert rfc822-to-8bit (ORCPT ); Sat, 25 Jun 2016 21:34:26 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,528,1459839600"; d="scan'208";a="128575747" 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 3/4][RFC v2] PM / hibernate: introduce a flag to indicate resuming from hibernation Thread-Topic: [PATCH 3/4][RFC v2] PM / hibernate: introduce a flag to indicate resuming from hibernation Thread-Index: AQHRzvxJhoM9ICy2FEuKaL9JZa1o0Z/53/0AgAEUOFA= Date: Sun, 26 Jun 2016 01:34:22 +0000 Message-ID: <36DF59CE26D8EE47B0655C516E9CE6402877B804@shsmsx102.ccr.corp.intel.com> References: <20160625165302.GC4362@amd> In-Reply-To: <20160625165302.GC4362@amd> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWVjZjk3YTUtYjAzNy00ZjY0LTk0NGMtYTUxMWQ4NDVkMWUyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlFQSnhla2d6WFI1VVlmcGQyUzhIbTgrUWFNRG1FZG1TcGJEYmJGdzlrVUk9In0= 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:53 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 3/4][RFC v2] PM / hibernate: introduce a flag to indicate > resuming from hibernation > > On Sun 2016-06-26 00:18:52, Chen Yu wrote: > > Sometime we need to do some operations before resuming from > > hibernation, so introduce a flag to indicate this stage. > > > > Signed-off-by: Chen Yu > > --- > > include/linux/suspend.h | 7 +++++++ > > kernel/power/hibernate.c | 3 +++ > > 2 files changed, 10 insertions(+) > > > > diff --git a/include/linux/suspend.h b/include/linux/suspend.h index > > 8b6ec7e..422e87a 100644 > > --- a/include/linux/suspend.h > > +++ b/include/linux/suspend.h > > @@ -384,6 +384,12 @@ extern bool system_entering_hibernation(void); > > extern bool hibernation_available(void); asmlinkage int > > swsusp_save(void); extern struct pbe *restore_pblist; > > +extern bool in_resume_hibernate; > > in_resume_hibernation? But it is pretty sad if we need another such > state function... At first I tried not to add any new flags, and just let all the CPUs fall into hlt if it is triggered by disable_nonboot_cpus, but as depicted in [PATCH 4/4], there is a scenario that, what about the CPUs already offline before the hibernation? They might be in deep cstate by mwait, and mwait is not safe during resume. We have to kick all the offline CPUs online again, and then put them offline to hlt state, thus to avoid the unsafe memory access during resume. (The memory mapping for text code is not safe during resume, so it's hard to fix it in mwait_play_dead, and the kick mechanism seems to be a suitable choice). In order to restrict the impact of the kick mechanism to a minimal scope, I used this flag to make this mechanism only work for hibernation resume phase. thanks, Yu