Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp253931pxm; Wed, 2 Mar 2022 14:40:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjQ3g36FUY6m/kv9yZjB6XEEmKAZD1H+K/1Lhjq9nAq2FkFpfWOLRmC6fcSgznX8DWTedL X-Received: by 2002:a17:903:2308:b0:151:8ca0:cd8d with SMTP id d8-20020a170903230800b001518ca0cd8dmr8307064plh.119.1646260838582; Wed, 02 Mar 2022 14:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646260838; cv=none; d=google.com; s=arc-20160816; b=rpie6RkbMmrkL1LKpH+m3fCyATLEijUSqk4KY4+GZwG3dRjZsAze3149HF7KlGtc22 Jx5aDQhdHa6vbcYMxbUxiFbEOVsc1KD+UNXqPYSLhgYsR18IKc/RClDSxAO4M2upZd3u Xz22aMMn0TntUAYP8Xx3rBGpXLanst8aePRqKfcLZP166+n/Jc34tJ7PS+Hkst9gCtsz 70bh7xleYnDCuPHDDutXl+tw1ogpt8TktyfGvmH9XsNo31nFGLeTJmlqA+L9Jj4jEbFa kWUV5n3c61ZkBPB4Kp6BwyNT4G8ApmOfCy3J/QEU99MBPAbtOrlxXeCUdOHIN3aHisLs dsrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=g2ZNVVCbLbWFvHoFdGGw62aXjqOkohSTObIxoEgWGUA=; b=i815yv8QJfwJ2q3ESnS0QHqCKg8zM/H34Fei+jlyu8wZhmlQwR+j1fTAfvLBXYEZp/ 43Oi9FPo3Saan5QW3Gpo2i86zxFw4Gjri/S0IhHynWMx5kOeb3+MpaZCBCS4LroRsfUf QDtqNObP++Xa0sUpUsIQ2dwIMhAp9MvpBpaFwuu5d+Odv+qhnv79fUYI0YCf0a9KnC0D DP2N05phf+FWHkO2eZxNor8Kkfb+Q6RnNo2kC/PrXJRhcaUfoDLnzgmqQlGeNwOt3dNV Vesh8HWHS6jI4FJwZm/Miisn6broQ5iKTYu2uBhrGAbzWvga4QYdqdeTnnqTpv7er+F6 kZ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gix1vsY2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nu12-20020a17090b1b0c00b001bf05b69eb4si316858pjb.82.2022.03.02.14.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gix1vsY2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 83792100761; Wed, 2 Mar 2022 14:36:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234704AbiCAMU3 (ORCPT + 99 others); Tue, 1 Mar 2022 07:20:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234707AbiCAMU1 (ORCPT ); Tue, 1 Mar 2022 07:20:27 -0500 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A64CB8B6DC for ; Tue, 1 Mar 2022 04:19:46 -0800 (PST) Received: by mail-yb1-xb2e.google.com with SMTP id u3so26831484ybh.5 for ; Tue, 01 Mar 2022 04:19:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=g2ZNVVCbLbWFvHoFdGGw62aXjqOkohSTObIxoEgWGUA=; b=gix1vsY2RfCg5rYq4KwA43bmZ3RwluQY2zRNMsUm3HFjGzu6kXGzw8E5AnFbdH1W4W JmuUAniBKPQLTsDZhs0ShrkyYXN4tP1Xd07Uf/DuHqPkVJ1Sgu73p+ie4VmDyCBXbOAZ DxI9hW087f7paMRXscpnr4TKGnKrd06W8nEccLJojJP+czW5WoNHQGKebjZmuoKxXLnw IHW015G6V7IPJ6hEDgUlXywPATd//YdwfU4l8YGW8Zu8qegZY+7D7NccaNrl34Nayy3B wrqmLzOx3+zufEdsX8ch8BRM046OZStZwhCPInE7PbaXxDryokYJKi7tjUv4yOcPfcCg vxNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=g2ZNVVCbLbWFvHoFdGGw62aXjqOkohSTObIxoEgWGUA=; b=Av/yiyphilZDc1JIgOUC1+bX4WNhcWNLpBQtzYhbtOOIWzjn61GkrXCNTuHN6ICd0g IYKb8VrlRnJiyrKV8ohnl+UJmUwcKvxzTj32ENGo2lr/7RVcHs7X1l/OzZ+T3EKep8+H DYxRVC+lgjEQaOLe1TOPgEMbSFEguEVjOrd+xB/eDIEYDSIIlBhuUC3dmf9aV3Dba2rj zqIrFAT6RCLacMb15MPJIMUdKT1V7jnf7cLn1gNqv6cPeUOAEp0pfkSI3gqWYXq/IvGw LEeM7MOTbByjlMP/yv0bvSrdY0qEEmxKh+felUAVpL+fX0KqpdhsdYg+VZzWM15X/uhg GMMQ== X-Gm-Message-State: AOAM53134O/Q/RCfqi9XrnBcULpcZJU0pa6rdRvwWyvfCBzkQDicx3Dg yywLMS8GNCyGcHyYVFVm7E9eacrNISXvOAhJHIe3/ItldTZlokOX X-Received: by 2002:a25:c592:0:b0:628:9263:38ba with SMTP id v140-20020a25c592000000b00628926338bamr215069ybe.291.1646137185832; Tue, 01 Mar 2022 04:19:45 -0800 (PST) MIME-Version: 1.0 From: Linus Walleij Date: Tue, 1 Mar 2022 13:19:34 +0100 Message-ID: Subject: Question on expiring HRtimer in-kernel To: linux-power , Thomas Gleixner , Anna-Maria Gleixner Cc: Sebastian Reichel , Code Kipper , linux-kernel , Lee Jones Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 I have a problem with a premature expiring HRtimer. The HRtimer hrtimer_set_expires_range() is used in two places in the upstream kernel: kernel/futex/core.c drivers/power/supply/ab8500_chargalg.c Now I am testing the code in the latter, and it has seen some bitrot since merged in 2012. Maybe it was correct at one point. The timer is started like this: hrtimer_init(&di->safety_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); (...) hrtimer_set_expires_range(&di->safety_timer, ktime_set(timer_expiration * ONE_HOUR_IN_SECONDS, 0), ktime_set(FIVE_MINUTES_IN_SECONDS, 0)); hrtimer_start_expires(&di->safety_timer, HRTIMER_MODE_REL); What the author wanted to achieve is a very definitive callback in one hour relative to now +/- 5 min, and that is one hour later in the physical world, as this deals with battery charging. However sometimes this fires almost immediately rather than in an hour. My first thought is to pass HRTIMER_MODE_REL also to init as hrtimer_set_expires_range() could make things happen immediately if we have ABS set, but this is all just intuitive. Any hints? Better ways to create a definitive event in one hour? Yours, Linus Walleij