Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1221232rwd; Thu, 1 Jun 2023 12:10:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5k6YqvwmGFLhDDApBH8QZif09ZkGf1Kr1qwI6gSz0CkdIXOtYCAb8YPmslv1FZkudDiFbl X-Received: by 2002:a17:902:eccb:b0:1ab:275:5abf with SMTP id a11-20020a170902eccb00b001ab02755abfmr258198plh.55.1685646615754; Thu, 01 Jun 2023 12:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685646615; cv=none; d=google.com; s=arc-20160816; b=Z6G7m8zNTKImTat0VmnMH1FT/xIdorWGfhMMyrxxoI1d0os5uRZoUMj7DXomgAJZWR 1NLUQrb1deH9DPLMBBr0R+4e7K7MKpQ6KuiyfgnGjEQ1Jbeh5YBmlAhZbANu+rVkl8Lk yZhblMQQQhWZSQNnf6GgiJcHU8sGifJUUDFeHFu0IcTaiA055rloKBGqHxrg8ZYkqjme L0dOtiHORmKF1I+ixje8FTUbvmf/PpB6bWds7GSbR7i2nn1vapfp6DLKSxDGkWnXp51a mpuSckAHhYfX8jA5asPubbWf9isQgKufzroztk/OXXWMbAXWHC38bVQvAvnAP8vZbJDa OIPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=qyFON+nxk2A5/kg6X5Qv6OwhBLXdPK0urAgWXEZqX2U=; b=AzSAxEMgcaT0sC57U7D7OLJMqiapm69knx3aP4tTx27bMelyaKHEaxhAsiP63Esv6P mddTHg2UDORa1ZdlfNOyjgZTtSZ2GRnITW1dAqPrBtJ0HEoqU3sS01D6wNlRRNS6i1I6 FSs6Swj+67bVXpPyrf9gPkJMckeHqCuec9hZWf9W2GYacBAl5N1GhXdDcpmgKMajhecw mM8Tj7aLk+A6toxWemrg7wPRmDWX12GrWWSsVqj0xfdyJLvnDXee7Qd+hy13XCAJXtCI jbJDwyqAt4cNh4sFTD+wMKSrc0WRvY6LysXaxDkgl8IddiCGMX5Swd+4XC4Kg+oqJV60 msZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UzAXAQ8H; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a170903024700b001ae5eb838edsi3222651plh.152.2023.06.01.12.10.02; Thu, 01 Jun 2023 12:10:15 -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=@linutronix.de header.s=2020 header.b=UzAXAQ8H; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjFASnY (ORCPT + 99 others); Thu, 1 Jun 2023 14:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjFASnW (ORCPT ); Thu, 1 Jun 2023 14:43:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBC2E4 for ; Thu, 1 Jun 2023 11:43:21 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685644999; 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=qyFON+nxk2A5/kg6X5Qv6OwhBLXdPK0urAgWXEZqX2U=; b=UzAXAQ8Hc0yFYDPFDOPnkqcGhGu6mC2eGLwJKC9q1v50jeClbv7tX58uBNLzZb6FgvaiaE x5q1pKJhNnSgdgPFymElQg9cZIn0YPRK9LbvInITF4n2CSsGXZm2qhnFdsNIKNRI6dpTvD CS98MG9/QZ6nhkHLqijouwPFHqqU/dSZTqy8pBEwR5ZsQbBlRqArQGA3qd49x3kyRaR5J3 9uXr5WyBLF6Ty0CzQ+y6afhnlbxwefyWWx3QtTGuKKjsaFJiD5JcyMMlEFfyRN3mFMqUV6 er/Bmaecs8W8zdxMAQzp/Cum9VTfuUKoVynO4MrKbEUV7CSMw24q19Ur0Rz7Cg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685644999; 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=qyFON+nxk2A5/kg6X5Qv6OwhBLXdPK0urAgWXEZqX2U=; b=p6J0aiOebK7dCr7Fn1VLhf/1ge5rRbdGcssAhMF02q7oTUB0iD+JajpZc9/3ZFrs6pAVb9 VXfvY2qixT6bKUDw== To: Frederic Weisbecker 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 In-Reply-To: References: <20230425181827.219128101@linutronix.de> <20230425183313.777610259@linutronix.de> Date: Thu, 01 Jun 2023 20:43:19 +0200 Message-ID: <87edmvdnw8.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Thu, Jun 01 2023 at 15:21, Frederic Weisbecker wrote: > 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. Duh. My RT biased brain tricked me. >> + * >> + * 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... Let me rephrase that. >> + * 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? Yep. Fixed it up.