Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp12553976pxu; Sat, 2 Jan 2021 03:07:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwF+adhnPUWsiSTcJ8AdCJWdd+pIcJmcSdAqA2KU1/qW2pyJV+mUp5Yv9K4hb78DF64RFwO X-Received: by 2002:a17:906:3bcd:: with SMTP id v13mr60020387ejf.181.1609585638371; Sat, 02 Jan 2021 03:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609585638; cv=none; d=google.com; s=arc-20160816; b=gdFjHufFNVeOYa4Y78ARUsT5MF8rFlyLpTb/Qkj5hMkOLavYRYZyZKi92HkQEs8+av LxBRLwXo/1Rps9zPy1U4oQMjDFBm++x1kydZ7n78+prsmfPPYQD/rnaMWvwrBFsGHX7p kwOZqeR5MqfNTCYFDce3dbkNHzppYiz+6U4Rt2hHeE47V+inJH9SI8TOtLhaxlm+TXKu NeOlad3Iky+TQVr2LsdqrUu+pQy/4xQzD7JSDtP3tL/RJOIIiZ2JElSEug0pZLe48QSX s+WhkMmxmcIaFJ5El7TtFUKmNnAu77DP18C+aWQLZXj7kJA3KahnZb9oereVL82kAqu7 Fn+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wJJZ2OtAlRJDTxCR1QkW8qQg8VoXLFtFWZ1vy+yghLs=; b=G2RX+z+fkj+u4UaaMejPGKoXHSreL3LpjazPCVB6mUrdzTTq6nqYvcZBeG116hCgmn sqZQq19AxSEDTcoGusklZfF44D9U1qo+HwEpPuBtOPtM3hJWfp4yASND51R9A/+Y+msq LFABthPAunRYMVMvv+HYFcwx6H2CpG14tX8aKoGN6bkiZQf490P6LHkwVN44wztEs2zX izweEBWk/LHdx7UijrmWJDHAmIu/Fcu7+CjvKfDySQ86M7x2R0hKzkMbVrRfOdcSPGBl dqy8EVSNAH8lXy2/6ngg32prrewelAiFCLDt11QRiKKBeCIXSubE/FlyJEnISLG6/NjW Aeqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs24si28377564edb.519.2021.01.02.03.06.31; Sat, 02 Jan 2021 03:07:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbhABLED (ORCPT + 99 others); Sat, 2 Jan 2021 06:04:03 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:55248 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbhABLEC (ORCPT ); Sat, 2 Jan 2021 06:04:02 -0500 Received: from 89-77-60-66.dynamic.chello.pl (89.77.60.66) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.537) id f83ed3595adce064; Sat, 2 Jan 2021 12:03:18 +0100 From: "Rafael J. Wysocki" To: Sebastian Andrzej Siewior , Stephen Berman Cc: Zhang Rui , Robert Moore , Erik Kaneda , Len Brown , Thomas Gleixner , Peter Zijlstra , Linux Kernel Mailing List , ACPI Devel Maling List , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , "Rafael J. Wysocki" Subject: Re: power-off delay/hang due to commit 6d25be57 (mainline) Date: Sat, 02 Jan 2021 12:03:17 +0100 Message-ID: <1744807.WFtog62eDp@kreacher> In-Reply-To: <9709109.MH8tSaV5v9@kreacher> References: <87blkbx1gt.fsf@gmx.net> <9709109.MH8tSaV5v9@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 wrote: > > > > > > On Wed, Dec 2, 2020 at 7:03 PM Sebastian Andrzej Siewior > > > 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; }