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 X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7437DC432BE for ; Mon, 26 Jul 2021 12:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A3EF60F5D for ; Mon, 26 Jul 2021 12:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234198AbhGZMPG (ORCPT ); Mon, 26 Jul 2021 08:15:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:50610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234072AbhGZMPC (ORCPT ); Mon, 26 Jul 2021 08:15:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8681C60F46; Mon, 26 Jul 2021 12:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627304131; bh=duAI6da3d0IJY3Ydyn7BrPpbzqS/tN31SpkrAKR6pyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1NeTOLJGKDiBwmqUBu8dNXMw3SoqYzIoWK2HWN5bciRtA9I3pDpr4FoxGrZHuOxl Yg/SHPfuf/qk9EFcVJe7GlpPBijLEHp8ljglFDRzttMaNdYS/hEDI0rg3rnylSEpXt PN2PRpL3jbPipMrB8Jd52iBzEzJXk8Xdpb4tjeV+EVACdo+aEH22uoR+MPdOLaAnOQ zXDhKY+T5VF3h97gRiVT+CB9u9D+pdPivuX+6EqxuAcYUyALwttxO7kzmZ3+aqu18B Yg6t/+Qj/wvrKrRSLlTAXhbWV4kmuihGa7LwFu13cW9J03d8AC4cXme6vFiEbhTfwh hg98lBcIgM/Qw== From: Frederic Weisbecker To: Thomas Gleixner , Ingo Molnar Cc: LKML , Frederic Weisbecker , Peter Zijlstra , "Eric W . Biederman" , Oleg Nesterov Subject: [PATCH 3/6] posix-cpu-timers: Force next expiration recalc after itimer reset Date: Mon, 26 Jul 2021 14:55:10 +0200 Message-Id: <20210726125513.271824-4-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726125513.271824-1-frederic@kernel.org> References: <20210726125513.271824-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an itimer deactivates a previously armed expiration, it simply doesn't do anything. As a result the process wide cputime counter keeps running and the tick dependency stays set until we reach the old ghost expiration value. This can be reproduced with the following snippet: void trigger_process_counter(void) { struct itimerval n = {}; n.it_value.tv_sec = 100; setitimer(ITIMER_VIRTUAL, &n, NULL); n.it_value.tv_sec = 0; setitimer(ITIMER_VIRTUAL, &n, NULL); } Fix this with resetting the relevant base expiration. This is similar to disarming a timer. Acked-by: Peter Zijlstra (Intel) Signed-off-by: Frederic Weisbecker Cc: Oleg Nesterov Cc: Thomas Gleixner Cc: Peter Zijlstra (Intel) Cc: Ingo Molnar Cc: Eric W. Biederman --- kernel/time/posix-cpu-timers.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 61c78b62fe6a..5c71322b45c7 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1379,8 +1379,6 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid, } } - if (!*newval) - return; *newval += now; } -- 2.25.1