Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp794124rwd; Thu, 1 Jun 2023 06:42:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LjH90taXefqsdlr6TItz64VVtBeapMq72DqmNZtDcJYnRvCkCI0sB6PZtFehAepeHEI/I X-Received: by 2002:a05:6a00:16d3:b0:64d:632a:d0ac with SMTP id l19-20020a056a0016d300b0064d632ad0acmr12258331pfc.25.1685626973790; Thu, 01 Jun 2023 06:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685626973; cv=none; d=google.com; s=arc-20160816; b=RBjqoEtpVyHFM8iBsPW/J+QlWnGL3jupwmr3Ks0Cru1OQkgBDmXDiERnVxU83a7k9B vVI4vrB+yje4K4tRx2wO1k68wEcFFDnP+3Ak1Vj2sbQS1mTGmfCJP7fxBxaGdQNWb/Ab eFVIXwxZBq0PISfzFptj4roMSY02NrmvfcNz6ncSe+PiqJ6Yl8Mbx4Np4oexCahQr/r+ dcTIgDYTefQVzlNb15KvN0VsHsuesKCxpvxqxWMkQlEZh5BOu/uJuIQHvAmocih4rCLs YuQw0MQp0QJ0GgIZQL7m0Sv8jTB17jdjFu/hfFqQN9PQVLIlUvmOxXFd3Pg4y+MAj03j qh6w== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fxeirf9lBboGoDji81OfJehuckyrNP5FFMFo2WWvrLg=; b=y2vrlwwTIK3UH3NtKSpQfLZ7Ein2eMIT25hZM2TmHdo8TJQTQJilsp1ZhGAmfjFzXe lMDf/gWklpmhU8IA3PtAPcYiNqsdZljWOZ+GZqc9Une8YR3VULUcIAcwSuuXwegX0Yzd apyNk8I3Rd9z9rsSGklbolwKq/6V+LeVFDA1yaLI3FgNMhfrl3D9Fu1Y3J1pMN+at4y8 zOOs861B9nJCNFBox20YP+9dqK+2o6MqwImrFAUa35bZNaw0fMaIKcnNTiCPOxCVwrN3 0S1qG+cV96u7pZ1hXqx8ZK6BDGUjkFK8yVFcdhYeoMXKzT59apb4aZzdf2/GU8Z0Spzr 9puA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gIj9aps6; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z18-20020aa79592000000b0064d2d8d7c33si5600232pfj.45.2023.06.01.06.42.40; Thu, 01 Jun 2023 06:42:53 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=gIj9aps6; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233499AbjFANWW (ORCPT + 99 others); Thu, 1 Jun 2023 09:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233486AbjFANWN (ORCPT ); Thu, 1 Jun 2023 09:22:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056AB19B for ; Thu, 1 Jun 2023 06:22:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3295664435 for ; Thu, 1 Jun 2023 13:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 433D0C433D2; Thu, 1 Jun 2023 13:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685625718; bh=wU8Vu9bgI8KbbN4ljQAHM+Omu6PSOvAFrS2vgPhZtVw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gIj9aps68UB3wq/gUpFKTAq6Fog98L16LqkWWzpaCfmsmXEmZ2fAjHUNVlVtFR7Gd VQZ7LfKlzo5aSM1DMHU5aCfO+4gPJGZ2xcEBC/8DdEB1WI3B6Lw0xOUHmgyHklqDJs hC6TiIh3usXktKu4OtiWf2jbEvkVZnZQWdKgWlchCJwYweVrNysZpVAqrlzKmzzwls 5iVUh+cPkytdH7mQewvgqxVIhHQSJlMD4hFDGS4z71z24R/Aoyv2qI/I5unewdUb4R hYGR2EF2Lu/1HnXqpBMX8LQxx/DpJBFXISaUYcyJIM6lL/zqGKMxwPRZDw4xR9zXpc ifz+UzUVzg1GA== Date: Thu, 1 Jun 2023 15:21:55 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Anna-Maria Behnsen , Peter Zijlstra , Sebastian Siewior , syzbot+5c54bd3eb218bb595aa9@syzkaller.appspotmail.com, Dmitry Vyukov , Michael Kerrisk Subject: Re: [patch 18/20] posix-timers: Clarify posix_timer_fn() comments Message-ID: References: <20230425181827.219128101@linutronix.de> <20230425183313.777610259@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230425183313.777610259@linutronix.de> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, Apr 25, 2023 at 08:49:24PM +0200, Thomas Gleixner wrote: > Make the issues vs. SIG_IGN understandable and remove the 15 years old > promise that a proper solution is already on the horizon. > > Signed-off-by: Thomas Gleixner > --- > kernel/time/posix-timers.c | 56 +++++++++++++++++++++------------------------ > 1 file changed, 27 insertions(+), 29 deletions(-) > > --- a/kernel/time/posix-timers.c > +++ b/kernel/time/posix-timers.c > @@ -325,11 +325,11 @@ int posix_timer_event(struct k_itimer *t > } > > /* > - * This function gets called when a POSIX.1b interval timer expires. It > - * is used as a callback from the kernel internal timer. The > - * run_timer_list code ALWAYS calls with interrupts on. > - > - * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers. > + * This function gets called when a POSIX.1b interval timer expires from > + * the HRTIMER soft interrupt with interrupts enabled. BTW, what arranges for this to be called in softirq with interrupts enabled? The modes I see used here are HRTIMER_MODE_ABS or HRTIMER_MODE_REL and not their _SOFT counterparts. > + * > + * Handles CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_BOOTTIME and CLOCK_TAI > + * based timers. > */ > static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer) > { > @@ -358,34 +359,31 @@ static enum hrtimer_restart posix_timer_ > * FIXME: What we really want, is to stop this > * timer completely and restart it in case the > * SIG_IGN is removed. This is a non trivial > - * change which involves sighand locking > - * (sigh !), which we don't want to do late in > - * the release cycle. > + * change to the signal handling code. > + * > + * For now let timers with an interval less than a > + * jiffie expire every jiffie to avoid softirq Or rather at least to the next jiffie, right? Because then in the next jiffie it gets re-evaluated in case a real signal handler might have been set in-between. Or it could be: + * For now let timers with an interval less than a + * jiffie expire every jiffie (until a real sig handler + * is found set) to avoid softirq... > + * starvation in case of SIG_IGN and a very small > + * interval, which would put the timer right back > + * on the softirq pending list. Moving now ahead of > + * time tricks hrtimer_forward() to expire the > + * timer later, while it still maintains the > + * overrun accuracy for the price of a slightly > + * inconsistency in the timer_gettime() case. This > + * is at least better than a starved softirq. [...] > */ > -#ifdef CONFIG_HIGH_RES_TIMERS > - { > + if (IS_ENABLED(CONFIG_HIGHRES_TIMERS)) { > ktime_t kj = NSEC_PER_SEC / HZ; Could be TICK_NSECS? Thanks! > > if (timr->it_interval < kj) > now = ktime_add(now, kj); > } > -#endif > - timr->it_overrun += hrtimer_forward(timer, now, > - timr->it_interval); > + > + timr->it_overrun += hrtimer_forward(timer, now, timr->it_interval); > ret = HRTIMER_RESTART; > ++timr->it_requeue_pending; > timr->it_active = 1; >