Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp483653lqp; Mon, 10 Jun 2024 09:45:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWojWqWRzC3iMgdlzd33KWOsMbtwZ7TjR2a9Y+B6nThgePohzate/SzWyd+4xWSdHbCLa/dhHSa73b1TukGb4cLuxCBb2L/4Mlh4cuPdA== X-Google-Smtp-Source: AGHT+IG+u25ZjMr5d7BLhjbvtfJrVXe9O1zAIhIF01VbFSKGyEq939tFb9PsM2FD4DVXQrNfeBj/ X-Received: by 2002:a05:6a00:9a1:b0:704:151d:dcce with SMTP id d2e1a72fcca58-705a8489ce1mr238568b3a.5.1718037909263; Mon, 10 Jun 2024 09:45:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037909; cv=pass; d=google.com; s=arc-20160816; b=ICD6zdxNkANRY8zrAMrKZvDG1t66J//J+BAJADXLsH77tNkLGxs/aNUU9gyYhFOq4Z oYi23OSv9CueFo++cG247rRruMpLgQH+nPibwm9QXXTPVwlkATLuFPadn4znbq1S6/XY imdYtWnjVSvwia5Hdn/HiEikmpn+/s8PYCHnlcxJpx3hjQYTWkxxfAJs+mJzu1NAQ/4E AN2zHlhvV2+9FKV+QnXanWPvmB2lcNbSh6+4LD/9BIW7t57teGWj2v1rJ052cGCKELwV 5cllid7HfvcNU1HR6jGU6enT1YWb4nkzclA//dBNvQdFn8tjakDSaOCDVPnWBXVa7t+S pcJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=osYubTMAcZxZdMMm1RQggfIXZUJTx+ldm1e90x9mqTY=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=uRlVaLcxH8c997+Hfa4K7ZyMi/N4h0OLKVZqCn2HXYUGX3sCW/HPG4qhPHnFBouygz +CS/Q9YKHZjRz/yKx9INKbCyp02+OYbbNdN/J6tMYRMTEWLk90Yit1k33JlRbZwjQFNX br6QSduOr9ehA76fOskgURO2SOFh1atYgMenqZNFs4RzAIHK2NMnVVnY78TTDdL0YFPf yQv8+JieRQL+AwWPqR/ts9bvvTwHZXe8HFJ6/vF7DznzELUmFTj6+It9YXjXv/L+g63t 6drLnMveWJPn420PJOchEkSCNgBrVGH8D0OprxKAFfsWw6X/u13iHOm5PyHiknHW0lXZ pjlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=djfpZA5I; 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-208578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208578-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-705a15697c8si938157b3a.47.2024.06.10.09.45.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=djfpZA5I; 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-208578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208578-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 EC628282903 for ; Mon, 10 Jun 2024 16:45:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9F5415279B; Mon, 10 Jun 2024 16:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="djfpZA5I"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="a/utNjal" 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 5C9C01514DE for ; Mon, 10 Jun 2024 16:42:24 +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=1718037745; cv=none; b=NAr6pELFGbKR0Ix8zW+Zv6mqEUr+a9E9N7E5wE7oGS83QhFExINRspEavPeGBoxDRBEG6HglxMD81yN7m1G4ZSEHPghA49ZMzj9xkBqxqLFabmamuPF6FrO47TWFJzbSgQ7jgWBmnHOf3luIN5z4w3fsS5XOSVGW3Z3/e6jRmOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037745; c=relaxed/simple; bh=XOVBbigKGjPLdX5P0pMrym6mQdm4eaTiAmzCqhAsQJU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Jptfby2o014a9R+WzxsbeqjuldproDvAu1T8d2+V9o5JOnPwVNOVJ5i3ELAFBvEgoc9QYMY7zJSXTbF6ELD/40nFhQM7vtPwvYM1dPsTGIy4Qo4ByDMPoysm4lB10wavPhcg/k+D0qzqiikqf9S47ju7suvezbq7Yukr+UKQPoo= 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=djfpZA5I; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=a/utNjal; 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 Message-ID: <20240610164026.299017301@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037741; 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=osYubTMAcZxZdMMm1RQggfIXZUJTx+ldm1e90x9mqTY=; b=djfpZA5IJmtk9s8xdJZkrpJCPyVwEYSrStVhGW0mFaYe20F77zpEXL7b4PB/ZRA7Y2GbTY QAjg6A0u4b9cu/yZ/BLEDJ7pFOCjtQvfCuuS9BOLIWsb+GYDlcQ052xgUion19GPaHHSJd G3IWcs1csxuXoWgwZESaEBbMykmevEve1iLfRnd5CW0zySwYcthlYIqHX+8+SsErhWsWOf DvVP5gzmizPRJNU4DGNBzTB23mjeHVDMCSD84T/amaghgBdbAg7yc4g9iARh02NaXIPuTB 77KbkFHXjn1dzc67utjfCEOvZOppEmbG92gvD3pSxwbP292xlk6I6FLLuxxDZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037741; 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=osYubTMAcZxZdMMm1RQggfIXZUJTx+ldm1e90x9mqTY=; b=a/utNjalf6l6G9EmsX6O3mdjPa0GNxFRTNGszxIGmvAnP4S9wlOkuHb7Kwru3/d6LwuefG oxNwDEwYKOnK4dDg== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 13/51] posix-cpu-timers: Do not arm SIGEV_NONE timers References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Jun 2024 18:42:21 +0200 (CEST) There is no point in arming SIGEV_NONE timers as they never deliver a signal. timer_gettime() is handling the expiry time correctly and that's all SIGEV_NONE timers care about. Prevent arming them and remove the expiry handler code which just disarms them. Signed-off-by: Thomas Gleixner --- V2: Split out into new patch to make review simpler - Frederic --- kernel/time/posix-cpu-timers.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -584,12 +584,7 @@ static void cpu_timer_fire(struct k_itim { struct cpu_timer *ctmr = &timer->it.cpu; - if ((timer->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { - /* - * User don't want any signal. - */ - cpu_timer_setexpires(ctmr, 0); - } else if (unlikely(timer->sigq == NULL)) { + if (unlikely(timer->sigq == NULL)) { /* * This a special case for clock_nanosleep, * not a normal timer from sys_timer_create. @@ -625,6 +620,7 @@ static void __posix_cpu_timer_get(struct static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, struct itimerspec64 *new, struct itimerspec64 *old) { + bool sigev_none = timer->it_sigev_notify == SIGEV_NONE; clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); u64 old_expires, new_expires, old_incr, val; struct cpu_timer *ctmr = &timer->it.cpu; @@ -688,7 +684,7 @@ static int posix_cpu_timer_set(struct k_ if (CPUCLOCK_PERTHREAD(timer->it_clock)) val = cpu_clock_sample(clkid, p); else - val = cpu_clock_sample_group(clkid, p, true); + val = cpu_clock_sample_group(clkid, p, !sigev_none); /* Retrieve the previous expiry value if requested. */ if (old) { @@ -708,19 +704,20 @@ static int posix_cpu_timer_set(struct k_ goto out; } - if (new_expires != 0 && !(timer_flags & TIMER_ABSTIME)) { + /* Convert relative expiry time to absolute */ + if (new_expires && !(timer_flags & TIMER_ABSTIME)) new_expires += val; - } + + /* Set the new expiry time (might be 0) */ + cpu_timer_setexpires(ctmr, new_expires); /* - * Install the new expiry time (or zero). - * For a timer with no notification action, we don't actually - * arm the timer (we'll just fake it for timer_gettime). + * Arm the timer if it is not disabled, the new expiry value has + * not yet expired and the timer requires signal delivery. + * SIGEV_NONE timers are never armed. */ - cpu_timer_setexpires(ctmr, new_expires); - if (new_expires != 0 && val < new_expires) { + if (!sigev_none && new_expires && val < new_expires) arm_timer(timer, p); - } unlock_task_sighand(p, &flags); /* @@ -739,7 +736,7 @@ static int posix_cpu_timer_set(struct k_ timer->it_overrun_last = 0; timer->it_overrun = -1; - if (val >= new_expires) { + if (!sigev_none && val >= new_expires) { if (new_expires != 0) { /* * The designated time already passed, so we notify