Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp248103pxf; Wed, 24 Mar 2021 04:19:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWadr8pm8IV+4kVwYt2c8hkh8uvLoqF5YV9EuasdbXZZ8bE/L7T7zBwIQNQRdUXd+O7Mu/ X-Received: by 2002:a17:906:4d8f:: with SMTP id s15mr3120846eju.350.1616584758240; Wed, 24 Mar 2021 04:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616584758; cv=none; d=google.com; s=arc-20160816; b=p7BqhfdlRW8qeVfQdtshV7dp6BZZUgMQhdKE/+JsWRH9fSvf5DWFSN27VdNRTePwI/ VGnFsXaXVRM+2AzzeYPGmKKW2nXTYpep8sbeBuK5gmInIsXc6cvxznhxgesOexgEZxam 9Zv/kLF4JpikoYHKpCJ+r9qn+Pfaa867OoI/qELdZq58TwDa0KXcOnLYIJNOCjsKLxP/ MFJ3jiDaerz7anL8dLZH1So8M8g/N3j9Ee88b4NDMeNvUfxu6b509YjjFQyiw0w+0YPg KZcGFLvXDCxDpZYXOfbBgUv0b1hO1xTNV+LkqtaPKf4rqkWqkYbxeebh4Vk3tJF9O+Ua /xNw== 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=tlE7gowY/JQvvN3vtmtqL6YeVObw7oIr+DM32xIg/4Y=; b=hmH7cVWt4e4KkFpVhPYrdY/+QqrVV/Q7tAHq9/qjmxsyWpoFZjzT/jbeHfId9TCSVw HRAFB3aGGDjapbNPS5qe7bRqbqUcEaeydoGKaT8UtCvzbu11BhXpSTAMZ5lma1Tq+fK1 U6Yn79bZpX1uWYXU92FQ9UQ+YnMI5YMGtUxnNjBW3Z5dblvGcrjfvbCv2KUIRhXu0KJp dtWVUrifxip9pa3BV1MIVzH73fL3mf47m1U6q+gpDtwD0OAJkY215pUoyupj30U4Ac7m i96W+kzE4bLPnlCH02+V9fg8o1tsylGvjhyeo2VLKPbPxP0TOlp8lCQ0Q9VTld3ER80o Zi1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XkqYGWPk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si1511264ejb.465.2021.03.24.04.18.55; Wed, 24 Mar 2021 04:19: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=@infradead.org header.s=casper.20170209 header.b=XkqYGWPk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235083AbhCXJjE (ORCPT + 99 others); Wed, 24 Mar 2021 05:39:04 -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-kernel@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.