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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C216C4321E for ; Mon, 5 Dec 2022 12:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231390AbiLEML5 (ORCPT ); Mon, 5 Dec 2022 07:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbiLEMLw (ORCPT ); Mon, 5 Dec 2022 07:11:52 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5DA6562 for ; Mon, 5 Dec 2022 04:11:51 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so14600861pjs.4 for ; Mon, 05 Dec 2022 04:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=je642uC/QM2q2uiJ455cWQgJTQZ2s2VIKEuHkYSqLSY=; b=FEmiEyAfYIdpKkVVrcM2myJBq9Gd26hAz6+4yOpADnvfMVE0aPesCBgx342rXF08lp TCQyXF8GkzmtS6Z9YrWkolPOItK1xsEU+96tzXEDb1AlyAmzgDCo23jDO4Kl30xB1XIr tkvIYPgXOQR4RxorORzC5LorpFYswRYs8vLVc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=je642uC/QM2q2uiJ455cWQgJTQZ2s2VIKEuHkYSqLSY=; b=vFuTa7rWJ5sEMiSgXF95DpaogE/PJqOXE1xGUV42n7LHsnKPpS8yXYSRxzJXCL1WC8 qnysYsxYlU5RzUCllBQyIZ5tdxRDI6QKbYSEiL5Z6Kz7gF7q6VCBflgjwWbCSpuovmq3 ugF3WrXmq0GpOYVgzmauY3wXr624nUSR4gAkQF3a50Hz0KCFV4NlkymjPuUlztuaFGB5 PUY6Umc78qT42PCIgD5Ms5EaFvu5AaaMBZkawLy15nTr9/sMxbozKf3Qi0iV/xah1KQl kSPI3uRiYPDxTp4XtURf6bWord3K4CpP2SH+1CLdJMAbQmQSNQF7WbwYbfI3jPil4PBl yVGA== X-Gm-Message-State: ANoB5pmG6IkUOx/dNyIaiW/2sPYdSRgLVImuohy1d7Wapz8PGSbSYjUr 9wUub/nJCDxwp3eA1w3HwQ9kMnlswqoKfV73 X-Google-Smtp-Source: AA0mqf5XH6324rXIRv9FgA4GXw8Ga/rBSdx+Z5HnKetuGP7gYwiFgYzL4oFcgLCIQICZ65ARV88Ofw== X-Received: by 2002:a17:903:191:b0:186:5cda:1e01 with SMTP id z17-20020a170903019100b001865cda1e01mr66741601plg.111.1670242310241; Mon, 05 Dec 2022 04:11:50 -0800 (PST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com. [209.85.214.170]) by smtp.gmail.com with ESMTPSA id p14-20020a17090a2c4e00b0020d24ea4400sm10881867pjm.38.2022.12.05.04.11.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Dec 2022 04:11:49 -0800 (PST) Received: by mail-pl1-f170.google.com with SMTP id y4so10609014plb.2 for ; Mon, 05 Dec 2022 04:11:49 -0800 (PST) X-Received: by 2002:a17:902:7d93:b0:186:9cf4:e53b with SMTP id a19-20020a1709027d9300b001869cf4e53bmr68703080plm.50.1670241940337; Mon, 05 Dec 2022 04:05:40 -0800 (PST) MIME-Version: 1.0 References: <20221127-snd-freeze-v8-0-3bc02d09f2ce@chromium.org> <20221127-snd-freeze-v8-2-3bc02d09f2ce@chromium.org> In-Reply-To: From: Ricardo Ribalda Date: Mon, 5 Dec 2022 13:05:29 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 2/3] freezer: refactor pm_freezing into a function. To: "Rafael J. Wysocki" Cc: Juergen Gross , Mark Brown , Chromeos Kdump , Daniel Baluta , Christophe Leroy , Len Brown , Ard Biesheuvel , Ranjani Sridharan , Boris Ostrovsky , Nicholas Piggin , Michael Ellerman , Eric Biederman , Dave Hansen , Jaroslav Kysela , Joel Fernandes , Liam Girdwood , Peter Ujfalusi , Pavel Machek , Pierre-Louis Bossart , Kai Vehmanen , Steven Rostedt , "K. Y. Srinivasan" , Ingo Molnar , Bjorn Helgaas , Dexuan Cui , Takashi Iwai , "H. Peter Anvin" , Bard Liao , Haiyang Zhang , Wei Liu , Thomas Gleixner , Borislav Petkov , x86@kernel.org, kexec@lists.infradead.org, alsa-devel@alsa-project.org, stable@vger.kernel.org, sound-open-firmware@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org Hi Rafael On Fri, 2 Dec 2022 at 18:48, Rafael J. Wysocki wrote: > > On Thu, Dec 1, 2022 at 12:08 PM Ricardo Ribalda wrote: > > > > Add a way to let the drivers know if the processes are frozen. > > > > This is needed by drivers that are waiting for processes to end on their > > shutdown path. > > > > Convert pm_freezing into a function and export it, so it can be used by > > drivers that are either built-in or modules. > > > > Cc: stable@vger.kernel.org > > Fixes: 83bfc7e793b5 ("ASoC: SOF: core: unregister clients and machine drivers in .shutdown") > > Signed-off-by: Ricardo Ribalda > > Why can't you export the original pm_freezing variable and why is this > fixing anything? Because then any module will be able to modify the content of the variable. The Fixes: is because the last patch on the set is doing a real fix. If you only cherry-pick the last patch on a stable branch, the build will fail. (Also, the zero-day builder complains) Anyway, I think we can hold this patch for a bit. The snd people are discussing if this the way to handle it, or if we should handle .shutdown in a different way. Thanks! > > > --- > > include/linux/freezer.h | 3 ++- > > kernel/freezer.c | 3 +-- > > kernel/power/process.c | 24 ++++++++++++++++++++---- > > 3 files changed, 23 insertions(+), 7 deletions(-) > > > > diff --git a/include/linux/freezer.h b/include/linux/freezer.h > > index b303472255be..3413c869d68b 100644 > > --- a/include/linux/freezer.h > > +++ b/include/linux/freezer.h > > @@ -13,7 +13,7 @@ > > #ifdef CONFIG_FREEZER > > DECLARE_STATIC_KEY_FALSE(freezer_active); > > > > -extern bool pm_freezing; /* PM freezing in effect */ > > +bool pm_freezing(void); > > extern bool pm_nosig_freezing; /* PM nosig freezing in effect */ > > > > /* > > @@ -80,6 +80,7 @@ static inline int freeze_processes(void) { return -ENOSYS; } > > static inline int freeze_kernel_threads(void) { return -ENOSYS; } > > static inline void thaw_processes(void) {} > > static inline void thaw_kernel_threads(void) {} > > +static inline bool pm_freezing(void) { return false; } > > > > static inline bool try_to_freeze(void) { return false; } > > > > diff --git a/kernel/freezer.c b/kernel/freezer.c > > index 4fad0e6fca64..2d3530ebdb7e 100644 > > --- a/kernel/freezer.c > > +++ b/kernel/freezer.c > > @@ -20,7 +20,6 @@ EXPORT_SYMBOL(freezer_active); > > * indicate whether PM freezing is in effect, protected by > > * system_transition_mutex > > */ > > -bool pm_freezing; > > bool pm_nosig_freezing; > > > > /* protects freezing and frozen transitions */ > > @@ -46,7 +45,7 @@ bool freezing_slow_path(struct task_struct *p) > > if (pm_nosig_freezing || cgroup_freezing(p)) > > return true; > > > > - if (pm_freezing && !(p->flags & PF_KTHREAD)) > > + if (pm_freezing() && !(p->flags & PF_KTHREAD)) > > return true; > > > > return false; > > diff --git a/kernel/power/process.c b/kernel/power/process.c > > index ddd9988327fe..8a4d0e2c8c20 100644 > > --- a/kernel/power/process.c > > +++ b/kernel/power/process.c > > @@ -108,6 +108,22 @@ static int try_to_freeze_tasks(bool user_only) > > return todo ? -EBUSY : 0; > > } > > > > +/* > > + * Indicate whether PM freezing is in effect, protected by > > + * system_transition_mutex. > > + */ > > +static bool pm_freezing_internal; > > + > > +/** > > + * pm_freezing - indicate whether PM freezing is in effect. > > + * > > + */ > > +bool pm_freezing(void) > > +{ > > + return pm_freezing_internal; > > +} > > +EXPORT_SYMBOL(pm_freezing); > > Use EXPORT_SYMBOL_GPL() instead, please. > > > + > > /** > > * freeze_processes - Signal user space processes to enter the refrigerator. > > * The current thread will not be frozen. The same process that calls > > @@ -126,12 +142,12 @@ int freeze_processes(void) > > /* Make sure this task doesn't get frozen */ > > current->flags |= PF_SUSPEND_TASK; > > > > - if (!pm_freezing) > > + if (!pm_freezing()) > > static_branch_inc(&freezer_active); > > > > pm_wakeup_clear(0); > > pr_info("Freezing user space processes ... "); > > - pm_freezing = true; > > + pm_freezing_internal = true; > > error = try_to_freeze_tasks(true); > > if (!error) { > > __usermodehelper_set_disable_depth(UMH_DISABLED); > > @@ -187,9 +203,9 @@ void thaw_processes(void) > > struct task_struct *curr = current; > > > > trace_suspend_resume(TPS("thaw_processes"), 0, true); > > - if (pm_freezing) > > + if (pm_freezing()) > > static_branch_dec(&freezer_active); > > - pm_freezing = false; > > + pm_freezing_internal = false; > > pm_nosig_freezing = false; > > > > oom_killer_enable(); > > > > -- > > -- > You received this message because you are subscribed to the Google Groups "Chromeos Kdump" group. > To unsubscribe from this group and stop receiving emails from it, send an email to chromeos-kdump+unsubscribe@google.com. > To view this discussion on the web, visit https://groups.google.com/a/google.com/d/msgid/chromeos-kdump/CAJZ5v0jbKSTQopEoXW9FpqDmAqp6Pn%3D-Om5QP2-7ocuGdq8R9w%40mail.gmail.com. -- Ricardo Ribalda