Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17550336rwd; Tue, 27 Jun 2023 04:47:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PAbPdhCquMnAvvKtWy3oDbTpZTopEf4Zm0kdYTGWBoAl5TVRyoWnDz4gWfWdsRSh6BQpQ X-Received: by 2002:a17:907:94c9:b0:989:3e0d:89fb with SMTP id dn9-20020a17090794c900b009893e0d89fbmr18768919ejc.45.1687866423927; Tue, 27 Jun 2023 04:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687866423; cv=none; d=google.com; s=arc-20160816; b=th9kYx6tztLj8kLJyZIuYaSuMFNWGzuEVboTsEp8mGw6sCDf/JMW4mkewW9D0Abnud qTMslwHyrQTDHq7OqXcW+MGbgYoz+8jjungC9B2v3pAHo+elGq9rgxRBjEvo0jvm/x6U hZnAQc0ePsIGb8lvYicdLnu2ujyY5HM09KFy98ndSA+gydUBbJTsr+REzpD48kbtJ4FQ G/FIuLz9BAquvj6//3SJxP+17jlZEBN5tGtqo9W1cMyaRNoU56LUVDllDTukrWzXczyj eca4GyIdNnhI3J53DWxlenRacndR9qKmqoDahR/mUad5JthLP309vfhzvsNYGpUmCQbR V6Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DjKoKBgEI1Ap5SjhHl4fSiMtM1HbkO8esaslvdTNij8=; fh=QOUZCYc62iDiwtosvzrxKEygH1QGT5eEr4TokP/EdL0=; b=iNrIoRyExa/fbitVVi+xXgbptfGtC/6fx7VxyOrt8Wa6JVAykK877iGR0GgXCAHlMa U6TzP9w0MeCculJdrMiDuJd13PC6sDaxkzEjeBkueG7k/i6oJJjdIh4CV318YnDihgmG r2F893CH8yYCzMHHtpmRlrdvkCh26EfzeKy3kUCqofFc8F/4ndHazWQC4uJUJq76+vPo bwCnLgbI+W9bjZpgvAxHMNhERLUN6x5ILlr8CzfHJbK90N58hVC2luMW3yCzhUrfrz1Q PbMU9XWmOM1FUFRiLRAx1VhY1jzpHlaff9XvNDnOFD+NnZA1Y65dVziWIZeENvVpI7s7 d1kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WxTCxhmF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k26-20020a170906971a00b00991f598188csi1435117ejx.214.2023.06.27.04.46.38; Tue, 27 Jun 2023 04:47:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WxTCxhmF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjF0Kv0 (ORCPT + 99 others); Tue, 27 Jun 2023 06:51:26 -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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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); > /*