From patchwork Tue Jun 6 14:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 103901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3455381vqr; Tue, 6 Jun 2023 07:58:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63yl8rY9q/4VhmTkeZEwjOR7ap7ivshdhg+gQF/NC5zQ4Pbcd4CLo2fRyBHEfovBmQ1pQD X-Received: by 2002:a05:6214:5189:b0:62a:9624:89d7 with SMTP id kl9-20020a056214518900b0062a962489d7mr2572549qvb.21.1686063527204; Tue, 06 Jun 2023 07:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686063527; cv=none; d=google.com; s=arc-20160816; b=e+kZGKuHtMEIL7zJfObiTeurpB0aF+iu7jZUgJb6ZtDBKSlVjxVtESgwRVeerqS5yd is8nruOGe7pERW66TxEYT5q2ZcN+prPqeoM7KHmnnvgRrURVyeVSCtBb5LVrY8M9PttH 0R86c792MI7X4rtYZgoigeCo9A1fT+/m3TRxoDF/HlzlN/6agixFm+tFnfwmT4gxwpSM r9+zdhCN6N2gsLIlGx8QibJiUEVOJZeKOz7szWQ8jZ7AOLfjMzuihEg/M7FhHdXEH7ID +DlJR3Ms0w3wfslGzfmcnEh5AxwWvTLeD9TVYPK5wx9Wc/45mANz9rhDBoumFwGlUHTN 21BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=PVNa4KLijTQ7CcOYu3CDLgD0Q8pt6GmBRvk3JFfaO1Y=; b=Al3ftaQxo9SdDDh6f+pxh0goLYtGsJwSi5tBTCI+mpb5q+1PIttMaqv7gZNLnUluON uKZeVVkuqjEiYRi9Lo8zK1OkIpEeeWKgGAbfVWAMqyJ0shid0WYp9Gr5QWSI6TQGRitL 3Dq2pXhYgIXpiJjhu1yzScirSqd1eUQEY+SZ1tcZyCtI7a2kcEjykIctCSVMOSAZH8CA aQaSkCDCZJ2lmvZMDTmHoxszeUd5are5Pd/7igchKjyRtdkCxJAA0dmUylMae8QysEhB JP0dOyME6HgDfLgTAu6jE2T/K3pnc1J/lBNqbhd4P5UI1nX0fSp/r0Szn5FwU3BP6hnF C/BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3tnlpwZR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zuo3CLae; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gc11-20020a056214230b00b00620cb906a49si6450541qvb.281.2023.06.06.07.58.32; Tue, 06 Jun 2023 07:58:47 -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=3tnlpwZR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zuo3CLae; 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 S238296AbjFFOj3 (ORCPT + 99 others); Tue, 6 Jun 2023 10:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238183AbjFFOit (ORCPT ); Tue, 6 Jun 2023 10:38:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E231BE4 for ; Tue, 6 Jun 2023 07:38:01 -0700 (PDT) Message-ID: <20230606142032.433429880@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686062278; 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: references:references; bh=PVNa4KLijTQ7CcOYu3CDLgD0Q8pt6GmBRvk3JFfaO1Y=; b=3tnlpwZR7AOO7Yh1fmxAmC8HLkEI6QD76zGVnsBJknf8UMe5AeHLON600517dH6ZfYHN1t EsBV1RT/DYKL87zBhaT5vrA6XEstqCzGt65cKoBch1fUhqGgkU0qJFAAFHmZG+cuw8mxxM vTIynumi25/W/Ey+lLIyrp8rJAj3Otsm1xnxe/uPFsybfThD3/Jl3yakh/8aC+J1+oQ21b sCxb0iDMYure57654loi6WY4SlZSuiJ//iQ7wp0Xz94G/FiHDrYQq8FwolQVk48G2kPCjd JuVT+hfISI+Am4uRRb4esCZptkkEH5WdA2cnn263pWvRwpz9Pkk51VmspWig5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686062278; 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: references:references; bh=PVNa4KLijTQ7CcOYu3CDLgD0Q8pt6GmBRvk3JFfaO1Y=; b=zuo3CLae5BOp6gIZnvW7WN6SahTzqoMNx2aNczVT7msm1Y6lFSCoT8iMQb3JZiQXA9Wm/F ZFr6Z0bcwUN/2uBg== From: Thomas Gleixner To: LKML Cc: Frederic Weisbecker , Anna-Maria Behnsen , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch 25/45] posix-timers: Drop signal if timer has been deleted or reprogrammed References: <20230606132949.068951363@linutronix.de> MIME-Version: 1.0 Date: Tue, 6 Jun 2023 16:37:58 +0200 (CEST) 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,URIBL_BLOCKED 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?1767965748861251767?= X-GMAIL-MSGID: =?utf-8?q?1767965748861251767?= No point in delivering a signal from the past. POSIX does not specify the behaviour here: - "The effect of disarming or resetting a timer with pending expiration notifications is unspecified." - "The disposition of pending signals for the deleted timer is unspecified." In both cases it is reasonable to expect that pending signals are discarded. Especially in the reprogramming case it does not make sense to account for previous overruns or to deliver a signal for a timer which has been disarmed. Drop the signal as that is conistent and understandable behaviour. Signed-off-by: Thomas Gleixner --- kernel/time/posix-timers.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -250,14 +250,14 @@ static void common_hrtimer_rearm(struct } /* - * This function is called from the signal delivery code if - * info::si_sys_private is not zero, which indicates that the timer has to - * be rearmed. Restart the timer and update info::si_overrun. + * This function is called from the signal delivery code. It decides + * whether the signal should be dropped and rearms interval timers. */ bool posixtimer_deliver_signal(struct kernel_siginfo *info) { struct k_itimer *timr; unsigned long flags; + bool ret = false; /* * Release siglock to ensure proper locking order versus @@ -279,6 +279,7 @@ bool posixtimer_deliver_signal(struct ke info->si_overrun = timer_overrun_to_int(timr, info->si_overrun); } + ret = true; unlock_timer(timr, flags); out: @@ -286,7 +287,7 @@ bool posixtimer_deliver_signal(struct ke /* Don't expose the si_sys_private value to userspace */ info->si_sys_private = 0; - return true; + return ret; } int posix_timer_queue_signal(struct k_itimer *timr)