Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp192378ybt; Tue, 30 Jun 2020 18:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwathixJNiWz6EAt8kNZbaYwTIy1BxSRpsgY+gEmx6JwY6rLEBufboMT1mTswDPLEdlSnOM X-Received: by 2002:a17:906:57c6:: with SMTP id u6mr20226905ejr.194.1593565934687; Tue, 30 Jun 2020 18:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593565934; cv=none; d=google.com; s=arc-20160816; b=qyNHXnKL1kZmnTHH5RnlNweKo2r+CKrGm6uJE8DBrwo1fbaPr7ExfwMO0trKNHPxow aFz64CcSDBY2YWwuOIsQhZKv2ajTqJdRYjxuS10h/ziyLdZwsJVNTacm7zyXyl1vuz0W 8B88KQtCBSGcooQi/dfZoiq/vSXP0vVpdJwE7hyaf0ZGFiR6SqNVAkTy0NMvjuXS+KAa ZpGsJrLcuKG+wD3KRUBXC9L8wLifs6bYxpbSvI2NX29UnwvG2PM1Xiy2rbvWXX1G+hac ljUZWXM/F2uIQIkuuAvCSstPoEdyrIHGEZvOcIKwobE1tMLBSVyqhnj2fJ+QgrSYoxM3 z0/A== 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=/aWrx4xfqeB/084LIU4B0Gpma4UOpAlESNcPfLNS+Ak=; b=QQIJ+g0wSd+N1ds1hwAC2eCPKAkNCaFNPQLB0EsYc5JLuVQKqq51R4c7FLzAkOXQP4 dtyeVAMGHeHADlnUdEGDz0vzwxgyp5QgF7iXySxrq3g+LDa6Rb/dWcLzWdqZhsiOsk3W pI6pnD8WPy2yo0w9fRVEvh8C9Lb8U2FiJ4ajvQc2q5FYI+u1N8Quw9MBd0e8l8kpn/0S qnFlpIrvpMHF821Zk8PHGWZQCJHz31QyCFR5EB4CPqOXqTzoMHYS3qvDNQHhA+BEUN7Z U7ZQ076oSttipkkWK9jg77Sf02ZGDeL6eFaqVk50VYLwFsnSuDY4yxIiHACOGcBW7Nb+ RzPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jRiNtFGL; 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 l2si2846693edk.332.2020.06.30.18.11.51; Tue, 30 Jun 2020 18:12:14 -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=jRiNtFGL; 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 S1726791AbgGABKx (ORCPT + 99 others); Tue, 30 Jun 2020 21:10:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:57152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbgGABKv (ORCPT ); Tue, 30 Jun 2020 21:10:51 -0400 Received: from lenoir.home (lfbn-ncy-1-996-218.w90-101.abo.wanadoo.fr [90.101.73.218]) (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 2AB2620781; Wed, 1 Jul 2020 01:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593565850; bh=TkNGgrqX4DuoPRYiKCidraOvpBZ4CbPraEJ/I0LaPyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRiNtFGLBYAD1ceOu7EAcw7jxUF/h1Ttyyc5IBKihSkH1ccgg0O24b3asC1GfqCxY wNCBaM2fjKXE75uxitiaco25IV3Jivdi+V1g7c/hxXz/BE5yh813x81aVVuq6j81EA PiuKf+vvm6JLWOkbAJgjrrxFrVhVJahJuTKhLTNM= From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker , Anna-Maria Gleixner , Peter Zijlstra , Juri Lelli Subject: [RFC PATCH 09/10] timer: Remove must_forward_clk Date: Wed, 1 Jul 2020 03:10:29 +0200 Message-Id: <20200701011030.14324-10-frederic@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200701011030.14324-1-frederic@kernel.org> References: <20200701011030.14324-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 95f51b646447..439fee098e76 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -204,7 +204,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; @@ -877,12 +876,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; @@ -1713,16 +1713,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); @@ -1730,7 +1722,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); } @@ -1926,7 +1917,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