Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp368824pxf; Thu, 25 Mar 2021 06:10:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0drjXAh6ePAgiKMcojZUFhs+Y9oJAMjDthvomTHPrM2c5nZ+inmErojh4KzQF0tea2efT X-Received: by 2002:a17:906:ecb8:: with SMTP id qh24mr9681939ejb.162.1616677818595; Thu, 25 Mar 2021 06:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616677818; cv=none; d=google.com; s=arc-20160816; b=0Ku9LGMoRdzV+v6CA8gRPBXl4cTkAMSx/hixuxMXp5RUXopIqGzPTuHPBDyppP7oZJ BEf9XYhIz57/Rik/nYYwJ3lZeQjckptPkSFQUsqh0aQVvm6fgEgaSJO9mf2+fK6aQcLB bSohc3s5fz4nn8KJ98779qiNc5A6HFAvXYhLePy+x0k2Sj1R9BCo4JmYNuDwM+EcsiPV ObBcwDWmZ7JMVIXW/e+Ebu4govDpWgjerZnkZfHb9SkfJUmPt91t96K4aVnaBtfKvtVk MaFdgF/YDBOSle+jWijEsUvs7MRxHsa6npLAIvC7xgtS2CP4Gk+Sl3qA6Y3jJqFVYsmU vbFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JEiGEHdT8DDnEHTAONAa7RLOATr2Y6mteZ2USznbGz4=; b=gNQilbEWY8AK/yiqcn/5YUvJn6zEPVGZM3iCToObIOIZO6bpU5DLtPUzrBa8HPggOA TjK7VFkbcNmz7qffdN8AOw2u+K9pexNzUlmbre5smO8AKs8mhIl8jvhV+ulzsOtEu/tV GcvSvME8PhRP+5W3Zjg7rxpjzBpo6TGrp1SXvX0muP1OfG1Q/4pZE7cNlnS+eGln9kwx NiF5iDtKfA64/fu2RvO982EUqk8+5+9KWtqn6HnuB9bB1K48DU8GBt5QvjgYKQx+oUcc 4ivvgZ16cT9/Ww4lymNNDDUxHTvJVo/tyu1gDZkb/mKh88mN8gXADrvfBDhUqqKWYHT7 mkFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAoN7G0X; 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 f2si4206445edn.109.2021.03.25.06.09.54; Thu, 25 Mar 2021 06:10:18 -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=k20201202 header.b=aAoN7G0X; 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 S230281AbhCYNIl (ORCPT + 99 others); Thu, 25 Mar 2021 09:08:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbhCYNIC (ORCPT ); Thu, 25 Mar 2021 09:08:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A4ACA61A26; Thu, 25 Mar 2021 13:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616677680; bh=ay7jHy+IN5DJK2Ax+Lw0U4zg5VZ6z8995EDoxgwUap8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aAoN7G0XPC2i3xWqxeozi2xY6sA83W+izDswsLNWoRZfjY4ZabKMWBtyMm9b2L+3j B7PFDYPOCKXTj6M5lSwXdXNvNx6jbaqH1Fzsx3cCpFIpafCVZcs8jqogPqFyBXGBNm l4TNQ5IfRrN/zs5cCaNYJ++K0/u9R5rIU0W3Fk1uU1jXjfWjL+C2j1wxE6iI76+g3Z RHt8vtT3GXaXeMLAaTXbaX+DrMR4NjbKYUPERO/q9vvPrExQ3LQOZwXAqnMB5aXtix Yj5pcmfB6OM7ekwaFFPF/8Q4nyvY3LcM7Jth2bgXFFsk+cOHmYn5NKGmD1Rfhnh0uB OD/nqMKoLlPcw== Date: Thu, 25 Mar 2021 14:07:57 +0100 From: Frederic Weisbecker To: Peter Zijlstra Cc: Thomas Gleixner , LKML , "Rafael J . Wysocki" , Ti Zhou , Yunfeng Ye , "Paul E . McKenney" , Marcelo Tosatti , Ingo Molnar Subject: Re: [PATCH 06/10] timer: Report ignored local enqueue in nohz mode Message-ID: <20210325130757.GA938196@lothringen> References: <20210311123708.23501-1-frederic@kernel.org> <20210311123708.23501-7-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 04:27:56PM +0100, Peter Zijlstra wrote: > On Thu, Mar 11, 2021 at 01:37:04PM +0100, Frederic Weisbecker wrote: > > 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); > > I'm not entirely sure I understand this one. What's the callchain that > leads to this? That's while calling add_timer*() or mod_timer() on an idle target. Now the issue is only relevant when these timer functions are called after cpuidle_select(), which arguably makes a small vulnerable window that could be spotted in the future if the timer functions are called after instrumentation_end()? Thanks.