From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,BIGNUM_EMAILS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70F09C433E0 for ; Thu, 21 Jan 2021 14:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29C5C239D4 for ; Thu, 21 Jan 2021 14:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731097AbhAUOoE (ORCPT ); Thu, 21 Jan 2021 09:44:04 -0500 Received: from mail-ot1-f53.google.com ([209.85.210.53]:38592 "EHLO mail-ot1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732125AbhAUOnl (ORCPT ); Thu, 21 Jan 2021 09:43:41 -0500 Received: by mail-ot1-f53.google.com with SMTP id 34so1785955otd.5 for ; Thu, 21 Jan 2021 06:43:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sXc33hxdRpwQJGKZjxNyVIcjvQKvzTxYx/3Q/uncr5E=; b=LQ7yhYFqyFAd2Kt8vCOnXt5iRDluGCHmdLHna56L/18R5LVHKJ2IpCyd2+EK2BFrSF LfwluhtZs7f29mOgWWlFmG5FpdMlXg9orzBcIr+B2h77iNQWQL2un97jqvqfY34vHEzX fdveT7AP7PxeHG0rH51cxF73zKi24RQ7JM+grzJV9m8Wsqgqt8xouOx7Ku8mKgsVCpPC +QVFVZ4afO1pm3a0qZxkUND8xa2fJYEdZACNWJscqx126wXPTQLvETibhkDYeXNHdrlu hAy/U4rU7y35eFnpu1LNlY/Jt2zfp9oUxTB4BjPVxn59hTpSS4h8kfySy8PE81BxgbqA 8bJA== X-Gm-Message-State: AOAM530t95sx/h2RUCFCJJLEGNcB8oKY5c/RvqCLQHgcxRraiueUTHzy 7qXkcER5998oJw3YXaft/iBpe9ulAHdHTQo0HejIR+uS X-Google-Smtp-Source: ABdhPJxPMAvoP0Dey6wXSHoUWIQQi4nNGO0bp/XQ7Noq3Wi0WUWWAwDvGkd1VDInoBf4Pn0Quw+NpQ5b5WQMeBioCpc= X-Received: by 2002:a9d:1710:: with SMTP id i16mr10453816ota.260.1611240178606; Thu, 21 Jan 2021 06:42:58 -0800 (PST) MIME-Version: 1.0 References: <20201118185917.GA433776@mwanda> <20210120093015.GE20161@MiWiFi-R3L-srv> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 21 Jan 2021 15:42:46 +0100 Message-ID: Subject: Re: [bug report] PM / reboot: Eliminate race between reboot and suspend To: Pingfan Liu , Baoquan He Cc: Dan Carpenter , Kexec Mailing List , Linux PM , Dave Young Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Thu, Jan 21, 2021 at 10:14 AM Pingfan Liu wrote: > > On Wed, Jan 20, 2021 at 5:30 PM Baoquan He wrote: > > > > Hi, > > > > On 11/18/20 at 09:59pm, Dan Carpenter wrote: > > > Hello Pingfan Liu, > > > > > > The patch 55f2503c3b69: "PM / reboot: Eliminate race between reboot > > > and suspend" from Jul 31, 2018, leads to the following static checker > > > warning: > > > > > > kernel/power/main.c:27 lock_system_sleep() > > > warn: called with lock held. '&system_transition_mutex' > > > > This is a good finding. I think we can simply remove the lock/unlock > > pair of system_transition_mutex in kernel_kexec() function. The dead > > lock should be easily triggered, but it hasn't caused any failure report > > because the feature 'kexec jump' is almost not used by anyone as far as > > I know. We may need to find out who is using it and where it's used > > through an inquiry. Before that, we can just remove the lock operation > > inside CONFIG_KEXEC_JUMP ifdeffery scope. Thanks. > > > > > > diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c > > index 80905e5aa8ae..a0b6780740c8 100644 > > --- a/kernel/kexec_core.c > > +++ b/kernel/kexec_core.c > > @@ -1134,7 +1134,6 @@ int kernel_kexec(void) > > > > #ifdef CONFIG_KEXEC_JUMP > > if (kexec_image->preserve_context) { > > - lock_system_sleep(); > > pm_prepare_console(); > > error = freeze_processes(); > > if (error) { > > @@ -1197,7 +1196,6 @@ int kernel_kexec(void) > > thaw_processes(); > > Restore_console: > > pm_restore_console(); > > - unlock_system_sleep(); > > This should work since the only caller syscall_reboot has already > placed kernel_kexec() under the protection of system_transition_mutex. > > Thanks for the fix. > > Reviewed-by: Pingfan Liu OK, so can anyone please submit that patch formally (Cc linux-pm, please)? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-ot1-f42.google.com ([209.85.210.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2bAq-0000jq-SR for kexec@lists.infradead.org; Thu, 21 Jan 2021 14:43:01 +0000 Received: by mail-ot1-f42.google.com with SMTP id a109so1803147otc.1 for ; Thu, 21 Jan 2021 06:43:00 -0800 (PST) MIME-Version: 1.0 References: <20201118185917.GA433776@mwanda> <20210120093015.GE20161@MiWiFi-R3L-srv> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 21 Jan 2021 15:42:46 +0100 Message-ID: Subject: Re: [bug report] PM / reboot: Eliminate race between reboot and suspend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Pingfan Liu , Baoquan He Cc: Dave Young , Kexec Mailing List , Dan Carpenter , Linux PM On Thu, Jan 21, 2021 at 10:14 AM Pingfan Liu wrote: > > On Wed, Jan 20, 2021 at 5:30 PM Baoquan He wrote: > > > > Hi, > > > > On 11/18/20 at 09:59pm, Dan Carpenter wrote: > > > Hello Pingfan Liu, > > > > > > The patch 55f2503c3b69: "PM / reboot: Eliminate race between reboot > > > and suspend" from Jul 31, 2018, leads to the following static checker > > > warning: > > > > > > kernel/power/main.c:27 lock_system_sleep() > > > warn: called with lock held. '&system_transition_mutex' > > > > This is a good finding. I think we can simply remove the lock/unlock > > pair of system_transition_mutex in kernel_kexec() function. The dead > > lock should be easily triggered, but it hasn't caused any failure report > > because the feature 'kexec jump' is almost not used by anyone as far as > > I know. We may need to find out who is using it and where it's used > > through an inquiry. Before that, we can just remove the lock operation > > inside CONFIG_KEXEC_JUMP ifdeffery scope. Thanks. > > > > > > diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c > > index 80905e5aa8ae..a0b6780740c8 100644 > > --- a/kernel/kexec_core.c > > +++ b/kernel/kexec_core.c > > @@ -1134,7 +1134,6 @@ int kernel_kexec(void) > > > > #ifdef CONFIG_KEXEC_JUMP > > if (kexec_image->preserve_context) { > > - lock_system_sleep(); > > pm_prepare_console(); > > error = freeze_processes(); > > if (error) { > > @@ -1197,7 +1196,6 @@ int kernel_kexec(void) > > thaw_processes(); > > Restore_console: > > pm_restore_console(); > > - unlock_system_sleep(); > > This should work since the only caller syscall_reboot has already > placed kernel_kexec() under the protection of system_transition_mutex. > > Thanks for the fix. > > Reviewed-by: Pingfan Liu OK, so can anyone please submit that patch formally (Cc linux-pm, please)? _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec