Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36915630rwd; Tue, 11 Jul 2023 07:16:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYOTwbzte79xBkrEG1vxfOOXyIvYAnvwwp9J1wa6w82k79uL2AQP0hHNVDcMna+GkTcwlp X-Received: by 2002:a2e:b681:0:b0:2b6:fa8d:ff91 with SMTP id l1-20020a2eb681000000b002b6fa8dff91mr13271459ljo.3.1689084985385; Tue, 11 Jul 2023 07:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689084985; cv=none; d=google.com; s=arc-20160816; b=k9QLTqQAcNdK6ICbzzzsnFpk/s9CckZJJjO2UYqya+Bu/pxk2twhJF7ZS/yfY9gEDG aSDw8cuwT2Klw0WMrXPUZpO17iHnKlKPGwNbTDGUU+Pak69AlELuyIUQWIahudDV/NqA YQZyOAGap7NWuA/miGtl3nKWY6HoaEQsXhI2BaOSPsq0TELTHB35culM4olPyiOxSTYA 0dExLKEZTkOlKkF5eIqAAFYMaegDugNV+2KSeGe5QibgjofMhNtvrQbokRyVI8x4Z7tE hYKeAg/TxtStBgGOebKvNFULxxslIhgoJpUu140svYQSNcJKljWgie+bDvgX45xboldU a4FQ== 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=tK73mQT8AGrD7LXY9K8h9XH696dgpAMIKDD4qFnUUIM=; fh=M2CE1Bvtm1SBXbBqRuDoJxhFdGmfgKZ6ZCCt02Bkls8=; b=oIUTrZfKAOPsG90w9yZJszmF9SLhTJ4q2jOaAUAEA2O2TUfJXW+xdUXUzOz7W7NQow /+POfC3e9AGCZZWwJDNOXzYYHcwjJ7zip6j+oSDYPvRzhb4SNplvHltEYJ7ZTHOC5YAw PSBryT5WgC0d4cVaOHm6jkl8HE8/f0a1ilaPKcfE9NofTY1r9qpD8FBG0vE/rv0VM399 OzkLzJKjwv1x3EOvUHnUVaEa3nXbOFcwn6nvknblJbzXUwe4BawrQ6WRsPkxj8tTRjKg 8ZDShHYTFXnhDAl0TitUz2oawkHFafIv4quzOeJUcSQ2mj4NFaInmG1HhjpFpjIbkPkd ybMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Q/e19YX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a17090613cc00b00987a43ee395si2164573ejc.741.2023.07.11.07.16.00; Tue, 11 Jul 2023 07:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Q/e19YX/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232955AbjGKNL5 (ORCPT + 99 others); Tue, 11 Jul 2023 09:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbjGKNL4 (ORCPT ); Tue, 11 Jul 2023 09:11:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B81851A3 for ; Tue, 11 Jul 2023 06:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689081072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tK73mQT8AGrD7LXY9K8h9XH696dgpAMIKDD4qFnUUIM=; b=Q/e19YX//hm2Jmc/V8y4sfBXX9W8/C1oUx6bslMxeDY0oBIrXzruCINFRXDwmq4O5k+K6y 4+tUgDQD6Fq8/acU6M+FYAs5kImspO07ys4+WOY9ov956ZduliSVfYUNd0h1FyNwBEB8lt 5RuFZ2LQpdYRXvqa1tcu0llgawT7azQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-kfvEwjkPPZeXn96pDhPczQ-1; Tue, 11 Jul 2023 09:11:00 -0400 X-MC-Unique: kfvEwjkPPZeXn96pDhPczQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC4C9887158; Tue, 11 Jul 2023 13:10:32 +0000 (UTC) Received: from lorien.usersys.redhat.com (unknown [10.22.17.109]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9BFE40C6F5A; Tue, 11 Jul 2023 10:55:30 +0000 (UTC) Date: Tue, 11 Jul 2023 09:10:24 -0400 From: Phil Auld To: Benjamin Segall Cc: linux-kernel@vger.kernel.org, Juri Lelli , Ingo Molnar , Daniel Bristot de Oliveira , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Mel Gorman , Frederic Weisbecker , Tejun Heo Subject: Re: [PATCH v5 2/2] Sched/fair: Block nohz tick_stop when cfs bandwidth in use Message-ID: <20230711131024.GA150804@lorien.usersys.redhat.com> References: <20230707195748.2918490-1-pauld@redhat.com> <20230707195748.2918490-3-pauld@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 10, 2023 at 04:54:58PM -0700 Benjamin Segall wrote: > Phil Auld writes: > > > CFS bandwidth limits and NOHZ full don't play well together. Tasks > > can easily run well past their quotas before a remote tick does > > accounting. This leads to long, multi-period stalls before such > > tasks can run again. Currently, when presented with these conflicting > > requirements the scheduler is favoring nohz_full and letting the tick > > be stopped. However, nohz tick stopping is already best-effort, there > > are a number of conditions that can prevent it, whereas cfs runtime > > bandwidth is expected to be enforced. > > > > Make the scheduler favor bandwidth over stopping the tick by setting > > TICK_DEP_BIT_SCHED when the only running task is a cfs task with > > runtime limit enabled. We use cfs_b->hierarchical_quota to > > determine if the task requires the tick. > > > > Add check in pick_next_task_fair() as well since that is where > > we have a handle on the task that is actually going to be running. > > > > Add check in sched_can_stop_tick() to cover some edge cases such > > as nr_running going from 2->1 and the 1 remains the running task. > > > > Add sched_feat HZ_BW (off by default) to control the tick_stop > > behavior. > > > > Signed-off-by: Phil Auld > > Cc: Ingo Molnar > > Cc: Peter Zijlstra > > Cc: Vincent Guittot > > Cc: Juri Lelli > > Cc: Dietmar Eggemann > > Cc: Valentin Schneider > > Cc: Ben Segall > > Cc: Frederic Weisbecker > > --- > > kernel/sched/core.c | 12 ++++++++++ > > kernel/sched/fair.c | 49 +++++++++++++++++++++++++++++++++++++++++ > > kernel/sched/features.h | 2 ++ > > kernel/sched/sched.h | 1 + > > 4 files changed, 64 insertions(+) > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 1b214e10c25d..4b8534abdf4f 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -1229,6 +1229,18 @@ bool sched_can_stop_tick(struct rq *rq) > > if (rq->nr_running > 1) > > return false; > > > > + /* > > + * If there is one task and it has CFS runtime bandwidth constraints > > + * and it's on the cpu now we don't want to stop the tick. > > + * This check prevents clearing the bit if a newly enqueued task here is > > + * dequeued by migrating while the constrained task continues to run. > > + * E.g. going from 2->1 without going through pick_next_task(). > > + */ > > + if (sched_feat(HZ_BW) && rq->nr_running == 1 && task_on_rq_queued(rq->curr)) { > > + if (cfs_task_bw_constrained(rq->curr)) > > + return false; > > + } > > + > > I think we still need the fair_sched_class check with the bit being on > cfs_rq/tg rather than task. > Is there a way a non-fair_sched_class task will be in a cfs_rq with cfs_rq->runtime_enabled and/or cfs_b->hierarchical_quota set to non RUNTIME_INF? I suppose if they are stale and it's had its class changed? That makes the condition pretty ugly but I can add that back if needed. Thanks, Phil --