Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3207213rdb; Sat, 9 Dec 2023 17:00:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3GTNBYZz3LUtNhG7O3mB2AJuRUxJD0rJdDdalFH38XBKPx15QErQ1eAYT/NvJ2lFGsYgV X-Received: by 2002:a05:6808:3206:b0:3b9:decf:7af2 with SMTP id cb6-20020a056808320600b003b9decf7af2mr2530895oib.106.1702170048076; Sat, 09 Dec 2023 17:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702170048; cv=none; d=google.com; s=arc-20160816; b=npoQoqU8SS9hqdO/C9qVk3qw4s9eyeqhBrIronCXqktlOrx3ZoCzqmhHAwQ/uVotyI SRU1jbywe0wP6yY0TI/kbS8sWuXQ6prsYPoYI4kmgZlq5GFXd4Tnn7nMT6DssKPaSk28 dU3otdx2+o0qn9vZRJcbrDOQ+H4rBYsxoKO+1Uq9SyBoGz9znpsm9CQ71cwlCtDen/Xk M0d1HHvVidVQvqETJrmOEFdDVV/8Ffy/RxwmqtncEmnOkErKbsU2saVrZy5L2C/KYdMj olH3F6SSKX+pFG31k71xn2bStuf5UB6zL9q9vG0PewJlLsFDM6bW5PqTeDYmj2O6dld8 BF6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cp6+b3H2pIzNS2uDseLDt1R29h3C9hmAmIxcol1dVpA=; fh=vy/G9oOUOab3wFSI2sJN0SfXkaZOJWEA0o3c/dIqg1k=; b=e9GKYwNKOyt6rwU8xYCu/Yc619PbjXy6itRtQpJAY/Mk09CTw+3EipvAXqDlui46QN YvAnfR5/RBF8rKEdLvpuctJ6dQ7QdZXzsv7YNEQ4RQVvpu8Vb09jiNZNvy6LRf2B4YMS 5g2wFNUixaxwbNwzSTBGUgRINfAAqKhW3GwZwa2tvd4Axkn/V2XjhwsqwfDwMIeIBnI4 23svPuycYz5HXWCPCVUc1wtcfrUSQdj7Dp3VbGmUgzF2tQDp5cxjkLOt8vJD9TnUOX3p +KlA1wdD6Ot+Gg5DmGp/LrawAOPPUSZ8t1QNje3x9l54S1dzNb0IHlxquUld5MKnzSTv zsfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aO75rSnL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o12-20020a17090ac08c00b0028688bb3d17si3833818pjs.159.2023.12.09.17.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 17:00:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aO75rSnL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 051298087B56; Sat, 9 Dec 2023 17:00:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbjLJAfH (ORCPT + 99 others); Sat, 9 Dec 2023 19:35:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjLJAfG (ORCPT ); Sat, 9 Dec 2023 19:35:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C9BBE7 for ; Sat, 9 Dec 2023 16:35:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1704C433C7; Sun, 10 Dec 2023 00:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702168512; bh=u+cXPj/slh1aFMEJSuOOp1f8U3gz4OU5Qb61R98fQFY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aO75rSnL2pN+RxPsPFQQcEUYG/FfbjHIWrG72uV21BCtrU5nfycNAOkx7M+DDVUzU e4aNBYcs4b/0/8qplP2newjAx+vT6T8nv2BuBy8zWH+korOcWD6WS0fwdXRxF4H+Xw ahkv/gQqc1nymrWWu6bHl2KOf2QBTbBcGNprM5lnzmxSyxa/R41dDtmVSuvLkrG04B mm6WtQWXBRWAV7lcKtIdXUqOC3j4xrSwqMX1y7ds40OrYZbbNM84OnWIVj/wtD6AY8 iTXHiNVqWiw8EyX9EgUy6D1YVmSofhHULtMZafQiNFwM4abwCtnwkCORRNd6A/X0qo v3ZvwYmjpkW3w== Date: Sun, 10 Dec 2023 01:35:07 +0100 From: Frederic Weisbecker To: Anna-Maria Behnsen Cc: Sebastian Siewior , linux-kernel@vger.kernel.org, Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Rik van Riel , Steven Rostedt , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak Subject: Re: [PATCH v9 12/32] timers: Fix nextevt calculation when no timers are pending Message-ID: References: <20231201092654.34614-1-anna-maria@linutronix.de> <20231201092654.34614-13-anna-maria@linutronix.de> <20231204160350.OTCnqCJf@linutronix.de> <87zfyodfxc.fsf@somnus> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87zfyodfxc.fsf@somnus> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 09 Dec 2023 17:00:13 -0800 (PST) Le Tue, Dec 05, 2023 at 12:53:03PM +0100, Anna-Maria Behnsen a ?crit : > Sebastian Siewior writes: > >> Use only base->next_expiry value as nextevt when timers are > >> pending. Otherwise nextevt will be jiffies + NEXT_TIMER_MAX_DELTA. As all > >> information is in place, update base->next_expiry value of the empty timer > >> base as well. > > > > or consider timers_pending in run_local_timers()? An additional read vs > > write? > > This would also be a possibility to add the check in run_local_timers() > with timers_pending. We could but do we really care about avoiding a potential softirq every 12 days (on 1000 Hz...) > And we also have to make the is_idle marking in > get_next_timer_interrupt() dependant on base::timers_pending bit. Yes that, on the other hand, looks mandatory! Because if the CPU sleeps for 12 days and then gets an interrupt and then go back to sleep, base->is_idle will be set as false and remote enqueues won't be notified. > But this also means, we cannot rely on next_expiry when no timer is pending. But note that this patch only fixes that partially anyway. Suppose the tick is stopped entirely and the CPU sleeps for 13 days without any interruption. Then it's woken up with TIF_RESCHED without any timer queued, get_next_timer_interrupt() won't be called upon tick restart to fix ->next_expiry. > > Frederic, what do you think? So it looks like is_idle must be fixed. As for the timer softirq, ->next_expiry is already unreliable because when a timer is removed, ->next_expiry is not updated (even though that removed timer might have been the earliest). So ->next_expiry can already carry a "too early" value. The only constraint is that ->next_expiry can't be later than the first timer. So I'd rather put a comment somewhere about the fact that wrapping is expected to behave ok. But it's your call. Thanks.