linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Hao <haokexin@gmail.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	Pavel Machek <pavel@ucw.cz>,
	"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 2/3] powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread
Date: Thu, 21 Dec 2023 12:45:09 +0800	[thread overview]
Message-ID: <20231221044510.1802429-3-haokexin@gmail.com> (raw)
In-Reply-To: <20231221044510.1802429-1-haokexin@gmail.com>

A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So for the following snippet of code in a kernel thread loop:
  wait_event_interruptible();
  try_to_freeze();

We can change it to a simple wait_event_freezable() and then eliminate
a function call.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
 arch/powerpc/platforms/83xx/suspend.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c
index eed325ed08cc..c9664e46b03d 100644
--- a/arch/powerpc/platforms/83xx/suspend.c
+++ b/arch/powerpc/platforms/83xx/suspend.c
@@ -264,8 +264,7 @@ static int agent_thread_fn(void *data)
 	set_freezable();
 
 	while (1) {
-		wait_event_interruptible(agent_wq, pci_pm_state >= 2);
-		try_to_freeze();
+		wait_event_freezable(agent_wq, pci_pm_state >= 2);
 
 		if (signal_pending(current) || pci_pm_state < 2)
 			continue;
-- 
2.39.2


  parent reply	other threads:[~2023-12-21  4:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21  4:45 [PATCH 0/3] powerpc: Fixes and optimization for the freezable kthread Kevin Hao
2023-12-21  4:45 ` [PATCH 1/3] powerpc: mpc83xx: Add the missing set_freezable() for agent_thread_fn() Kevin Hao
2023-12-21  4:45 ` Kevin Hao [this message]
2023-12-21  4:45 ` [PATCH 3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread() Kevin Hao
2023-12-21  6:36   ` Geoff Levand
2023-12-21 11:17     ` Michael Ellerman
2023-12-31 11:07 ` [PATCH 0/3] powerpc: Fixes and optimization for the freezable kthread Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231221044510.1802429-3-haokexin@gmail.com \
    --to=haokexin@gmail.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).