Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp505903lqp; Mon, 10 Jun 2024 10:22:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhb6gRV7axFmxm8qKpAj4+7M0K1qkOMs61Yh0argXXtjwaR+psCpiQOP4SYkUtVpVgbMG0sOA3cA2GVIPKyNVjTo2LuHhKxyWyHDrpJQ== X-Google-Smtp-Source: AGHT+IGjFncbwkvrdx1j+L0ahO+21U13E1EJ6Dm1TQFa1gg8M4ujwUbM+IN+lHMkj0IAFuACR+q9 X-Received: by 2002:a05:6358:432a:b0:19c:3fad:8a8b with SMTP id e5c5f4694b2df-19f1fe293bamr1465040755d.12.1718040129112; Mon, 10 Jun 2024 10:22:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718040129; cv=pass; d=google.com; s=arc-20160816; b=fnum7j8T5EAQsXi/QIXGN8XU4yi7AcjfXHgE/ZUOTKDpZ6gK+hKlsyQOhHb/cHZ9s4 vpk2Okmld0HHb4ruduYOW0iVurvfxUKvYpCI4y7u+XMDTrUsz8EU7oa100vnQQfSmP1h DztY7KkYh/RRWmZzo7vMe9Glz6YeOdTXQp0eoV7fHzGq65y0Z9MmjYq4SrGPcrpZ4TAW k+H0DbWVNbB3exazPGt20Pa4VuHaVwME8lQkip5mH2PPBNWHC5qV4pSyGfNFfQ3fjGa4 rcYx9wpoct+0Dst9dORQ/mziHqajWwRHTzdkr59jO/XfLtt43/Z4pVnD4wGnpIiwYRzA +mpA== 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=IjZXK69CXPSZdDcaR3Lrs+m7BfPVp6Q5CnwMmPhWl8E=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=KW1IvWHK11i3hMtLuPth1666ZM3qaHq1kmWwxvq7V3mX9lsEbpk0RqoErOeV9gpIWA H7lR5zX8C6xJHzWZL4YGrxLeC75qsgXDjWWmAwhDhR9rXIpv2Q147G2FOk/WOMA4y2b/ vgIsoNqWW6CFpbVychlFuDvzKqt/fkoC/awo1P7TJRMW4agdWHsAnxi0nFjwR8wWqoS1 R7LA1Dnx9PuvlEaOL11wnSIqeHyuTnIPYLO01jEFKs9UURNUCbI34P84UjTJmDaRFyGi PW5uqcChvZtFDavDIOd8sD8Q+edfG9lc2/N9twvNg9huRwuKELtWL8GbRuNT8pUZXB14 2VCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vQKwhV2V; 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-208576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208576-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2ae0ee72si4777405a12.868.2024.06.10.10.22.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 10:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vQKwhV2V; 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-208576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208576-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 14BB6B2476B for ; Mon, 10 Jun 2024 16:44:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03F0115252C; 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="vQKwhV2V"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RQeo4Py8" 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 2C96C14F9F7 for ; Mon, 10 Jun 2024 16:42:22 +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=q1qE3GmJLX/hn+RnjFVqgtIZOSy8ynmZCfGjPIM6sZ+ORVKlhdjnx71s97kjenBm+ZLDnMa/0MUD9WrAbxrvlPZitGyFQ8Kw59a6wNmejZNwn3iF4P/MIsSxT3NkvbXCTtoxfplWNTk8g5qELv7FTpDH5Z7thTctP83WX4WkfpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037745; c=relaxed/simple; bh=UGVZy9yiNtE3R/qqXfALDVUSsmVr1T6CsA5jtA7JuEI=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=PIQ62bLNcUYJYJHf0ewFXGm9bkUbPnWCisqMMlz4Ba1dIE1/KxDBx8VqVtrxvdemmMI+gq2HVcr4+q11s46erAGube2FYkM6rvDdrwjGkAnCiXPIV1KFr5l40FjNG9ntltiyHIRDg0yvRKXg1LKoi7SuCe+FnK5d0Q/AGa51a2o= 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=vQKwhV2V; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RQeo4Py8; 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.225762087@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037740; 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=IjZXK69CXPSZdDcaR3Lrs+m7BfPVp6Q5CnwMmPhWl8E=; b=vQKwhV2VHCny5Tg9fl+zR5CNQptSwBYJMiOrxDw+e1CprtmxOUsVGtbzKoS24BralhVc/t /O6N7SJtNVDWq9knDZsyLHaXLJNxI26a7EGSN7ujqIFtLs0Ys5Eeb2LRFWvnQWQ1LWecCl RQMO8J+21voQbixP7HAEm76GP7E1ua0lnRQXJPAeylmfFkJT28lqS8DthGFCCSOapTQrmx pwNF1LKM0ycUGc7Ce63QsXk32xmT3ojOpCpM+qITQ5UYJH55ZG562zWOh4jmmHSbBwUsUx KUOuUj6djGUwFYZ51jpWkRmZj59eeuN77/eaPYdDFFhCtANZkrwVTHOIV+htXg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037740; 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=IjZXK69CXPSZdDcaR3Lrs+m7BfPVp6Q5CnwMmPhWl8E=; b=RQeo4Py8SyaHuNFc2wn7AHLLc4Nu6RvFl5F64d02NDNnhld6SvGIdMVwfy6yhBRTVLIYkK GGomy/CX/nWDjADA== 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 12/51] posix-cpu-timers: Replace old expiry retrieval in posix_cpu_timer_set() 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:20 +0200 (CEST) Reuse the split out __posix_cpu_timer_get() function which does already the right thing. No functional change. Signed-off-by: Thomas Gleixner --- V2: Adopted to previous changes --- kernel/time/posix-cpu-timers.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -614,6 +614,8 @@ static void cpu_timer_fire(struct k_itim } } +static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp, u64 now); + /* * Guts of sys_timer_settime for CPU timers. * This is called with the timer locked and interrupts disabled. @@ -688,37 +690,11 @@ static int posix_cpu_timer_set(struct k_ else val = cpu_clock_sample_group(clkid, p, true); + /* Retrieve the previous expiry value if requested. */ if (old) { - if (old_expires == 0) { - old->it_value.tv_sec = 0; - old->it_value.tv_nsec = 0; - } else { - /* - * Update the timer in case it has overrun already. - * If it has, we'll report it as having overrun and - * with the next reloaded timer already ticking, - * though we are swallowing that pending - * notification here to install the new setting. - */ - u64 exp = bump_cpu_timer(timer, val); - - if (val < exp) { - old_expires = exp - val; - old->it_value = ns_to_timespec64(old_expires); - } else { - /* - * A single shot SIGEV_NONE timer must return 0, when it is - * expired! Timers which have a real signal delivery mode - * must return a remaining time greater than 0 because the - * signal has not yet been delivered. - */ - if (sigev_none) - old->it_value.tv_nsec = 0; - else - old->it_value.tv_nsec = 1; - old->it_value.tv_sec = 0; - } - } + old->it_value = (struct timespec64){ }; + if (old_expires) + __posix_cpu_timer_get(timer, old, val); } if (unlikely(ret)) {