Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp568121lqb; Wed, 17 Apr 2024 05:09:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTOhYPi9Tfwd4uyeFu6hc3u5Mopx7DOqqosgfU0/YXetnnKFpSPzSMlU1FfgNoJQsWKVKO45VNiSMBJttJVQG9ZLt2ybmYNcg0o/n+zA== X-Google-Smtp-Source: AGHT+IGbwJJiXY/sjHYN3GMhqk/pL7V0dhq0KxZacRpcEVK9W5pgGqIC12xC/sm/Ts+zxmjFtLi1 X-Received: by 2002:a05:6a21:8cc1:b0:1a9:9c0a:18a1 with SMTP id ta1-20020a056a218cc100b001a99c0a18a1mr7162005pzb.26.1713355779163; Wed, 17 Apr 2024 05:09:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713355779; cv=pass; d=google.com; s=arc-20160816; b=xFJDt/0a6YUAswwcs7FJOKVOdlN3ThOesyCZqX9PQjJc7anKtwogwrTrP21Igd3vwQ kxjWYb8OjgAScKortq5BStudcBxWF/XDL2he/8Drlguj5B0n5U0WduuJDTB9gRXI3sl1 78xtQfx0kTay8SI6OIdEvBBdiGcQjXSVw+VnK3IOpBXqicTJfrgCKrL7Jb/ZvgjJUyia nFxEvMi+/Sdu/qgwrKcUBu6/HceXyDJZISgQl78dk3OCfDDzOLdJhC6xCOnTh3/L4urt k9QDchng+K+sBLuVKk12R9n8kiXnAG7LafvWG9YYozGiGwthbtgOQ1V2rzqLfVv5lJsG 23cA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=r3NaHExdm3WyaQpGvSme9+DJMOEEo7U68Oxk8WVMP6c=; fh=MxOqrKe8Fax3kxE77rA0inxVaQwZCyEyqDk4Qwcbk14=; b=aBLlGzvEbT1PneO7n+F9Ist3dxiUhZZFRzL5r0FeRZuaGVnt1cG5ZrA5Bcx2ldAfzM bZv7M5ycNu90wvFZP3W2/H+9gEl685o8OypnjCnhfY0PYAL9StWKC6aSRf3NSp1oZqGB ye5Ig+x5bmzInr5E+yzVZSRgEwDoO7f1J9xQbJdogzj+AvQtGvwKWXNHpBhSjz95XBX0 5BALYrGkU686r4JoQmjf9zllbv5clSthyA53U1NBk/ei+n2Qe8gyM+U5QaAqrXMBwNbX yFWy4qtLxy/jT0EXA+sJoUlRcj2BhGbgVwBy+43ex3ECLjL1Ciu2/dCsZDDbmtXhsXxY ZawA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kzaT5iWw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-148455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id go19-20020a056a003b1300b006ecd3b2776asi11484406pfb.367.2024.04.17.05.09.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 05:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kzaT5iWw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-148455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9C2DD2831C6 for ; Wed, 17 Apr 2024 12:09:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D4F513CFBC; Wed, 17 Apr 2024 12:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kzaT5iWw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="27HQC/Wl" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55D79AD48 for ; Wed, 17 Apr 2024 12:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713355752; cv=none; b=UVN3AECGR6B3oiOYCNYAHE/h309LOsnRTb7FtUpXuCRKSNhvY7ZhIBa7MNT8NuGrSXcVg9Fti+QzsaUUvPXvvxYVs1jLIlbbZEeOc82pOPTW8eU+wmXdUbsjkWEXEnR9G3mHmGCCLJ2g4szdI96nul1IHVOAbWnUp1bNY6Jg9ws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713355752; c=relaxed/simple; bh=5Hx3JPtxG6DH3oUCBMk+s42v/1GkEL+FBqZS/S6m2YU=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:MIME-Version: Content-Type; b=JqBroKzrQNrn7LHqsGrLHGG8glapnIK1Jdcyh5PPIQ5I/+uX46cMHQ4PjDCgVI9FU1pZ/Z8Zz7OnuxMvqb3vR3cPeBgd+O8i7FLd7x3XzRsXh6bMCmoURTh1yyUKJx8HTDqR0bh0Vs1mpVqLxa4rjdyN1oJmWXVzqJIpqtaIl+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kzaT5iWw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=27HQC/Wl; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713355746; 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; bh=r3NaHExdm3WyaQpGvSme9+DJMOEEo7U68Oxk8WVMP6c=; b=kzaT5iWwdY7sDVbmWnZy4HewbLuodwL8BhxT8xiaOlh4srpFtkSIMCqbKwzEYmADioe9hb prz8Jg+pFhd630ysRgu2ZHm0qH4t3mWXP9pgGJAxMIyRb/HgT+eu+HyT9lEgix2+rJS5lE 3otJ7xpX2HBxJVYXTOpzPGob+S9MUpZmmqvQ6BkeIPRwFvlf+F1efGf9pi3hbEOUtlDMMt VsfN+uLUij8+Bn0307InM8sS3oPUMU93uaUd9qJ29LWBLilwEM+rtIyuqlxNRNslktp/D+ i9ztcTB/lb3Ho+iNdVrohVrk6ydhQHb3q+/RL9hnxB7CODO3mP2Bdrj+dCv5dA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713355746; 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; bh=r3NaHExdm3WyaQpGvSme9+DJMOEEo7U68Oxk8WVMP6c=; b=27HQC/WliuAvN5p6BSTI/WOjOoyh01yAonxOFihw2ySLbtcsckqGFCi0WyxbCwSIdBaChQ hBkNt+2KRahVmJBA== To: Thomas Gleixner , LKML Cc: Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: Re: [patch V2 25/50] signal: Confine POSIX_TIMERS properly In-Reply-To: <20240410165552.509700441@linutronix.de> Date: Wed, 17 Apr 2024 14:09:05 +0200 Message-ID: <875xwg5gym.fsf@somnus> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Thomas Gleixner writes: > Move the itimer rearming out of the signal code and consolidate all posix > timer related functions in the signal code under one ifdef. It would be easier to read, when it is splitted. But I made it :) With the typo fix below feel free to add: Reviewed-by: Anna-Maria Behnsen > Signed-off-by: Thomas Gleixner > --- > include/linux/posix-timers.h | 5 + > kernel/signal.c | 125 +++++++++++++++---------------------------- > kernel/time/itimer.c | 22 +++++++ > kernel/time/posix-timers.c | 15 ++++- > 4 files changed, 82 insertions(+), 85 deletions(-) > > --- a/include/linux/posix-timers.h > +++ b/include/linux/posix-timers.h [...] > @@ -151,7 +151,27 @@ COMPAT_SYSCALL_DEFINE2(getitimer, int, w > #endif > > /* > - * The timer is automagically restarted, when interval != 0 > + * Invoked from dequeue_signal() when SIG_ALRM is delivered. s/SIG_ALRM/SIGALRM > + * > + * Restart the ITIMER_REAL timer if it is armed as periodic timer. Doing > + * this in the signal delivery path instead of self rearming prevents a DoS > + * with small increments in the high reolution timer case and reduces timer > + * noise in general. > + */ > +void posixtimer_rearm_itimer(struct task_struct *tsk) > +{ > + struct hrtimer *tmr = &tsk->signal->real_timer; > + > + if (!hrtimer_is_queued(tmr) && tsk->signal->it_real_incr != 0) { > + hrtimer_forward(tmr, tmr->base->get_time(), > + tsk->signal->it_real_incr); > + hrtimer_restart(tmr); > + } > +} > + > +/* > + * Interval timers are restarted in the signal delivery path. See > + * posixtimer_rearm_itimer(). > */ > enum hrtimer_restart it_real_fn(struct hrtimer *timer) > {