Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp625114ybt; Mon, 6 Jul 2020 18:34:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmPO1uSOYFhrEvefyOvHk4/v+TB4nBfpd3Z4HEzDCAadxTaY0htB7rgHnKjpGtTFs3RcCC X-Received: by 2002:a17:906:4dcc:: with SMTP id f12mr46934677ejw.401.1594085642557; Mon, 06 Jul 2020 18:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594085642; cv=none; d=google.com; s=arc-20160816; b=emkzDTEUTcnyWMyLbSnvcqj78HOWj6AWPh/sCVC1NWAWkB4MlluOJdyDpFGQQ4ocaz ZyLYMywfY/ZPyx6LDa16LY8jDcbzKAW2i/ffOluQ41vGJdPSacLyQy3hvoBuGPpLqCUk Vna6DIC1yxB2LRMFSOPvs1qoxAzQweB+vC2wyNh2+huqoRvZUucBLtawyuTkWZov2Iel gWDPz/yxX3KQlxBc7x8wU6G/RZvcH05SBlo7eOY1HWYIjf6dIZne7P1fTN0EFGpyeGuz t//xJ78qGTzxwStd6ZYoUHVKour3BNIQTA+mTMLyLGJEk4PXd4SfbYN+IpUORvb9OkYf mv1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eBjT2wcOqL3LOcX7O7dx7/wbqYvSJcPQXWAUvNFw61Y=; b=eLskICmhRYLmmhjNoqSL76M/EXqsN0GsmMBd4KbSO9gF8bxh79fB+VYphI+9zZB63c gNtMZA/7laJ6qcagO99KO57bWa9o9xBDjDDLzu5Pvvimy0zTO6BOK3iP22qw6YhbtLsL 4iiI9f+DXHJzw+LIZ9ltryZygwMliudtVTvtUsuRLuSVssXU/WE3OfVCHSqH1uhHQyNI KYemBhf0QLq7yKLm4zThAHJEYnZVpoh9VmAzSTaGPmNAd/AsdhWeQL+Isobr2F+yvoIp hEiUfseU7fZTYd2EznWoVkjYSiWq64w/rU2+QFH8FZrV+X8sUgo8E5Z0ssqhL6A+sTmM uLBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l3jJ+e5y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si14744645ejw.376.2020.07.06.18.33.39; Mon, 06 Jul 2020 18:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l3jJ+e5y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728025AbgGGBdU (ORCPT + 99 others); Mon, 6 Jul 2020 21:33:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgGGBdT (ORCPT ); Mon, 6 Jul 2020 21:33:19 -0400 Received: from lenoir.home (lfbn-ncy-1-317-216.w83-196.abo.wanadoo.fr [83.196.152.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7375320791; Tue, 7 Jul 2020 01:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594085598; bh=NgWEqQnSVqC5LOup/3TSA5hnb6wwgWyqhpWuOGCgkF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l3jJ+e5yKAFgSKglKAA2UxdM3e4edlWhu5hTOjsBPsNZHrtfy/cSVWVrKk7I8ceCK ycBKhqHJCuGWDrKjvtP0YBf2Pkz2rxjX5B2gBbdkHNuorzrB5lbq1OUuZA55owap+E ewbKMzBN8CN8Z25hNlvi5EH35N/lAxq0FoG5wim0= From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker , Anna-Maria Gleixner , Peter Zijlstra , Juri Lelli Subject: [PATCH 8/9] timer: Remove must_forward_clk Date: Tue, 7 Jul 2020 03:32:52 +0200 Message-Id: <20200707013253.26770-9-frederic@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200707013253.26770-1-frederic@kernel.org> References: <20200707013253.26770-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no reason to keep this guard around. The code makes sure that base->clk remains sane and won't be forwarded beyond jiffies nor set backward. Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra Cc: Anna-Maria Gleixner Cc: Juri Lelli --- kernel/time/timer.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index cbc5ac7f772d..60126d5c79e1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -205,7 +205,6 @@ struct timer_base { unsigned long next_expiry; unsigned int cpu; bool is_idle; - bool must_forward_clk; DECLARE_BITMAP(pending_map, WHEEL_SIZE); struct hlist_head vectors[WHEEL_SIZE]; } ____cacheline_aligned; @@ -885,12 +884,13 @@ get_target_base(struct timer_base *base, unsigned tflags) static inline void forward_timer_base(struct timer_base *base) { - unsigned long jnow; + unsigned long jnow = READ_ONCE(jiffies); - if (!base->must_forward_clk) - return; - - jnow = READ_ONCE(jiffies); + /* + * No need to forward if we are close enough below jiffies. + * Also while executing timers, base->clk is 1 offset ahead + * of jiffies to avoid endless requeuing to current jffies. + */ if ((long)(jnow - base->clk) < 2) return; @@ -1721,16 +1721,8 @@ static inline void __run_timers(struct timer_base *base) timer_base_lock_expiry(base); raw_spin_lock_irq(&base->lock); - /* - * timer_base::must_forward_clk must be cleared before running - * timers so that any timer functions that call mod_timer() will - * not try to forward the base. - */ - base->must_forward_clk = false; - while (time_after_eq(jiffies, base->clk) && time_after_eq(jiffies, base->next_expiry)) { - levels = collect_expired_timers(base, heads); base->clk++; base->next_expiry = __next_timer_interrupt(base); @@ -1738,7 +1730,6 @@ static inline void __run_timers(struct timer_base *base) while (levels--) expire_timers(base, heads + levels); } - base->must_forward_clk = true; raw_spin_unlock_irq(&base->lock); timer_base_unlock_expiry(base); } @@ -1934,7 +1925,6 @@ int timers_prepare_cpu(unsigned int cpu) base->clk = jiffies; base->next_expiry = base->clk + NEXT_TIMER_MAX_DELTA; base->is_idle = false; - base->must_forward_clk = true; } return 0; } -- 2.26.2