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 CB6C9EB64D9 for ; Tue, 27 Jun 2023 10:51:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjF0Kv1 (ORCPT ); Tue, 27 Jun 2023 06:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbjF0KvZ (ORCPT ); Tue, 27 Jun 2023 06:51:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7582210D7 for ; Tue, 27 Jun 2023 03:51:24 -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 DCBEC6112A for ; Tue, 27 Jun 2023 10:51:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B914BC433C8; Tue, 27 Jun 2023 10:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687863083; bh=AWdtvtdK2jeau/jeOTJfvqMbtrKaNLL/5enJRmd48p8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WxTCxhmFsYZwZAUnypYzQp7zr1OKXl0Mi2bRwdzxg/ZAvpHWhxe9rosI/V62DZDV7 KHDSwySXmrwBEAoaf2f61S7I4I0brjbOImFxNjUn5o62koGAJkf+RDDoi1un0ZS2lF E9gJ0KzkHL+kz0qsV81blsPD/wtAvZIcCM0PMJCqhW0XXotxid2x0XTU7ublct0oqg DD41l5RIvfP9y3nSHS0maF3mFMUTVzoCCIXxpBDQtO8SZAtiFR0AZ0nwZhmWGXlM0m C/Uq23M6YgreJX2yGwlxZIBZLDwNOjh2yGGn0Q2EQVzHrtTvRW1vExnmyVb49gGoSM V4+m5UWLiRmNA== Date: Tue, 27 Jun 2023 12:51:20 +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 12/45] posix-cpu-timers: Simplify posix_cpu_timer_set() Message-ID: References: <20230606132949.068951363@linutronix.de> <20230606142031.705286109@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230606142031.705286109@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 06, 2023 at 04:37:37PM +0200, Thomas Gleixner wrote: > Avoid the late sighand lock/unlock dance when a timer is not armed to > enforce reevaluation of the timer base so that the process wide CPU timer > sampling can be disabled. > > Do it right at the point where the arming decision is made which already > has sighand locked. > > Signed-off-by: Thomas Gleixner > --- > kernel/time/posix-cpu-timers.c | 38 +++++++++++++------------------------- > 1 file changed, 13 insertions(+), 25 deletions(-) > > --- a/kernel/time/posix-cpu-timers.c > +++ b/kernel/time/posix-cpu-timers.c > @@ -720,10 +720,14 @@ static int posix_cpu_timer_set(struct k_ > /* > * Arm the timer if it is not disabled, the new expiry value has > * not yet expired and the timer requires signal delivery. > - * SIGEV_NONE timers are never armed. > + * SIGEV_NONE timers are never armed. In case the timer is not > + * armed, enforce the reevaluation of the timer base so that the > + * process wide cputime counter can be disabled eventually. > */ > if (!sigev_none && new_expires && now < new_expires) > arm_timer(timer, p); > + else > + trigger_base_recalc_expires(timer, p); We don't need a recalc if sigev_none, right? Thanks. > > unlock_task_sighand(p, &flags); > /*