Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp149412pxf; Wed, 17 Mar 2021 01:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbKvvchoIfJJqjJgI9wHnHlGx37t4uLsc4hQHH9XR3TnUiqsVBuEa+GJ207/YoE2YClNhl X-Received: by 2002:aa7:cb4d:: with SMTP id w13mr40842185edt.249.1615969769746; Wed, 17 Mar 2021 01:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615969769; cv=none; d=google.com; s=arc-20160816; b=AgHTcZocG4n9K0W0AH9MsoKKmqCYa+8JCl3XffvZrqhe11tpfQAP6eb85FZAT4Q43K fkUC+eXbm6tv+TWWezvZFXqM4KZhD7CMZpo81T+ksmqS6NWAniLeYuJeaXkdKwchrHl0 qS5E658bVmBruLKCA4ag/5kGFqKGa0qj/HWEdp0YhbzbGfodTLoEIo/FSgLYbShQMV6R +G0Aemzr0ln9c8D9O5/hsfm/6FTqrzGbXMYdxNPi7pk2oE0+DufuMEWZNcD4O5zU3eAz RYWz2DwxJVCA5QlcKkou4Dzc22rGQbtPuFCQZdplEh0NZeaxM8K90Oe0WO+O35BNgYRF ltEQ== 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:sender:dkim-signature; bh=XlkVO6VFXg55yuEE9nnAKjJmnNqPrYchZV1BwfG3vEE=; b=bHY6sGqdNd7aVncOcervBQlqMbrJrHLASL6lNOTqzMaskJVWS6TVNwe6K+XNQKMAE7 0hxSEHULgQqHt99iVIIigBnKA6lW7sAF6VoCIVTvep9hMJfT42cuP7IlhJO2kKcDH+5K oPGXNTUyBtDjrV+aKqM5YfMl6iEw2lzHChwSya2kmSojd1xpiJhDDE5kTByjRFQQgb4C uLt62B+5+HpPTbTeQlLt3gVR6CjDMV6dmidXxmiGJi3JwPsOvJF3cp3fxmmWK2ywwOI/ zwlDNOMucbSuKItYSrDYrfxlTIH9Kqf0bFGmYRQH5tZnIOz8XhUDStp/97c+kTkmP/oI 9FHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jam1Ubwp; 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 f26si16022493ejr.164.2021.03.17.01.29.07; Wed, 17 Mar 2021 01:29:29 -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=@gmail.com header.s=20161025 header.b=Jam1Ubwp; 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 S229717AbhCQI0A (ORCPT + 99 others); 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-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