All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rafael J. Wysocki <rjw at rjwysocki.net>
To: devel@acpica.org
Subject: [Devel] Re: power-off delay/hang due to commit 6d25be57 (mainline)
Date: Sat, 02 Jan 2021 12:03:17 +0100	[thread overview]
Message-ID: <1744807.WFtog62eDp@kreacher> (raw)
In-Reply-To: 9709109.MH8tSaV5v9@kreacher

[-- Attachment #1: Type: text/plain, Size: 3992 bytes --]

On Thursday, December 31, 2020 9:46:11 PM CET Rafael J. Wysocki wrote:
> On Wednesday, December 2, 2020 8:13:38 PM CET Rafael J. Wysocki wrote:
> > On Wed, Dec 2, 2020 at 7:31 PM Rafael J. Wysocki <rafael(a)kernel.org> wrote:
> > >
> > > On Wed, Dec 2, 2020 at 7:03 PM Sebastian Andrzej Siewior
> > > <bigeasy(a)linutronix.de> wrote:
> > > >
> > > > On 2020-10-26 18:20:59 [+0100], To Rafael J. Wysocki wrote:
> > > > > > > > > Done as Bug 208877.
> > > > > > > Rafael, do you have any suggestions?
> > > > > >
> > > > > > I've lost track of this sorry.
> > > > > >
> > > > > > I have ideas, let me get back to this next week.
> > > > >
> > > > > :)
> > > >
> > > > Rafael, any update? If you outline an idea or so then I may be able to
> > > > form a patch out of it. Otherwise I have no idea how to fix this - other
> > > > than telling the driver to not poll in smaller intervals than
> > > > 30secs.
> > >
> > > The idea, roughly speaking, is to limit the number of outstanding work
> > > items in the queue (basically, if there's a notification occurring
> > > before the previous one can be handled, there is no need to queue up
> > > another work item for it).
> > 
> > That's easier said than done, though, because of the way the work item
> > queue-up is hooked up into the ACPICA code.
> 
> So scratch this and it wouldn't work in general anyway AFAICS.
> 
> ATM, I'm tempted to do something like the patch below (with the rationale
> that it shouldn't be necessary to read the temperature right after updating
> the trip points if polling is in use, because the next update through polling
> will cause it to be read anyway and it will trigger trip point actions as
> needed).

There is one more way to address this, probably better: instead of checking the
temperature right away in acpi_thermal_notify(), queue that on acpi_thermal_pm_queue
and so only if another thermal check is not pending.

This way there will be at most one temperature check coming from
acpi_thermal_notify() queued up at any time which should prevent the
build-up of work items from taking place.

So something like this:

---
 drivers/acpi/thermal.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Index: linux-pm/drivers/acpi/thermal.c
===================================================================
--- linux-pm.orig/drivers/acpi/thermal.c
+++ linux-pm/drivers/acpi/thermal.c
@@ -900,6 +900,12 @@ static void acpi_thermal_unregister_ther
                                  Driver Interface
    -------------------------------------------------------------------------- */
 
+static void acpi_queue_thermal_check(struct acpi_thermal *tz)
+{
+	if (!work_pending(&tz->thermal_check_work))
+		queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
+}
+
 static void acpi_thermal_notify(struct acpi_device *device, u32 event)
 {
 	struct acpi_thermal *tz = acpi_driver_data(device);
@@ -910,17 +916,17 @@ static void acpi_thermal_notify(struct a
 
 	switch (event) {
 	case ACPI_THERMAL_NOTIFY_TEMPERATURE:
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		break;
 	case ACPI_THERMAL_NOTIFY_THRESHOLDS:
 		acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  dev_name(&device->dev), event, 0);
 		break;
 	case ACPI_THERMAL_NOTIFY_DEVICES:
 		acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  dev_name(&device->dev), event, 0);
 		break;
@@ -1117,7 +1123,7 @@ static int acpi_thermal_resume(struct de
 		tz->state.active |= tz->trips.active[i].flags.enabled;
 	}
 
-	queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
+	acpi_queue_thermal_check(tz);
 
 	return AE_OK;
 }



WARNING: multiple messages have this Message-ID (diff)
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Stephen Berman <stephen.berman@gmx.net>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Robert Moore <robert.moore@intel.com>,
	Erik Kaneda <erik.kaneda@intel.com>, Len Brown <lenb@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	"open list:ACPI COMPONENT ARCHITECTURE (ACPICA)"
	<devel@acpica.org>, "Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: power-off delay/hang due to commit 6d25be57 (mainline)
Date: Sat, 02 Jan 2021 12:03:17 +0100	[thread overview]
Message-ID: <1744807.WFtog62eDp@kreacher> (raw)
In-Reply-To: <9709109.MH8tSaV5v9@kreacher>

On Thursday, December 31, 2020 9:46:11 PM CET Rafael J. Wysocki wrote:
> On Wednesday, December 2, 2020 8:13:38 PM CET Rafael J. Wysocki wrote:
> > On Wed, Dec 2, 2020 at 7:31 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > >
> > > On Wed, Dec 2, 2020 at 7:03 PM Sebastian Andrzej Siewior
> > > <bigeasy@linutronix.de> wrote:
> > > >
> > > > On 2020-10-26 18:20:59 [+0100], To Rafael J. Wysocki wrote:
> > > > > > > > > Done as Bug 208877.
> > > > > > > Rafael, do you have any suggestions?
> > > > > >
> > > > > > I've lost track of this sorry.
> > > > > >
> > > > > > I have ideas, let me get back to this next week.
> > > > >
> > > > > :)
> > > >
> > > > Rafael, any update? If you outline an idea or so then I may be able to
> > > > form a patch out of it. Otherwise I have no idea how to fix this - other
> > > > than telling the driver to not poll in smaller intervals than
> > > > 30secs.
> > >
> > > The idea, roughly speaking, is to limit the number of outstanding work
> > > items in the queue (basically, if there's a notification occurring
> > > before the previous one can be handled, there is no need to queue up
> > > another work item for it).
> > 
> > That's easier said than done, though, because of the way the work item
> > queue-up is hooked up into the ACPICA code.
> 
> So scratch this and it wouldn't work in general anyway AFAICS.
> 
> ATM, I'm tempted to do something like the patch below (with the rationale
> that it shouldn't be necessary to read the temperature right after updating
> the trip points if polling is in use, because the next update through polling
> will cause it to be read anyway and it will trigger trip point actions as
> needed).

There is one more way to address this, probably better: instead of checking the
temperature right away in acpi_thermal_notify(), queue that on acpi_thermal_pm_queue
and so only if another thermal check is not pending.

This way there will be at most one temperature check coming from
acpi_thermal_notify() queued up at any time which should prevent the
build-up of work items from taking place.

So something like this:

---
 drivers/acpi/thermal.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Index: linux-pm/drivers/acpi/thermal.c
===================================================================
--- linux-pm.orig/drivers/acpi/thermal.c
+++ linux-pm/drivers/acpi/thermal.c
@@ -900,6 +900,12 @@ static void acpi_thermal_unregister_ther
                                  Driver Interface
    -------------------------------------------------------------------------- */
 
+static void acpi_queue_thermal_check(struct acpi_thermal *tz)
+{
+	if (!work_pending(&tz->thermal_check_work))
+		queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
+}
+
 static void acpi_thermal_notify(struct acpi_device *device, u32 event)
 {
 	struct acpi_thermal *tz = acpi_driver_data(device);
@@ -910,17 +916,17 @@ static void acpi_thermal_notify(struct a
 
 	switch (event) {
 	case ACPI_THERMAL_NOTIFY_TEMPERATURE:
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		break;
 	case ACPI_THERMAL_NOTIFY_THRESHOLDS:
 		acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  dev_name(&device->dev), event, 0);
 		break;
 	case ACPI_THERMAL_NOTIFY_DEVICES:
 		acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
-		acpi_thermal_check(tz);
+		acpi_queue_thermal_check(tz);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  dev_name(&device->dev), event, 0);
 		break;
@@ -1117,7 +1123,7 @@ static int acpi_thermal_resume(struct de
 		tz->state.active |= tz->trips.active[i].flags.enabled;
 	}
 
-	queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work);
+	acpi_queue_thermal_check(tz);
 
 	return AE_OK;
 }




             reply	other threads:[~2021-01-02 11:03 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 11:03 Rafael J. Wysocki [this message]
2021-01-02 11:03 ` power-off delay/hang due to commit 6d25be57 (mainline) Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2021-01-25 16:25 [Devel] " Rafael J. Wysocki
2021-01-25 16:25 ` Rafael J. Wysocki
2020-08-11 14:02 [Devel] " Rafael J. Wysocki
2020-08-11 14:02 ` Rafael J. Wysocki
2020-05-01 15:46 Stephen Berman
2020-05-06 21:57 ` Sebastian Andrzej Siewior
2020-05-08 21:30   ` Stephen Berman
2020-05-13 22:04     ` Sebastian Andrzej Siewior
2020-05-14 21:39       ` Stephen Berman
2020-05-22 16:40         ` Sebastian Andrzej Siewior
2020-06-09 10:06           ` Stephen Berman
2020-06-09 20:23             ` Sebastian Andrzej Siewior
2020-06-10  8:21               ` Stephen Berman
2020-06-10 10:25                 ` Sebastian Andrzej Siewior
2020-06-10 22:49                   ` Stephen Berman
2020-06-11 15:39                     ` Stephen Berman
2020-06-12 11:01                       ` Sebastian Andrzej Siewior
2020-06-14 12:12                         ` Stephen Berman
2020-06-14 17:10                           ` Sebastian Andrzej Siewior
2020-06-15  7:58                             ` Stephen Berman
2020-06-15 14:51                               ` Sebastian Andrzej Siewior
2020-06-15 15:41                                 ` Stephen Berman
2020-06-15 15:58                                   ` Sebastian Andrzej Siewior
2020-06-15 16:19                                     ` Stephen Berman
2020-06-15 16:32                                       ` Sebastian Andrzej Siewior
2020-06-16  7:14                                 ` Stephen Berman
2020-06-16  7:38                                   ` Sebastian Andrzej Siewior
2020-06-16  8:13                                     ` Stephen Berman
2020-06-16 15:55                                       ` Sebastian Andrzej Siewior
2020-06-16 20:28                                         ` Stephen Berman
2020-06-17 14:27                                           ` Sebastian Andrzej Siewior
2020-06-17 21:09                                             ` Stephen Berman
2020-06-24 20:11                                               ` Sebastian Andrzej Siewior
2020-06-24 21:49                                                 ` Stephen Berman
2020-07-14 13:44                                                   ` Sebastian Andrzej Siewior
2020-07-14 13:54                                                     ` [Devel] " Rafael J. Wysocki
2020-07-14 13:54                                                       ` Rafael J. Wysocki
2020-07-14 14:11                                                       ` Sebastian Andrzej Siewior
2020-07-14 15:53                                                         ` [Devel] " Rafael J. Wysocki
2020-07-14 15:53                                                           ` Rafael J. Wysocki
2020-07-14 16:10                                                           ` Sebastian Andrzej Siewior
2020-08-11 10:27                                                           ` Sebastian Andrzej Siewior
2020-07-19 10:07                                                         ` Stephen Berman
2020-08-11 11:58                                                           ` Stephen Berman
2020-08-11 13:29                                                             ` Sebastian Andrzej Siewior
2020-08-11 14:34                                                               ` [Devel] " Rafael J. Wysocki
2020-08-11 14:34                                                                 ` Rafael J. Wysocki
2020-08-11 15:25                                                                 ` Sebastian Andrzej Siewior
2020-08-11 17:22                                                                   ` Stephen Berman
2020-08-11 18:49                                                                     ` Sebastian Andrzej Siewior
2020-10-06 21:49                                                                       ` Sebastian Andrzej Siewior
2020-10-07 16:18                                                                         ` Rafael J. Wysocki
2020-10-26 17:20                                                                           ` Sebastian Andrzej Siewior
2020-12-02 18:03                                                                             ` Sebastian Andrzej Siewior
2020-12-02 18:31                                                           ` [Devel] " Rafael J. Wysocki
2020-12-02 18:31                                                             ` Rafael J. Wysocki
2020-12-02 19:13                                                             ` [Devel] " Rafael J. Wysocki
2020-12-02 19:13                                                               ` Rafael J. Wysocki
2020-12-31 20:46                                                               ` [Devel] " Rafael J. Wysocki
2020-12-31 20:46                                                                 ` Rafael J. Wysocki
2021-01-04 15:38                                                                 ` Stephen Berman
2021-01-24 13:49                                                                   ` Stephen Berman
2020-06-20 19:08               ` [PATCH] SCSI: Disable CD-ROM poll on shutdown kernel test robot
2020-06-20 19:08                 ` kernel test robot
2020-06-09 21:26             ` power-off delay/hang due to commit 6d25be57 (mainline) Stephen Berman

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=1744807.WFtog62eDp@kreacher \
    --to=devel@acpica.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.