Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp312618pxf; Thu, 11 Mar 2021 04:39:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDDXtHLA/aWJo0FEpdrxMkYks4P3uR9pRMcXjouyGXSjtZDhsaBPykrk9JOqHUQHh+RDAN X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr2904833ejo.247.1615466378228; Thu, 11 Mar 2021 04:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615466378; cv=none; d=google.com; s=arc-20160816; b=MbDRYfO2+MZGFtUSY5WVzwufBaqx9SL3gpFsPwlC5vmpLc/1p4yts1ur6TZ6uvM/9c LzJgjGW2gstcVwFdjHclUJyE4Kuf3NPqvFVpkgki/+PFLb4JoWc0rZ1Ln/ODSWnkbgYt VDtwl7mWm3vRVX1xT+cGE/ZhCq+/KFJbI8ZTwPJXjFuMEMUwXfJG4r7LphRvDT7cmFA4 U6aAiygubrKcIUB7s9JM4HOI1yaj09DI2MNK54tMv/WUjv89xUsYV6b4KeYqa3KY3qw0 rvWSC+W15y+PiV/n6dhU1sB0hepp+CUJi7nFRWMq7KF56CMlXjWJnbfhIE/umfyq+0j/ 9bOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2S5Px80SiYpsbXXhuUIo9FI4WmaP6Dcyw1HfiQM5kc8=; b=vjsot+kBpDRK/NxbU5B+nvMQg5+M5XGWMhA9gnhVgng1iHRp1FiAK5MNJdHG+SBpfB 3IN/g3OoRU74cb2FvXvtpXhktSolOm6A9AE+TFOeJLm8Ia2xCOTjRLy+ID5oKLq7qpAS 9+QbH7huxfGmoFlaELg5OQiz0atB2YcqDEnuoAn6N94jMfCrIpCkCmDoZ/pkm1cQnCQp XdBiI2bv2YR1u1PEa4J7Hov2u1mwszlEqlzEwZn4Mb0Wc4uwiCFGw3wHhb15lQOW4wtD 3GTb+4YcIFv8+eIS64hmbXtVsDVz3WEAlenCg5Th/VfthTd7rsCgkzoFy2/gU78oTZRS crhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D8SgpFKl; 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 x4si1882194edd.118.2021.03.11.04.39.16; Thu, 11 Mar 2021 04:39:38 -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=D8SgpFKl; 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 S233370AbhCKMiE (ORCPT + 99 others); Thu, 11 Mar 2021 07:38:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:59878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233155AbhCKMhb (ORCPT ); Thu, 11 Mar 2021 07:37:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 042A964FE7; Thu, 11 Mar 2021 12:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615466251; bh=8ELDtlVQiqEuL1suAV+av1PZS+HMDd8m28xNQesUPg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8SgpFKlTs70Z1OIaiCAJpQO+kVAv0X/ccL4B04KkwdtPZ5WdN5coqwMHcyxZfa3z a72oi9VPWEmfTOoedO0ERZf1T7QUqh4GlVGACE9dQbev53XYWhxbLJ/u7kIse250mx ftMJr9nfnYhXrTw2n1Mw0AisfZtBAoRa9UBStmgsh4O4V4ls4Y5yu3pXNcSeXvbQsI ed5pmSWM0Vt+AtEs6xTnKWg91ytAf0wPmYawfMdYPaqT9otZk83xkSF3nj+TpHyLUL eJc6w1eZBfAq86mBOeO5jriJENM/rWuEFL7uiHQ9pJunedTlMFak0oxddRBlzyzjLw WlnUfzz0jJBfA== From: Frederic Weisbecker To: Peter Zijlstra , Thomas Gleixner Cc: LKML , Frederic Weisbecker , "Rafael J . Wysocki" , Ti Zhou , Yunfeng Ye , "Paul E . McKenney" , Marcelo Tosatti , Ingo Molnar Subject: [PATCH 06/10] timer: Report ignored local enqueue in nohz mode Date: Thu, 11 Mar 2021 13:37:04 +0100 Message-Id: <20210311123708.23501-7-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311123708.23501-1-frederic@kernel.org> References: <20210311123708.23501-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Rafael J. Wysocki Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Paul E. McKenney --- kernel/sched/core.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ca2bb629595f..24552911f92b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -674,6 +674,22 @@ int get_nohz_timer_target(void) return cpu; } +/* Make sure the timer won't be ignored in dynticks-idle case */ +static void wake_idle_assert_possible(void) +{ +#ifdef CONFIG_SCHED_DEBUG + /* + * Timers are re-evaluated after idle IRQs. In case of softirq, + * we assume 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. + */ + WARN_ONCE(in_task(), + "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 +704,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.25.1