From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94141C433E3 for ; Wed, 24 Mar 2021 09:39:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B14D614A7 for ; Wed, 24 Mar 2021 09:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232552AbhCXJjC (ORCPT ); Wed, 24 Mar 2021 05:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234676AbhCXJix (ORCPT ); Wed, 24 Mar 2021 05:38:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79491C061763; Wed, 24 Mar 2021 02:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tlE7gowY/JQvvN3vtmtqL6YeVObw7oIr+DM32xIg/4Y=; b=XkqYGWPk0EUc5bSZ3l+Kc5nPkc iCpQ2LXg/+3qkNv0scwWgEOoYOR/CaoN3QS3qVi1+mUfpEJ97L+AEidMtRlKhXyWGv+8I/BS+lNbT T7ppwLh6I/8nvMItbFSjaIZaPW3q+Pq72q1cAXcTwhSzMXqKb3YoxZMp62dR+azkLVSUbBTT6NIc0 xk1jnCcFJS1+tW0COcVBLpBDkGhUKaiu6oliOkCAEcJ8zpm93dSjNp9PQQcxYhsqL6K12heT39tb+ nXtSsRhyHg3ae1gteczsIW4zstzlPhzurKJ3xkfLx8C/n+q+VfBIb9OngaB4hRKDpiw7BSoMvZkqb SN895ErQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOzxQ-00BCbH-AP; Wed, 24 Mar 2021 09:37:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 231093007CD; Wed, 24 Mar 2021 10:37:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 049B1259421CD; Wed, 24 Mar 2021 10:37:42 +0100 (CET) Date: Wed, 24 Mar 2021 10:37:42 +0100 From: Peter Zijlstra To: Josh Don Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Rientjes , Oleg Rombakh , linux-doc@vger.kernel.org, Paul Turner Subject: Re: [PATCH v2] sched: Warn on long periods of pending need_resched Message-ID: References: <20210323035706.572953-1-joshdon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323035706.572953-1-joshdon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Mar 22, 2021 at 08:57:06PM -0700, Josh Don wrote: > From: Paul Turner > > CPU scheduler marks need_resched flag to signal a schedule() on a > particular CPU. But, schedule() may not happen immediately in cases > where the current task is executing in the kernel mode (no > preemption state) for extended periods of time. > > This patch adds a warn_on if need_resched is pending for more than the > time specified in sysctl resched_latency_warn_ms. If it goes off, it is > likely that there is a missing cond_resched() somewhere. Monitoring is > done via the tick and the accuracy is hence limited to jiffy scale. This > also means that we won't trigger the warning if the tick is disabled. > > This feature is default disabled. It can be toggled on using sysctl > resched_latency_warn_enabled. > > Signed-off-by: Paul Turner > Signed-off-by: Josh Don > --- > Delta from v1: > - separate sysctl for enabling/disabling and triggering warn_once > behavior > - add documentation > - static branch for the enable > Documentation/admin-guide/sysctl/kernel.rst | 23 ++++++ > include/linux/sched/sysctl.h | 4 ++ > kernel/sched/core.c | 78 ++++++++++++++++++++- > kernel/sched/debug.c | 10 +++ > kernel/sched/sched.h | 10 +++ > kernel/sysctl.c | 24 +++++++ > 6 files changed, 148 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst > index 1d56a6b73a4e..2d4a21d3b79f 100644 > --- a/Documentation/admin-guide/sysctl/kernel.rst > +++ b/Documentation/admin-guide/sysctl/kernel.rst > @@ -1077,6 +1077,29 @@ ROM/Flash boot loader. Maybe to tell it what to do after > rebooting. ??? > > > +resched_latency_warn_enabled > +============================ > + > +Enables/disables a warning that will trigger if need_resched is set for > +longer than sysctl ``resched_latency_warn_ms``. This warning likely > +indicates a kernel bug, such as a failure to call cond_resched(). > + > +Requires ``CONFIG_SCHED_DEBUG``. > + > + > +resched_latency_warn_ms > +======================= > + > +See ``resched_latency_warn_enabled``. > + > + > +resched_latency_warn_once > +========================= > + > +If set, ``resched_latency_warn_enabled`` will only trigger one warning > +per boot. > + > + > sched_energy_aware > ================== Should we perhaps take out all SCHED_DEBUG sysctls and move them to /debug/sched/ ? (along with the existing /debug/sched_{debug,features,preemp} files) Having all that in sysctl and documented gives them far too much sheen of ABI. Not saying this patch should do that, just as a general observation.