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 2A9B0C636D7 for ; Thu, 9 Feb 2023 15:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231447AbjBIPk4 (ORCPT ); Thu, 9 Feb 2023 10:40:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbjBIPky (ORCPT ); Thu, 9 Feb 2023 10:40:54 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 275245B74F; Thu, 9 Feb 2023 07:40:52 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1675957250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OVFhlR2M6tNz8ldOCJ24pLZnOnnyeNs58Qt9EziV6CM=; b=JW7EI1gy7ShLJfGdxUahI0jE6ujpSPzquuMDqkeDl1wd0R1Rdca3VNsHVCn0f4e8fq3JKq zZY+/EBDJH0zjuegVMTrKh2nFkMP0Z2TS2QmRl2Ma76vQ8B7BH8RgJbJ9QnWUz44XaXy9O RKfxQVSJj9SN1nilyERF8ZHFX5CIBivr75l8U60ExWteFiVwwpiouSMfy6f33y/OZGYuXe F3KBCHkONxaqNGTPnIegaW57YEG3eHeHvlyG+NV/NkPu/01ap8Y79zO4N57JbNttCVcr2I pur3/b95DWulKg/YKW1hCvYfIPDTf6oKMORsv1k5+ZAmuJ1k+HzdorIf5ECMQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1675957250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OVFhlR2M6tNz8ldOCJ24pLZnOnnyeNs58Qt9EziV6CM=; b=Uvene4wD+DyhDsbTMc4drDy2TYTCbUgnzBHvIRIRsrmwLaDxc7QkMPcZtjQsRXYkCuMsV+ qFSpFcfPM/4sOaAA== To: Michael Nazzareno Trimarchi Cc: Michael , Alexandre Belloni , linux-rtc@vger.kernel.org, Stephen Boyd , linux-kernel@vger.kernel.org, John Stultz Subject: Re: Problem when function alarmtimer_suspend returns 0 if time delta is zero In-Reply-To: References: <08fbdf25-faa1-aa13-4f13-d30acbf27dda@mipisi.de> <20190902074917.GA21922@piout.net> <4fc3a016-ec2f-a15e-5fd1-6794a001e2d9@mipisi.de> <87edr02fsc.ffs@tglx> Date: Thu, 09 Feb 2023 16:40:49 +0100 Message-ID: <87zg9m26f2.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael! On Thu, Feb 09 2023 at 12:19, Michael Nazzareno Trimarchi wrote: > On Wed, Feb 8, 2023 at 7:06 PM Thomas Gleixner wrote: >> I wrote that patch against the back then mainline code. No idea if it's >> still applying, but the underlying issue is still the same AFAICT. >> >> It needs some polishing and a proper changelog. >> > Ok, I will try to update it on some mainline kernel in my environment > and test it back. I need > a little information if it's possible. Consider that I have no > experience in this area. I understand how > code was designed in general but the part around the freezer and all > those code you remove, what was the logic behind in the removed code? What I can oracle out of that well commented gem is: A userspace task invokes clock_nanosleep(CLOCK_*_ALARM, ...), which arms an alarm timer. The expiry of an alarmtimer causes the system to come out of suspend. As the task invokes schedule() it can also be brought back from schedule() via a signal. If that happens then the task cancels the alarmtimer and returns to handle the signal. While doing that it can be frozen, which means the alarm and therefore the wake from suspend is lost. To prevent that the code tries to save the earliest expiring alarm if the task is marked freezing() and the suspend code takes that into account. John, did I summarize that correctly? The change I made remove that magic and marks the task freezable when it goes to schedule, which prevents the signal wakeup. That ensures that the alarm stays armed during freeze/suspend. That obviously needs some testing and scrunity by the folks which use this mechanism. IIRC that's used by android, but I might be wrong. Thanks, tglx