Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1221503pxf; Fri, 26 Mar 2021 03:48:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK9lCfscqhTqIXKn0CBz/KRXnP5p61jtV2Fk40DphOuXciRSnsk+9PwpviJl/sLE2Zx0Y5 X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr14121273ejb.264.1616755706638; Fri, 26 Mar 2021 03:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616755706; cv=none; d=google.com; s=arc-20160816; b=Xm6Au4oITafbgQrzxS5L71mpb5O+12/z8l/PO52erYDbpc1GrZthb+MNZ7rpf6qMnq Gm44LWIjEVKeOFzR6UZeQ9ld8uTmA+lKIJkYehwyOXx2wQd1zAk6FM8J78DRVRavjo5k cB3Wb2lpcXFjZ3IV1LRbDUZkppU/d+9B2HoOiWq7nxLOvqU/xHWuZpSKn81TryerUYfp R8pgJ50URnFVDHBbwt5aAK+fmJ9c0uKwepO6d23gnRtq5VYlsg73hLbjExAyXe8CGypk YK0LBxdZRQ4/BLII4uT1E1Xc7IpEs3Hh8u0lyPtOpyQRZ4T3y4YC2ko4WhEaXysBYtT7 dVBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=hK/R59Nh973XhTXjUjNFL5eml1I+OYJPEGxK9I4f5RA=; b=tCMfF2VL6ZPVQFy5RADa+UeIFhw+Knz8WQj7RGofqceVYareonC4G80XZNq8kzuij5 GFHgbhhpBuccQqsSAmwBiRGNZqVHRhg7bI6m7A44B1VHPilZrk+6IHLfaGe0QV3rhUIk 4wSdOOMAUD6vKvPMEufo4peJLskImxhhb1PZGHj1opWc1KGMuECsznMbcj7lQeCr3iTA tFYB7mCpOCfFHh3oJCWEq0YP+VhfY6oL58CA27NFfqnHWs89P6m9ompUaM72QQjkkHN0 pgG/1B3tLznb6XEpssFmCouFD6KgpKH2ozwrn/9gHeM0umHTR8r5hTHu6MN3DfW+sN/Q +Ndw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=C72vEYW9; 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 s17si6742873edx.88.2021.03.26.03.48.04; Fri, 26 Mar 2021 03:48:26 -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=C72vEYW9; 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 S230166AbhCZKoY (ORCPT + 99 others); Fri, 26 Mar 2021 06:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbhCZKoI (ORCPT ); Fri, 26 Mar 2021 06:44:08 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D1FC0613AA for ; Fri, 26 Mar 2021 03:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=hK/R59Nh973XhTXjUjNFL5eml1I+OYJPEGxK9I4f5RA=; b=C72vEYW9221SOS84RLRZCYe6WY +0xmw9yYXk44hLDmB2+pSlby49le2eZ2LZSbl1bmh4yLrnlNugTBtb++u7L5c4csPrl9+13+B87dK 7QUhlw6FnDxOdSxFkRoSqu3ceiVrzdHJgAnvYgtjd+WmHG/Mxd+EP6rokZaCKGVxnLiZhAAjOw7Oo 3kjiPuy4UFsC0Q+oeDlmEJPRW8fpmq1+iBu7Gmclhyw7lHI9dabynXuQLSJf7WhMwyP1QcEINGTtU OeGBDTHksS6ohugFGGxm0B+yzdNcOqmlH5Cyc1iSDLTqQ8wiq4RUFhJaaEOvLly4uT/RLc3YFB4ec FrPxpKuA==; 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 1lPjvF-00EgYX-VM; Fri, 26 Mar 2021 10:42:55 +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 5394F3077D7; Fri, 26 Mar 2021 11:42:32 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id D00732BD73361; Fri, 26 Mar 2021 11:42:31 +0100 (CET) Message-ID: <20210326103935.444833549@infradead.org> User-Agent: quilt/0.66 Date: Fri, 26 Mar 2021 11:34:01 +0100 From: Peter Zijlstra To: mingo@kernel.org, mgorman@suse.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, joshdon@google.com, valentin.schneider@arm.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, greg@kroah.com Subject: [PATCH 9/9] sched,fair: Alternative sched_slice() References: <20210326103352.603456266@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current sched_slice() seems to have issues; there's two possible things that could be improved: - the 'nr_running' used for __sched_period() is daft when cgroups are considered. Using the RQ wide h_nr_running seems like a much more consistent number. - (esp) cgroups can slice it real fine, which makes for easy over-scheduling, ensure min_gran is what the name says. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/fair.c | 15 ++++++++++++++- kernel/sched/features.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -680,7 +680,16 @@ static u64 __sched_period(unsigned long */ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) { - u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq); + unsigned int nr_running = cfs_rq->nr_running; + u64 slice; + + if (sched_feat(ALT_PERIOD)) + nr_running = rq_of(cfs_rq)->cfs.h_nr_running; + + slice = __sched_period(nr_running + !se->on_rq); + + if (sched_feat(BASE_SLICE)) + slice -= sysctl_sched_min_granularity; for_each_sched_entity(se) { struct load_weight *load; @@ -697,6 +706,10 @@ static u64 sched_slice(struct cfs_rq *cf } slice = __calc_delta(slice, se->load.weight, load); } + + if (sched_feat(BASE_SLICE)) + slice += sysctl_sched_min_granularity; + return slice; } --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -90,3 +90,6 @@ SCHED_FEAT(WA_BIAS, true) */ SCHED_FEAT(UTIL_EST, true) SCHED_FEAT(UTIL_EST_FASTUP, true) + +SCHED_FEAT(ALT_PERIOD, true) +SCHED_FEAT(BASE_SLICE, true)