Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp484250lqp; Mon, 10 Jun 2024 09:46:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmhc+zeEYvCo6Qbi8IDQOVxatVG/lSfo/SoyPK+MrVBD06/8uie0WPlMVF1I5dhcbCUvNQJuJn6kO6kX3E1xhFPNQ/4IdrQKUaz5crCA== X-Google-Smtp-Source: AGHT+IE/cTFZmoQIxWpKFUsJR8FLpNnhIq1AIPnQp4dkrrIcyNvwm1OeBSOgALXpu9YZNYLkm5BL X-Received: by 2002:a17:906:a44:b0:a6e:ff74:8321 with SMTP id a640c23a62f3a-a6eff74b625mr402597666b.53.1718037962980; Mon, 10 Jun 2024 09:46:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037962; cv=pass; d=google.com; s=arc-20160816; b=lBTR7tPCQqvocJtkmuydo7MiKhYLbxqavyl4TAhwDswgF1JDXe0tJt2BIP17aecIWo lP/g+HqV2uI6Qaq/9JZl2FCgJMhiO0SvLiq3ym3HapFbParI1jy37cLArhr4cvPehTGG vIcyKNr1aufWh1Gs2I3WkDsQcgHuu7w/PxyPNCUAOlr+7Y/Zm6UPjM8nPy9y5L7Zgovx ZrtZfCiETGMgFjjzZWr2obioLpWMhMxZiMSxAib0aTCe1S3dPr0OP28GGEfdf9Vy0RmE qyeg4mBxtl1qbC8WHltETgqLTCr5iiwcFOPDZ9l8KOTycJiukTMq40hXwQUcuyp4SORy OOCQ== 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=MghZ84E7UiOr0tHvfGZO5fEWxIJEE5d64smYZ8Zr4EeNs5hw270Iy5wHTIeCsfCr55 Z/JnaBv0JbT7bJVSQV71J6wZ2YNG4AgQ7DOFXyddWWLYJXItQFMQ8HlHEc/XNTvVg1Tt UrzfIWczPXd4jb4WTSA2AWT29azicPN9+/snEAn03yBV+bc3h/sCHYYc47E8RDg6QrWk x6CpWKTclmUlKax5mrL1tMPuzskK6bKSEGBrMQ7kuxyqH2P/xUTV7I5tPQV0xWcw6VfR HywBemZYxXCPw4zrnYtCrZGxmNb6EshvtGpMkBWjiIRuoTkTTmi0CtaIh0T/SeEd+Tuq nHIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QGjhEL8r; 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-208582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208582-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-a6efbb033ffsi279444966b.816.2024.06.10.09.46.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208582-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=QGjhEL8r; 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-208582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208582-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 7C8661F21C0B for ; Mon, 10 Jun 2024 16:46:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C2E714659A; Mon, 10 Jun 2024 16:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QGjhEL8r"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="l6CWizxc" 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 476C415380D for ; Mon, 10 Jun 2024 16:42:29 +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=1718037750; cv=none; b=kQW5weaEWeVHE+HvsdXrqr/nFPeO2xlvLDvpv/yi2kxBvtib/hKurbaFIm9pUqLiGWNhhdiCI/Ebd1NBnnZUS7VWxWuodlLt+ho4S0H39Z33jxgcrK/Gw34/4VzD0LTCc2o3MPvLpGoGJM9Kn3dKFBQdVj1idDUogiXET3GowSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037750; c=relaxed/simple; bh=M9Q7ax6L6HgZ2sYcMaynew0ayWNP6jxDDhPzY9nkD8E=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=ESO8t8iJ9IHBCwTWf5126QI0UQUafluDoeuKtzOEZw4kApcQZWOI0SiHsb/pzwOoxe7CrRBuChvwZqXSOD+usdys1SXh/I9dyN2Xz5S7B/AYHr01AvVhnHeQQbjyIAhC+skoOJ8XnACP5xAviiyVtxLj/44dnhBNgJuJfNTaiBQ= 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=QGjhEL8r; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=l6CWizxc; 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.552899255@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037746; 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=QGjhEL8rgUf4LT4XnfB9hwh3Joy0TpJofyy3Zzciwpqy16jIm74JFa2pE9d88WtHtzhcw+ YU1uZNVe/NP5Ln74Gl6w2LvLAyxSO5s5lw4ChUDTI3TFDz+91wLG2ZBlSzzaerBojQzRQY fPz9Rw356u4q4P0kfeGJ+7zbwieLSFcTPKj6CAL4PzV7MRyI9tQduMUKgCdhEQYEcIVyH7 ey1HHEPNqawr/B0rjYJVk3eZERlTsHFRUFP2XyXj6Wl7kVN6ufn0HcznsI7k6EhkdLm0gB yBiVpomKR/omMT8rnUJfMzqIaCvZUKEqBHeJi2VjoHbXMLsM3dWqpy1yd5TeBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037746; 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=l6CWizxcP/W4v72SIhiaaF1M463VhiMlQJ2B0UjZXbp0QYE48s2XaSzfSqdPAD8+heHtNZ PLW4LmA9Lz4jgNDw== 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 17/51] posix-timers: Retrieve interval in common timer_settime() code 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:26 +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;