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=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 21D14C4332D for ; Wed, 17 Mar 2021 08:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 002BE64F99 for ; Wed, 17 Mar 2021 08:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbhCQI0A (ORCPT ); Wed, 17 Mar 2021 04:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhCQIZz (ORCPT ); Wed, 17 Mar 2021 04:25:55 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A5DC06174A; Wed, 17 Mar 2021 01:25:54 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id a132-20020a1c668a0000b029010f141fe7c2so643950wmc.0; Wed, 17 Mar 2021 01:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XlkVO6VFXg55yuEE9nnAKjJmnNqPrYchZV1BwfG3vEE=; b=Jam1UbwprzCXzzWEp+LYot8Zkf2BvneeSOULv9A/8hivTc7bJiuQdj2Lye7Ncn1/hI yOWrgSsCJPKI81KEEUxt0cNhLIDhTj0zuXCAfSmKkjBEhq/C8C9n3RgPI4d7yTO3wndo SRpue61U3aUFu2FhbI3SHxQseZdkr8adguroFIxHEuAIcmAmg/7dOmJOH2b+Ixr0J/P3 ilvdZXLP2uU7J6LoVy0R2mZkzrKnw58IZdkF3qQUtiHOkTjKgi3qKEmJmHn5XqMHbvfY N9p558Mq3y/NlUET0mSgzuidFT9a7hGdiIfF25p6Q9tUYowSVA7wuIPq+X5W93N2bv51 cZiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=XlkVO6VFXg55yuEE9nnAKjJmnNqPrYchZV1BwfG3vEE=; b=P9VnCa8K5jKGbNowbz2UWCFST58eZ/NK/SrghSuhcrC5GYm+WvF1+R08JKsflK0Qis 40AtvYmY6fErHBzg2hr70KY5g4EVa7ZKVeUy7kIJWl++/WIYSIC0sh0nvAOdMvw91t12 5kpcrZ9YRpZXF1SLkPRURZOv/Ea3MZal2cxh9zAsghiWXHOTPPPqoBDDX95DhXzbJx+U q/FlxAwEsO3rf50tQT4471nx6Ye9O6dArUGntnbr8eNLqxYseNoBHRWYSGXWtUgIs7Kg ANH3AmLc/6zgz9mt58c4CISlSSOd7s8DkuQTM44goJebkN/QiP5dh/LgSrSE8wmChPjs oTqA== X-Gm-Message-State: AOAM533X6DnO0eZXmOKO8BnuHPUV32rWgeR0o9Yq5xSy70DV2mFlIHRe bT7xJYn6dQa952PKhugSlmQ= X-Google-Smtp-Source: ABdhPJyYp3dTaFQrggmXs8bfJj/VA/D+NPW2wY1Vxyf4X9WNVm/dAfNNvAW3+3t1iix/uEqsIqtUMg== X-Received: by 2002:a1c:e184:: with SMTP id y126mr2514928wmg.163.1615969553494; Wed, 17 Mar 2021 01:25:53 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id c6sm285377wri.32.2021.03.17.01.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 01:25:52 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 17 Mar 2021 09:25:50 +0100 From: Ingo Molnar To: Josh Don Cc: Ingo Molnar , Peter Zijlstra , 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 , Paul Turner Subject: Re: [PATCH] sched: Warn on long periods of pending need_resched Message-ID: <20210317082550.GA3881262@gmail.com> References: <20210317045949.1584952-1-joshdon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210317045949.1584952-1-joshdon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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. 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. Looks useful. > If resched_latency_warn_ms is set to the default value, only one warning > will be produced per boot. Looks like a value hack, should probably be a separate flag, defaulting to warn-once. > This warning only exists under CONFIG_SCHED_DEBUG. If it goes off, it is > likely that there is a missing cond_resched() somewhere. CONFIG_SCHED_DEBUG is default-y, so most distros have it enabled. > +/* > + * Print a warning if need_resched is set for at least this long. At the > + * default value, only a single warning will be printed per boot. > + * > + * Values less than 2 disable the feature. > + * > + * A kernel compiled with CONFIG_KASAN tends to run more slowly on average. > + * Increase the need_resched timeout to reduce false alarms. > + */ > +#ifdef CONFIG_KASAN > +#define RESCHED_DEFAULT_WARN_LATENCY_MS 101 > +#define RESCHED_BOOT_QUIET_SEC 600 > +#else > +#define RESCHED_DEFAULT_WARN_LATENCY_MS 51 > +#define RESCHED_BOOT_QUIET_SEC 300 > #endif > +int sysctl_resched_latency_warn_ms = RESCHED_DEFAULT_WARN_LATENCY_MS; > +#endif /* CONFIG_SCHED_DEBUG */ I'd really just make this a single value - say 100 or 200 msecs. > +static inline void resched_latency_warn(int cpu, u64 latency) > +{ > + static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1); > + > + WARN(__ratelimit(&latency_check_ratelimit), > + "CPU %d: need_resched set for > %llu ns (%d ticks) " > + "without schedule\n", > + cpu, latency, cpu_rq(cpu)->ticks_without_resched); > +} Could you please put the 'sched:' prefix into scheduler warnings. Let's have a bit of a namespace structure in new warnings. Thanks, Ingo