Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp483256lqp; Mon, 10 Jun 2024 09:44:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjr1HgSs1/Gdvyn/TwqKKyEefOCj+El0fzuQSP7c1k6iSoexYdvl218dBgv8UPrzP00E9GRoqeEks04iCz38ueFS2rsfyQjpQNZp5Xzw== X-Google-Smtp-Source: AGHT+IFvNAfZvn4vNCW7wG3NYm/LI/agw7NdbaFhJ2J7c6Cy/k6MzoispRqi1PRmhhhDSbedwsoq X-Received: by 2002:a17:906:71b:b0:a6f:1e97:b177 with SMTP id a640c23a62f3a-a6f1e97b24fmr177483566b.64.1718037868194; Mon, 10 Jun 2024 09:44:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037868; cv=pass; d=google.com; s=arc-20160816; b=EZIVsoi704ieafWnCHoEWbTHrb9pdHdVTZqJ5SuhpLnI9RWlbEnJXWXpR4otI1gSVm kZoLmDTYkZJtpB8tANh5UsXqMGUmUdPTitMFCPhIDi2HWASLNHZwLb+mCVBktLO7XxAg NRbpeWHOoIjirgTdWzL26caHho77liw0oWmI2V36NGqZ3nV5KJqq8J55jPDGssVeyfnY XgwO0RITjryLM8Wz9VvEETgs8JdTrwo/6ZcUH7O8MN0qn5/3ZFZ7tG/FdDOUOpS5CBrP AWvi03XoNT8IKEQrJORllhLAO64FyQGFkrwc+JgYlizmOst9m0CRFv16gFMExubeuDzM K0Ng== 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=bZ0w/TM6AE9SMRNm3Xm9JEw2iNfzEaEbkpBswlSbBEk=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=b93q/69DuwRTi3WugEyweIUeCLGypCRIKvWu2pIWGqQRPz3lPrymtivXP21LB0+cQo jLo0UeR4gH1i54qJlt4qn+g2ZnRe0F83GqXFxv5Zpj/M5s4QKr7EXrdyavBZfQ41ij7N lO8ivGYhXae3a3lwl+w9ZlenwzLYtIltpxWGpLN5SnmaMNeIx9xPWKW4oYNc9IvtCuIj HEbQsW2P3KBjOT790ZPuUuYfgMplxXYZaz7D/PlZ+ghOyTzNNGVXiAwvBv4rlHxbgGvD GbjQIw5ARVxnb5ADr0KuZxqfAZhZYwfj5L+hKjr8TL1A9J55Gl97guTUq9m3KV+LDY8X VMmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="351GCj/b"; 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-208575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f1f67e32csi115686166b.1034.2024.06.10.09.44.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="351GCj/b"; 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-208575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208575-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6675B1F2174C for ; Mon, 10 Jun 2024 16:44:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5255E1514D8; Mon, 10 Jun 2024 16:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="351GCj/b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vON8lXJ6" 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 1BE4E14B95F for ; Mon, 10 Jun 2024 16:42:21 +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=1718037742; cv=none; b=OLoQ/Pg1Xxry7u//YvGruY6AdupeyxqGoBaetBCHBzVq0a1zA6fkEZrWfWbXKipdCTUtpCNvFwb1k7OumfgAsLNvWz8cSEVZsokL/4MrWgM+67VCHYe7yNoUdxMHnxQucyexr9GdfYz2pr984YN2YUV1dZWZ8SWWZnwCwb6LPWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037742; c=relaxed/simple; bh=tBM7wjzipNsnWNbyoaSXjOxN31IJ8Anu9Imn8eeRuXc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=KXsJxElQ9MR6xKi3afJ8ZgHASza50sa06BDIfCvxd2354hfrS4v+NkAnFj/vJ8FDnKIAorBdjQ/5fWWWJopeceyCh+fXADZ2kEadIX3xmM/m26MVfhQQ2C0uLVRnVNXmJn/3Mck7I6wFVTNyPlMnNSiKdwGHNBzERzG8mUW78r4= 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=351GCj/b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vON8lXJ6; 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.036097741@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037736; 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=bZ0w/TM6AE9SMRNm3Xm9JEw2iNfzEaEbkpBswlSbBEk=; b=351GCj/bR/40nMdJI8rjAQt25kbM1nWMcaza6ayspqb9bXegZVO8gDYHCm+SGSziHIb9Nk LhTgk3NIMkX+ayysJ2LW14zqQz5B81woD/CYn2P7HZo+O+9LVo8uuv3U9+hHrPcxY4yFF0 N+9xNu8LUfJEulYKshSQ3GVn3FvHGnrshl9w2qemV55YpMR+PQbRsfXsmp/Bawz6G0IsRZ qA2K0DQjvlJcCHeJ36l6fbj4htPzN7mkk7rpeCgivnJfyjzhpi/pdB782lBe+LdNmD+O9H MnoZfkvVSEVLlmJTz0H+8GJALAHminllApN2GQhk8zpo51ffnhJkK4FBQE/o0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037736; 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=bZ0w/TM6AE9SMRNm3Xm9JEw2iNfzEaEbkpBswlSbBEk=; b=vON8lXJ6+zui9Pu0J/0NdMU/sEOpftHBrE9jvM6wlg2JqHV2e8oOQg7BQvfYUhwMdZOpny sDSQjs9igFDbNGCA== 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 09/51] posix-cpu-timers: Handle interval timers correctly in timer_get() 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:16 +0200 (CEST) timer_gettime() must return the remaining time to the next expiry of a timer or 0 if the timer is not armed and no signal pending, but posix CPU timers fail to forward a timer which is already expired. Add the required logic to address that. Signed-off-by: Thomas Gleixner --- V2: Split out into new patch to make review simpler - Frederic --- kernel/time/posix-cpu-timers.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -787,8 +787,24 @@ static int posix_cpu_timer_set(struct k_ static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp, u64 now) { - u64 expires = cpu_timer_getexpires(&timer->it.cpu); + u64 expires, iv = timer->it_interval; + /* + * Make sure that interval timers are moved forward for the + * following cases: + * - Timers which expired, but the signal has not yet been + * delivered + */ + if (iv && (timer->it_requeue_pending & REQUEUE_PENDING)) + expires = bump_cpu_timer(timer, now); + else + expires = cpu_timer_getexpires(&timer->it.cpu); + + /* + * Expired interval timers cannot have a remaining time <= 0. + * The kernel has to move them forward so that the next + * timer expiry is > @now. + */ if (now < expires) { itp->it_value = ns_to_timespec64(expires - now); } else {