From patchwork Sat Feb 11 06:45:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 55721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1380213wrn; Fri, 10 Feb 2023 23:36:38 -0800 (PST) X-Google-Smtp-Source: AK7set8tB80ZUWnNcAt9jG7NY37qKuCp6RVa49RiwSGzC0CYJozgPYVw+im7YYH0jd/uHw+QvP5Q X-Received: by 2002:a17:907:20ae:b0:87b:59d9:5a03 with SMTP id pw14-20020a17090720ae00b0087b59d95a03mr18311924ejb.36.1676100998162; Fri, 10 Feb 2023 23:36:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676100998; cv=none; d=google.com; s=arc-20160816; b=cDqyQGD44sWP/6ouvGf22mc8YBqsY+6lCaEHcTZnfjJMYA4YceroNGUPQIl37qCNQB Qh75cjhnCEPp3C8Eb54/vHDqzhT3gUpS/bs2rUoTABCpo7NAEDBeJW6JnsqITXeoOlb6 uu0UH4I+g+VWGYzVPAd8gyW5F/wIyP+yOF5GaxMiK/OFuf/tznLHuGZLvYDf8pBFwMPN 9laeENoFs83t9uqdfv1rLGc0TyloCbLb60pGhBFBSoUTK7FnanU/z/HmNPJjxoOaAqpg I42lsZWzzlXisRuieQlm4CRip22vK4B/qiwgrBEivVKLKIwghCWRLSyTKgUD0xvl00PV LN8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=/B9GAfQBYBoDhp2FsGVxBOlSI/O26/vnD5AYsxIyzR8=; b=jyTfXwmbUM4mlIKXuFyxRUj/lGZjZlXv3huHcxEdb/kF6oRNL5UvkB8ufC0Sx8hFoB fO/7eCgl6qVLsqTKZJLm9pTQncU6ojXQgFilLg54ws+CT9HXQF9pnrWohD8EFQAaoBLU r0/IJ3EJ+88VAM2ROkllxG1Z/stlzIjveaTOPhQvHazfdPc/KCu3IjgKGZUR6s47i9pB 5xJcHA9WnpUzlMHte6KbfoeRyJ9aT4AN2wGIoAJnJnCpMWml4ULc8uY4dRNI8C3gC3T/ YpmBGtbX3pjtV20Fj0zQR72X+gzu1LVNUJt7xT/il/yBfXGq8Cw/Z5ucDqmHM4gKLvUv 5mbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Yv539Zux; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc7-20020a170907124700b00870f0d7edd3si7063824ejb.831.2023.02.10.23.36.14; Fri, 10 Feb 2023 23:36:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Yv539Zux; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbjBKGpf (ORCPT + 99 others); Sat, 11 Feb 2023 01:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjBKGpe (ORCPT ); Sat, 11 Feb 2023 01:45:34 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B65835AF for ; Fri, 10 Feb 2023 22:45:33 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-52ed582a847so30514757b3.1 for ; Fri, 10 Feb 2023 22:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=/B9GAfQBYBoDhp2FsGVxBOlSI/O26/vnD5AYsxIyzR8=; b=Yv539ZuxLzEXoqlnYNJ4YBJiTtbId/KwCDAMas26JG8dvIgIIHPaSZWDtR/CzvuUVP ptyMI+e2fx2SyiZXjqX44ub7akJo68csVGHFXhCJ9OJSRg2dGOtwAOb9egWJH7BL1taq tee4lpO0rn+caE1sS9lo3uI+UEldjkVwUy5naRuVeFA9fQqRx4ytRbM3bPMFOf8OB+Tk ezMJj+jH/3XwS2q7I+JFN6GSE3uL55mgfu5suJRcLYUwOUN3Wk2QWwx9hdSmIFjL46EL jd+Bdc2mWz965ZkWRd/cv60cFAjY3hRX9EARTZw9xzPrrKg4Xo26PiVbaOPlceRez8Ce d/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/B9GAfQBYBoDhp2FsGVxBOlSI/O26/vnD5AYsxIyzR8=; b=K9qXN4qWZ2zthJmCsXKfaHBZ0ppF78KFOXNCTcvoESbA/Puqf5FB3cLloEhJkYOa+d LpY7rjKw7MFAYLEFrcKHIACgsM5Cuahn27JYU0DCFp8Kk45UH31epdGjt4gqgd+qILcg xTPv5+VtGSNSzEgfqTbZuusl1k81DjFK+piX/SmS61C+Z8tmPhtAAhcuEWrmcyERlZ9a b/uys26KPhxv9rkAy8ByNX1Ti3KnsA6MG6Rd6YyzulROSTCGdkhf94RmgmFjTaz+n+kI eVDcw95EmAg1lmwPI1HUlifxRRx7itfJwTP3Yt75G0gUjylAF67CEZEpq7MLiHYzbZXU CQoQ== X-Gm-Message-State: AO0yUKWuGvSLEW4gcj5g4zuUE9OuT3aBcG2WqiG95cgIMOFFaxbUHbMu xPI7wxeY9f2TZQ5d5STBUKFImWt0eYV/MFTDZlYtwsdKRUrzgMVxZX7UlUvbZG8nLmfRpShxzzP EwTUIpqZ0oTllDu0FjLeoZe6BLDR8AjQn7Pr4FJR3PY9x95VpJib1+Cssfpgnd9bDbSHZIwE= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a81:a97:0:b0:52e:c29d:7328 with SMTP id 145-20020a810a97000000b0052ec29d7328mr12ywk.7.1676097931564; Fri, 10 Feb 2023 22:45:31 -0800 (PST) Date: Sat, 11 Feb 2023 06:45:26 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230211064527.3481754-1-jstultz@google.com> Subject: [RFC][PATCH 1/2] time: alarmtimer: Fix erroneous case of using 0 as an "invalid" initialization value From: John Stultz To: LKML Cc: John Stultz , Thomas Gleixner , Stephen Boyd , Arnd Bergmann , Michael , Michael Trimarchi , kernel-team@android.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757519279694644651?= X-GMAIL-MSGID: =?utf-8?q?1757519279694644651?= Michael reported seeing an error where alarmtimers would occasionally not wake the system up. It was found that in alarmtimer_suspend() it was exiting via the: if (min == 0) return 0; check. This logic was from one of the early versions of the original alarmtimer patch, where we initialized min to 0, and then this check would exit early if we found no timers to expire (leaving min still at 0). However, its possible for an alarmtimer to expire as we are checking it, leaving the calculated delta to be zero, and thus setting min to zero. This is the result of my using 0 as an invalid time value which is clearly erroneous. Instead KTIME_MAX should have been used. This patch, split out from a change originally suggested by Thomas Gleixner, changes the logic to instead use KTIME_MAX. Cc: Thomas Gleixner Cc: Stephen Boyd Cc: Arnd Bergmann Cc: Michael Cc: Michael Trimarchi Cc: kernel-team@android.com Reported-by: Michael Reported-by: Michael Trimarchi Fixes: ff3ead96d17f ("timers: Introduce in-kernel alarm-timer interface") Originally-by: Thomas Gleixner Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1909021247250.3955@nanos.tec.linutronix.de/ [jstultz: Forward ported to 6.2-rc, and split out just the KTIME_MAX change] Signed-off-by: John Stultz Tested-by: Michael Trimarchi --- kernel/time/alarmtimer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 5897828b9d7e..f7b2128f64e2 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -251,7 +251,7 @@ static int alarmtimer_suspend(struct device *dev) min = freezer_delta; expires = freezer_expires; type = freezer_alarmtype; - freezer_delta = 0; + freezer_delta = KTIME_MAX; spin_unlock_irqrestore(&freezer_delta_lock, flags); rtc = alarmtimer_get_rtcdev(); @@ -271,13 +271,14 @@ static int alarmtimer_suspend(struct device *dev) if (!next) continue; delta = ktime_sub(next->expires, base->get_ktime()); - if (!min || (delta < min)) { + if (delta < min) { expires = next->expires; min = delta; type = i; } } - if (min == 0) + /* No timers to expire */ + if (min == KTIME_MAX) return 0; if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) { @@ -503,7 +504,7 @@ static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type) delta = ktime_sub(absexp, base->get_ktime()); spin_lock_irqsave(&freezer_delta_lock, flags); - if (!freezer_delta || (delta < freezer_delta)) { + if (delta < freezer_delta) { freezer_delta = delta; freezer_expires = absexp; freezer_alarmtype = type; From patchwork Sat Feb 11 06:45:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 55719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1368270wrn; Fri, 10 Feb 2023 22:56:29 -0800 (PST) X-Google-Smtp-Source: AK7set8nVGA8weaAUNFnbOFppszKzwOaaKhvUThUvNCiJkKjTXEjCPsfAmbtsrggd5erLScLFnCY X-Received: by 2002:a17:907:a45:b0:8af:1a8c:f13f with SMTP id be5-20020a1709070a4500b008af1a8cf13fmr14928003ejc.71.1676098588950; Fri, 10 Feb 2023 22:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676098588; cv=none; d=google.com; s=arc-20160816; b=ocvW1EqLtWHoNF1AvR5aS+ZG+TJBdwf9frYByAKhTPc0bSgpXEXrqelSU5Bzi7+OIn 0TtTZg+YycuALg8ukGhLL+/QQPRDzxjhYpYuyRkHI2poi1587pOHHwiZqY+vS+rm1M2C hD3tiPUPQteMaq++cKw3TFoJp/NB7dzNdYlfCVOTQ5np9vCBgobmt9pQsfZvKDhFb4Ns jkXouEp1KQxIUpX/9NFYkogeqlSifxwJs4MFSWx7HHorn5no+Gy/vVpLjFk9Qwn303Uv UODcm+rnVICYPYIWxBrxXv0zQOQVimN2zfTUvp08kq0MKexaJ3V9SP5SyEeWmhpAq0j4 OhgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=XUY7buPyO2Rb/4t6A6ezRdCJ8u1oMoPZarNvz1ZIp8s=; b=aDLTBu/85FRuNfclz4s53lNUlqII2ajshUIe8X9cry+cwFxRRV8W7DGVSIJxJMAwQt fXzbeNE9sgiGkjvC7HriGKUBvYhsfA3FmW0wEVMleULhgnPdtcbIJd6fy2eLuWMskMc+ dVhLIrvXYyqcH0NbLAg5JOiGdrYPiKhsPO7CwDWPzIWXnxYCjZeshv8LjlIjSrpPTqfT 1UaXvQ9RtOSpqAcYNox+aQLRyS0v/2gvly++ipmSgPFDyAxkBX1egEhx7kIbjEd7JWry k96IYcVckHxrfOdGGaMylmZin9DUZhaZF2X5kGai6q5tV7WqhbCesLYXwDPbwAcHLZpp ceBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PmjHVhyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ad8-20020a170907258800b008af2a87b529si6493502ejc.398.2023.02.10.22.56.02; Fri, 10 Feb 2023 22:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PmjHVhyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjBKGph (ORCPT + 99 others); Sat, 11 Feb 2023 01:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjBKGpf (ORCPT ); Sat, 11 Feb 2023 01:45:35 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD085FCB for ; Fri, 10 Feb 2023 22:45:34 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-50fe0b4495cso71705447b3.14 for ; Fri, 10 Feb 2023 22:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XUY7buPyO2Rb/4t6A6ezRdCJ8u1oMoPZarNvz1ZIp8s=; b=PmjHVhyGfR1NIIAusqytgQan7a4hI9LjnhwDKSfTH1KlwLVkXKGO/eyC3G6OiAQYhc FuaTwHQncXZ6S008ELgQPHlIdw8dLOL4/NaF1yycqXzlC6JwAC/q3VdZLnqF6i7q91UW BWfTUSqTuiIFUZ81wiW1acNezLK9h3emYKB0yuyyRxJxdibhFyzjhhMdkXcxMb3YS2PB 9eonuFLxZIvZBbwNc0bkJXk3cTvAzOCTOccq7aVYusqljhUwVnpsGsTQ3j74HsW2jYkN urgt8hxnbKFmsDvojvpSumhBdVZsi0d3+G5eiABGYDYn36ZynWKMfqCKlDsHoUUgzNWW bfEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XUY7buPyO2Rb/4t6A6ezRdCJ8u1oMoPZarNvz1ZIp8s=; b=mYmZXUQdwpxfL9HHbZC2IUbuPdE/GEAMkLrKjSLB3qhuzyv6xsyFcK+dVYSOFVAVK3 GGDoPD4J6ZQKTQl3OugAMsrb7UKLfkuIwogY/VEe8+qjrN0Qsrvd7a3lVUwUNnncgrcE wh1snGKDAQeIV8zDesxKyQ5wCI+hk74nU2ap0ouJ0touDn8+f72heJwBLOFJ69HpR2zg NNZB6gpRr9627GP/oB7Kbf+GgttB9o8LoNm8b2YXfSQhH7Xvlq59zwIizQXxnCMyYA/0 qKwe6Le85Y+UO5JA1ecHBHhTgiXMWx/PDrzx1tR4BfZdRDIrvWHmhb2F3s+mUUsEdYd9 98ew== X-Gm-Message-State: AO0yUKUcYy6beaA4kmqSFoN3YGtl4zOLMAa/dRMwM2gJG1Q78tTFXmAM rh7yep7qIY32MGELCMhFJOVPfrq0YDr69NKqBzEI/3xG1RGOFgFu23vzNKvYVOpDhKSbq/bR/Zc Flm9hi0h9dA2ypvcKLy3K1JADwFYO3HY532fiyfCmD2OKlnj4A5oy4X9CMj7GO42dbrggH1A= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a0d:fb84:0:b0:527:9733:fdee with SMTP id l126-20020a0dfb84000000b005279733fdeemr2175211ywf.490.1676097933895; Fri, 10 Feb 2023 22:45:33 -0800 (PST) Date: Sat, 11 Feb 2023 06:45:27 +0000 In-Reply-To: <20230211064527.3481754-1-jstultz@google.com> Mime-Version: 1.0 References: <20230211064527.3481754-1-jstultz@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230211064527.3481754-2-jstultz@google.com> Subject: [RFC][PATCH 2/2] time: alarmtimer: Use TASK_FREEZABLE to cleanup freezer handling From: John Stultz To: LKML Cc: John Stultz , Thomas Gleixner , Stephen Boyd , Arnd Bergmann , Michael , Michael Trimarchi , kernel-team@android.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757516754153656572?= X-GMAIL-MSGID: =?utf-8?q?1757516754153656572?= Instead of trying to handle the freezer waking up tasks from schedule() in nanosleep on alarmtimers explicitly, use TASK_FREEZABLE which marks the task freezable when it goes to schedule, which prevents the signal wakeup. This allows for the freezer handling to be removed, simplifying the code. Cc: Thomas Gleixner Cc: Stephen Boyd Cc: Arnd Bergmann Cc: Michael Cc: Michael Trimarchi Cc: kernel-team@android.com Originally-by: Thomas Gleixner Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1909021247250.3955@nanos.tec.linutronix.de/ [jstultz: Forward ported to 6.2-rc and split out from a separate fix.] Signed-off-by: John Stultz Tested-by: Michael Trimarchi --- kernel/time/alarmtimer.c | 53 ++-------------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index f7b2128f64e2..15ecde8fcc1b 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -49,14 +49,6 @@ static struct alarm_base { clockid_t base_clockid; } alarm_bases[ALARM_NUMTYPE]; -#if defined(CONFIG_POSIX_TIMERS) || defined(CONFIG_RTC_CLASS) -/* freezer information to handle clock_nanosleep triggered wakeups */ -static enum alarmtimer_type freezer_alarmtype; -static ktime_t freezer_expires; -static ktime_t freezer_delta; -static DEFINE_SPINLOCK(freezer_delta_lock); -#endif - #ifdef CONFIG_RTC_CLASS /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer; @@ -241,19 +233,12 @@ EXPORT_SYMBOL_GPL(alarm_expires_remaining); */ static int alarmtimer_suspend(struct device *dev) { - ktime_t min, now, expires; + ktime_t now, expires, min = KTIME_MAX; int i, ret, type; struct rtc_device *rtc; unsigned long flags; struct rtc_time tm; - spin_lock_irqsave(&freezer_delta_lock, flags); - min = freezer_delta; - expires = freezer_expires; - type = freezer_alarmtype; - freezer_delta = KTIME_MAX; - spin_unlock_irqrestore(&freezer_delta_lock, flags); - rtc = alarmtimer_get_rtcdev(); /* If we have no rtcdev, just return */ if (!rtc) @@ -480,38 +465,6 @@ u64 alarm_forward_now(struct alarm *alarm, ktime_t interval) EXPORT_SYMBOL_GPL(alarm_forward_now); #ifdef CONFIG_POSIX_TIMERS - -static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type) -{ - struct alarm_base *base; - unsigned long flags; - ktime_t delta; - - switch(type) { - case ALARM_REALTIME: - base = &alarm_bases[ALARM_REALTIME]; - type = ALARM_REALTIME_FREEZER; - break; - case ALARM_BOOTTIME: - base = &alarm_bases[ALARM_BOOTTIME]; - type = ALARM_BOOTTIME_FREEZER; - break; - default: - WARN_ONCE(1, "Invalid alarm type: %d\n", type); - return; - } - - delta = ktime_sub(absexp, base->get_ktime()); - - spin_lock_irqsave(&freezer_delta_lock, flags); - if (delta < freezer_delta) { - freezer_delta = delta; - freezer_expires = absexp; - freezer_alarmtype = type; - } - spin_unlock_irqrestore(&freezer_delta_lock, flags); -} - /** * clock2alarm - helper that converts from clockid to alarmtypes * @clockid: clockid. @@ -750,7 +703,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp, struct restart_block *restart; alarm->data = (void *)current; do { - set_current_state(TASK_INTERRUPTIBLE); + set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE); alarm_start(alarm, absexp); if (likely(alarm->data)) schedule(); @@ -765,8 +718,6 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp, if (!alarm->data) return 0; - if (freezing(current)) - alarmtimer_freezerset(absexp, type); restart = ¤t->restart_block; if (restart->nanosleep.type != TT_NONE) { struct timespec64 rmt;