Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1206283pxb; Thu, 4 Mar 2021 06:09:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1V0i4SXC+IPhPQ5BJzzfNF71DADPngyP/hOsDgDs9hzvN3m8Ix4iXTz0+wJUkWUjVe0uF X-Received: by 2002:aa7:c74a:: with SMTP id c10mr4445921eds.332.1614866987187; Thu, 04 Mar 2021 06:09:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614866987; cv=none; d=google.com; s=arc-20160816; b=P/gqnPKHPJD/t0KulYEPFzhNcA/YqLp60GpBYSvk31tfKut9Ik386rwGo7P5cgbxhN QnPReujRXHiE33uuc2I363/YJMimL2FvXQVKGIfkuvs0Xo7dTJ7/gp4/fNp5Fy9empSe Mv3Q5aB9Cqj63mfptZdMADpYm3GCtMXc4CS2aNKntloAEPCNIvMn7Re4Af0CA841qRU1 VQe/4cM92s1S6B/bDX5xdfT9akrBW2YFceZBKoLBCUqh8450TAXKMNdE9GDDjeUjDjm+ xyELj7LdDWZsfrXVp9CU5I3khJ6G8IGQ2sYnImm/BfbRlXKjSakuHsCGNDCLWI5u2Ti6 /iWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=zHFKNTEqPhfVaBWbZblG4lXg08AU2buzX45YKWwNSVw=; b=u71fJ5RUPqXBKMAa72068Hg1t7WHV92N9hBQrTT9w4kcuzcPfgRKXhlhTi7ToO4AwM OTLWkv3B5h6tkIttMQ0TfECzVD/jyAUKJXyZUEmiFGuPbxV/GIOeni6imAdQa9gyYoyH xBGpOx1ggbnurR7UXC97MBIDY2xkpgdNULjNMoA8lbGLdFqsFG72fLLCJq8Twm92RVK4 BJB+0j/DHoLcvP/yRadD2zVC0m0BFNko2r6kcSOK6g6t/sfsLsqY/upjWLGjS9OrrbXu Z8fYeN5BlBhsOzk9HvcZps9YDZlzCjsbbWnHbjjsZ4TP3iFAX9g0YElr9pkHQhSPyikc 7ENw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dBf2LOju; 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 r24si9949235ejs.40.2021.03.04.06.09.12; Thu, 04 Mar 2021 06:09:47 -0800 (PST) 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=k20201202 header.b=dBf2LOju; 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 S1351182AbhCDBC5 (ORCPT + 99 others); Wed, 3 Mar 2021 20:02:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:45590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355386AbhCDAXx (ORCPT ); Wed, 3 Mar 2021 19:23:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2889464E68; Thu, 4 Mar 2021 00:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614817393; bh=rKqkwhR8fdkTQi124+9qJ6BCRqBuri/f+Mi5cInkd2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBf2LOju5rBf3sP70NdkmLryLTYUp/ciJQ2dAxlSoibx6/Au6IKRaM5pw4s1xU5Zl P8Bm+LMk3OB5VvgBSf/gkALCib6TlwnwVX/zQB7NX6NI8b7RGxKlC7EFBOx46gam48 V1wLUeOeZ1QOef2DxJlXaAGbXoMmbe26LtENcCd8Z2uVBg8wexqsq1VxE7dkiVsWwG 2vNE0z2QvOrc74oAuUEWJq765YtMIz5XFvIGeMCbAjqlx7rW3mLp1LMYhsrAAXTGy9 Lg11CUjQ0nZay7FuMUP7M4OtFJZlc17RAE77PSCtVrA13xcrgGuNry40H+DOiCnDOn NwpjCjHKMYzgA== From: paulmck@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, Frederic Weisbecker , "Rafael J . Wysocki" , "Paul E . McKenney" Subject: [PATCH tip/core/rcu 02/12] timer: Report ignored local enqueue in nohz mode Date: Wed, 3 Mar 2021 16:23:01 -0800 Message-Id: <20210304002311.23655-2-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20210304002225.GA23492@paulmck-ThinkPad-P72> References: <20210304002225.GA23492@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frederic Weisbecker Enqueuing a local timer after the tick has been stopped will result in the timer being ignored until the next random interrupt. Perform sanity checks to report these situations. Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Rafael J. Wysocki Signed-off-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- kernel/sched/core.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ca2bb62..4822371 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -674,6 +674,26 @@ int get_nohz_timer_target(void) return cpu; } +static void wake_idle_assert_possible(void) +{ +#ifdef CONFIG_SCHED_DEBUG + /* Timers are re-evaluated after idle IRQs */ + if (in_hardirq()) + return; + /* + * Same as hardirqs, assuming they are executing + * on IRQ tail. Ksoftirqd shouldn't reach here + * as the timer base wouldn't be idle. And inline + * softirq processing after a call to local_bh_enable() + * within idle loop sound too fun to be considered here. + */ + if (in_serving_softirq()) + return; + + WARN_ON_ONCE("Late timer enqueue may be ignored\n"); +#endif +} + /* * When add_timer_on() enqueues a timer into the timer wheel of an * idle CPU then this timer might expire before the next timer event @@ -688,8 +708,10 @@ static void wake_up_idle_cpu(int cpu) { struct rq *rq = cpu_rq(cpu); - if (cpu == smp_processor_id()) + if (cpu == smp_processor_id()) { + wake_idle_assert_possible(); return; + } if (set_nr_and_not_polling(rq->idle)) smp_send_reschedule(cpu); -- 2.9.5