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.4 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,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 1FEB0C433F5 for ; Mon, 6 Sep 2021 01:20:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CAB9610E9 for ; Mon, 6 Sep 2021 01:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238797AbhIFBVW (ORCPT ); Sun, 5 Sep 2021 21:21:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:37640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238674AbhIFBVJ (ORCPT ); Sun, 5 Sep 2021 21:21:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07AA461076; Mon, 6 Sep 2021 01:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630891205; bh=37IGAPbcpOnofpDuEk7W4e8n+wX30U18HFbXwwutDKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GDHpjAMS1GrZNg2w9etex/zWH9dg10cRT4LzW97QPGIT80n83iJGDS7WlS6mbWm7J y+a2O5Ql455o7FZjFWs83enyn2oxxlppBHkAEvKjWQUA0CMLTt9xtHHtluuQfyASH+ qllb1HAFEAqeDljKMrXZvc7poYoTcC+xxR3zBmzTHdHw550bCOcK+MtF6oQZOK0/wd AAdo7YHjtXedz2M40V87q0Jvp3HFFW18OTTmw77QrPmgVSsHsdbDuawTQ3yTtNqVuF USrPybRBRHj6V8aeS7E6HRaud0LV6BXG+BCir0botH550oBRD9+GsepIbXDgZxBhOs PTEgR3EdXW3Tg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Frederic Weisbecker , Thomas Gleixner , Peter Zijlstra , Sasha Levin Subject: [PATCH AUTOSEL 5.14 11/47] posix-cpu-timers: Force next expiration recalc after itimer reset Date: Sun, 5 Sep 2021 21:19:15 -0400 Message-Id: <20210906011951.928679-11-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210906011951.928679-1-sashal@kernel.org> References: <20210906011951.928679-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Frederic Weisbecker [ Upstream commit 406dd42bd1ba0c01babf9cde169bb319e52f6147 ] 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 it reaches 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. Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20210726125513.271824-4-frederic@kernel.org Signed-off-by: Sasha Levin --- 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 517be7fd175e..a002685f688d 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1346,8 +1346,6 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid, } } - if (!*newval) - return; *newval += now; } -- 2.30.2