From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15336EB64D9 for ; Tue, 27 Jun 2023 11:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbjF0Lcc (ORCPT ); Tue, 27 Jun 2023 07:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjF0Lca (ORCPT ); Tue, 27 Jun 2023 07:32:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0289E26B8 for ; Tue, 27 Jun 2023 04:32:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 934DB61189 for ; Tue, 27 Jun 2023 11:32:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72E02C433C8; Tue, 27 Jun 2023 11:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687865548; bh=AlpMZ5iLqgAPxVW6nsDVYIyw9ZFOHeY/QxYTKuyL484=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qJcvhkkvfbBXSqbGMu2QUXOoNwcdEXCxGycx2ODHftd+U8MCscjuAK9KJy4B+oWi5 CJL7Te5EZsGPovlqAtUV4Wn9Xk2Caje/ovhJGD+LFxn01iFEn/3KiZOTytV2vG+0Iv zhrUQyPGGj/I3C9UtiCltVzh9qp3sWxJqZ/3GJAoDEFTMGj84ZF0npJo0MKFa2BkLB lSWwjY2jPm1iKfhvhPsbn9oq4aLITKjqx6beggTPrYWmxAvOeQRKvYRoiS8t/nA+W4 qK1wfBUqxzc/OHwm6aAkBZylhXYKVQ0LA2IF2wYjyDNanY6EeXgywIsEr8tFIQk5fZ 2/w14OcZgzHoQ== Date: Tue, 27 Jun 2023 13:32:24 +0200 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Anna-Maria Behnsen , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: Re: [patch 13/45] posix-cpu-timers: Replace old expiry retrieval in posix_cpu_timer_set() Message-ID: References: <20230606132949.068951363@linutronix.de> <20230606142031.761271959@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230606142031.761271959@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 06, 2023 at 04:37:39PM +0200, Thomas Gleixner wrote: > Reuse the split out __posix_cpu_timer_get() function which does already the > right thing. > > Signed-off-by: Thomas Gleixner > --- > kernel/time/posix-cpu-timers.c | 28 +++++----------------------- > 1 file changed, 5 insertions(+), 23 deletions(-) > > --- a/kernel/time/posix-cpu-timers.c > +++ b/kernel/time/posix-cpu-timers.c > @@ -609,6 +609,8 @@ static void cpu_timer_fire(struct k_itim > } > } > > +static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 > *itp, u64 now); Perhaps you can move __posix_cpu_timer_get() above posix_cpu_timer_set()? > + > /* > * Guts of sys_timer_settime for CPU timers. > * This is called with the timer locked and interrupts disabled. > @@ -680,29 +682,9 @@ static int posix_cpu_timer_set(struct k_ > else > now = cpu_clock_sample_group(clkid, p, !sigev_none); > > - 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, now); > - > - if (now < exp) { > - old_expires = exp - now; > - old->it_value = ns_to_timespec64(old_expires); > - } else { > - old->it_value.tv_nsec = 1; > - old->it_value.tv_sec = 0; > - } > - } > - } > + /* Retrieve the previous expiry value if requested. */ > + if (old && old_expires) > + __posix_cpu_timer_get(timer, old, now); The changelog should probably mention the desired side effect that sigev_none will return a zero old value if expired. Reviewed-by: Frederic Weisbecker Thanks. > > /* Retry if the timer expiry is running concurrently */ > if (unlikely(ret)) { >