Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp65505lqg; Wed, 10 Apr 2024 15:49:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3m5o1lL3MN92Br6vJA036Wb3hmsd9MpGYvP8+kqmqMl89ZAUcd6RZ9+gj7VE85deq+mIKXcEmBa/a4cd8SAd1Ak7N5GRj1rkAOjSCKg== X-Google-Smtp-Source: AGHT+IF4PyaOIm495Cli67BZUnJQADXrzi84qrNIwRt1JpoxjNLK/h2jPQK2XsVyf4TOYIdJFkuI X-Received: by 2002:a05:6358:5c0c:b0:186:4ada:4256 with SMTP id x12-20020a0563585c0c00b001864ada4256mr2601026rwe.22.1712789395798; Wed, 10 Apr 2024 15:49:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712789395; cv=pass; d=google.com; s=arc-20160816; b=OrnnfHSg2Wog23kOFtnRCIP3rHIxnRdkabKECbII9jT+5kxcrf+wmBg8J4aS7s+SCI wXjhW9T5+uprUKJTJkeqeEuCTlccLj21t5lWfOJ2N8454kQalJmc8UIHKWkJhccvhE8q GWBF3aQuoQ5Laz2t4TCEHxjG47u9dPpjCK2eOBXAmd1JiDO9pyeqtmxr2cJn7gyg+wIf tRR3YxPn+Yg4EG9KfxOO6s4I1Y9JjMZ+NkqiRh8XqAkRBzs7xoFVntJhqhW9/m1gQCg3 p1KJaV5TnNUN3uwbuX7LxZ+OjjT3gun3PHwUdhV+a5yk4YB3jhgJbh4kJhC+Gdo3i/Ky IIvg== 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=a4kBoLxoimUoUZk3ev7GSbKQUyXJ3UwY85qwVJP4oio=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=c2muInXAuYbwGbfQtVSlmR+OF5OpiMAg/aTVwAMMqB7kkZHgc97f7MNfwrB5WPYDqE 42Y8M96vyd9HIqYChA4UqKpoaeJKxekE0AGmtwxw88t8bRQDhyw60Rge+9V8SHhnouJj owgtl4nxuQVkl2NHXeO6cAtFlc62ZemHcWQBBJ3dXzqGlb2LZGARfrDl+ZzxhD0TnrbY JoNQNwIG/pKLdGSpq8a9jLh1PElsWo4tkV26hFjyX9yzaV94e9P3PvZk/nS/bQdRZWvR kTXhLUFo37uNzWODDLAMX1YVWv/QxBALVx3kvFTea95v4fnAhn9XXNpcrnkTUXY6Ffkc Ql3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=C01lQgvn; 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-139470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139470-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 bq21-20020a056a02045500b005ceef3c53a1si92692pgb.635.2024.04.10.15.49.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 15:49:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139470-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=C01lQgvn; 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-139470-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139470-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 AEA9D2823AF for ; Wed, 10 Apr 2024 22:49:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5B9F4F5FD; Wed, 10 Apr 2024 22:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="C01lQgvn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1S9lztVW" 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 6F9504F5EA for ; Wed, 10 Apr 2024 22:46:44 +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=1712789205; cv=none; b=er5IjfrzO+Ara+F3xnu77EeUtZ79ZCaWdDv/a92ifcLEcRJel6oYLhLTHlOQZkN1RikymoXcH6Ex+HLRIJtUWuP4cK/XQSvu2HDdXHpRGvW1CxnVf8yMDzN8Fw1WVqxQpoqMpcgtMbjyicX9Hg5EAfe84y+hTOEwoDfwwFyIJtg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712789205; c=relaxed/simple; bh=M9Q7ax6L6HgZ2sYcMaynew0ayWNP6jxDDhPzY9nkD8E=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=UsyrI5lpWVVWaBGoK2ambXpD+x4pm2EnG3UUUIO7V0zvQgj7WkUXjniwHcyFstlFFCOEkEt1kf3vlT2NHJt94hnr2jw8qR9aKZupdiiXMgPs4XNKpU0JcptC8SSlwMnzFWae8g8fNinvtMGHViRqgknuDqvx+8JDdKG+OTd1WRE= 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=C01lQgvn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1S9lztVW; 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: <20240410165552.006883398@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712789202; 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=a4kBoLxoimUoUZk3ev7GSbKQUyXJ3UwY85qwVJP4oio=; b=C01lQgvnpJfKiWn4HWNf7Sv/QhuG1SRBw6FdV/B0Agr60V6KbpT7YrMuIL/cZM25UFPClm rJTx5ssCYKQLh9HiVlL8h6Ythh6i0GHyjapo0AxxlcLNpLeGEYtWUaxfdn0UZFw4mx1ELR AOIZYzL7+IcQwDucOaGQQcUAs0LpkdR5hO1t4wG/sfvdXX+g7RK1CaK/G3c3drgojlpjWR tdQYsjV0w7Biy9Qhx1DxCdVeDuwAGDycEBZpkrDtbpDH4NbnyumfMyG1essOCZas/V0gfi Ms4ApNoawa9EFvwtNvLD6nQknODJ8nUBCG27MY0NA+ZYXfR4GXr7ZtoCL92LOg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712789202; 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=a4kBoLxoimUoUZk3ev7GSbKQUyXJ3UwY85qwVJP4oio=; b=1S9lztVWxLgK1OLkPLMZ26JATwvZaSWE9lLqTLHm73YPwWss7AwpGc+1+m0h5iYVXlLPUP J4ouymcsEEifd/BQ== 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 V2 17/50] posix-timers: Retrieve interval in common timer_settime() code References: <20240410164558.316665885@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: Thu, 11 Apr 2024 00:46:41 +0200 (CEST) No point in doing this all over the place. Signed-off-by: Thomas Gleixner --- V2: Removed the timer_gettime() part - Frederic --- kernel/time/posix-cpu-timers.c | 10 ++-------- kernel/time/posix-timers.c | 5 ++++- 2 files changed, 6 insertions(+), 9 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -622,8 +622,8 @@ static int posix_cpu_timer_set(struct k_ { bool sigev_none = timer->it_sigev_notify == SIGEV_NONE; clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); - u64 old_expires, new_expires, old_incr, now; struct cpu_timer *ctmr = &timer->it.cpu; + u64 old_expires, new_expires, now; struct sighand_struct *sighand; struct task_struct *p; unsigned long flags; @@ -660,10 +660,7 @@ static int posix_cpu_timer_set(struct k_ return -ESRCH; } - /* - * Disarm any old timer after extracting its expiry time. - */ - old_incr = timer->it_interval; + /* Retrieve the current expiry time before disarming the timer */ old_expires = cpu_timer_getexpires(ctmr); if (unlikely(timer->it.cpu.firing)) { @@ -742,9 +739,6 @@ static int posix_cpu_timer_set(struct k_ cpu_timer_fire(timer); out: rcu_read_unlock(); - if (old) - old->it_interval = ns_to_timespec64(old_incr); - return ret; } --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -904,7 +904,7 @@ static int do_timer_settime(timer_t time const struct k_clock *kc; struct k_itimer *timr; unsigned long flags; - int error = 0; + int error; if (!timespec64_valid(&new_spec64->it_interval) || !timespec64_valid(&new_spec64->it_value)) @@ -918,6 +918,9 @@ static int do_timer_settime(timer_t time if (!timr) return -EINVAL; + if (old_spec64) + old_spec64->it_interval = ktime_to_timespec64(timr->it_interval); + kc = timr->kclock; if (WARN_ON_ONCE(!kc || !kc->timer_set)) error = -EINVAL;