Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2780744pxp; Mon, 14 Mar 2022 05:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqZZq3GzMksnsjBvEtddkfxzsdiEXva176RElNdsspyqSRP0yRrFEtc37uMTGydr8D3eaM X-Received: by 2002:a05:6402:40cc:b0:416:d191:54fe with SMTP id z12-20020a05640240cc00b00416d19154femr14736106edb.380.1647259219899; Mon, 14 Mar 2022 05:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647259219; cv=none; d=google.com; s=arc-20160816; b=WC23LY12i1l3/y5qbOMsrjdzFhZvPxPxOUaIKgKrYpwdyD3MPRvCYl4yVwROS2yyL3 JtNK3FUtkzXsyQFsFJTQB+Mdsr3T5Pki7xn6KudRC0nlXLpSeEyxY2/v9D7rFyAl4L41 OLQzh8mnqmw0pDM+t2I8sKmZHo8HBGvCZco9JHBNccpzkHNhWs/aV1vk3eTC2HmLUGYl kLeXmlBD/CkQ6vxhHPK5ZbrOBYMBbbjQdWN0gN6wIRNDouPkkB0fz79bMkuKQ5gLFZ6Z IGnq4PJ05TVHQ9hlPAPc1k3sZsCLzu0tBIX5Un71ye6f6HHfIdLlNl5agyCVxygXM0zc FI5g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nnIwhci8XuuNrQx/+8PCV7USY7XxobulnmlQDzHN2IQ=; b=m8M5hisgo+h0+ybFMIsPpqU1+HcSqJUpyx9fB4f/tRqScfoiOJyD8UpaD9gn6V8iNw 7nubWEx8nSHIDmUdekfiDUBeTwIM8vkwbPbV1l8M1SCenqNcNogIeoM0XRmIuJnEn41E e+kjCEV2FTHdiWzleNZX9S7uomDzIfkc96Ga/7B5OiAoAWpXoEP/pe5NQy57yWl2zkvP rYtO0p9kfVgCkI9CU44il9cWppUdrtdUfyL9oGUq2KFk7lRexgqIxK+fBgz9HfB5e51d OfFgUv4CQOYft0ilFhGj0WwVeA8girBfu+zre2RZv5T7v8mi70acXvVtOuuOTuPUZE4H izcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=KAIa3WJg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm5-20020a170906c04500b006cec1b480basi9342889ejb.328.2022.03.14.04.59.54; Mon, 14 Mar 2022 05:00:19 -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=@infradead.org header.s=desiato.20200630 header.b=KAIa3WJg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232210AbiCMJDp (ORCPT + 99 others); Sun, 13 Mar 2022 05:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiCMJDo (ORCPT ); Sun, 13 Mar 2022 05:03:44 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BE8BBE34 for ; Sun, 13 Mar 2022 01:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=nnIwhci8XuuNrQx/+8PCV7USY7XxobulnmlQDzHN2IQ=; b=KAIa3WJgXPh2/MlA00OJCcAr5+ R8OSxKAtAu5bmfdEiRQ0z1/2bFwMJtrofExPuQgxSHvHfwG7wX1i+eO0za9Z67PNg+LOrmDkyCJkT WzbSXELw47fbZcUmtJvNCFNJNzyCKp+S6eysvNEqhUXau3t3KYJcFoklVtVanqB34xdci5lcY0Z/M 6g3ckYNTUh2/fcUeDzYKnAOElXS6+U0zXmi+jp35NbHAK8Vx5UTcQYZcrfJJQctc94DNQ4NTL/T6m rp0oPDOXQEguEinHsRx0T7kl5CRcugqvHHCl9bIcsmuoZyfzLqHF1fFJyrnup0nBC9RE6Et/fiOeE SD/UvGsA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTK7K-000TXJ-IO; Sun, 13 Mar 2022 09:02:22 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 72B33987D0D; Sun, 13 Mar 2022 10:02:22 +0100 (CET) Date: Sun, 13 Mar 2022 10:02:22 +0100 From: Peter Zijlstra To: chenying Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, mgorman@suse.de, bristot@redhat.com, bsegall@google.com, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, zhouchengming@bytedance.com, songmuchun@bytedance.com, zhengqi.arch@bytedance.com, zhoufeng.zf@bytedance.com, ligang.bdlg@bytedance.com Subject: Re: [External] Re: Subject: [PATCH] sched/fair: prioritize normal task over sched_idle task with vruntime offset Message-ID: <20220313090222.GL28057@worktop.programming.kicks-ass.net> References: <20220312120309.GB6235@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Sun, Mar 13, 2022 at 01:37:37PM +0800, chenying wrote: > 在 2022/3/12 20:03, Peter Zijlstra 写道: > > On Fri, Mar 11, 2022 at 03:58:47PM +0800, chenying wrote: > > > We add a time offset to the se->vruntime when the idle sched_entity > > > is enqueued, so that the idle entity will always be on the right of > > > the non-idle in the runqueue. This can allow non-idle tasks to be > > > selected and run before the idle. > > > > > > A use-case is that sched_idle for background tasks and non-idle > > > for foreground. The foreground tasks are latency sensitive and do > > > not want to be disturbed by the background. It is well known that > > > the idle tasks can be preempted by the non-idle tasks when waking up, > > > but will not distinguish between idle and non-idle when pick the next > > > entity. This may cause background tasks to disturb the foreground. > > > > > > Test results as below: > > > > > > ~$ ./loop.sh & > > > [1] 764 > > > ~$ chrt -i 0 ./loop.sh & > > > [2] 765 > > > ~$ taskset -p 04 764 > > > ~$ taskset -p 04 765 > > > > > > ~$ top -p 764 -p 765 > > > top - 13:10:01 up 1 min,  2 users,  load average: 1.30, 0.38, 0.13 > > > Tasks:   2 total,   2 running,   0 sleeping,   0 stopped,   0 zombie > > > %Cpu(s): 12.5 us,  0.0 sy,  0.0 ni, 87.4 id,  0.0 wa,  0.0 hi, 0.0 si,  0.0 > > > st > > > KiB Mem : 16393492 total, 16142256 free,   111028 used,   140208 buff/cache > > > KiB Swap:   385836 total,   385836 free,        0 used. 16037992 avail Mem > > > > > >   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM TIME+ COMMAND > > >   764 chenyin+  20   0   12888   1144   1004 R 100.0  0.0 1:05.12 loop.sh > > >   765 chenyin+  20   0   12888   1224   1080 R   0.0  0.0 0:16.21 loop.sh > > > > > > The non-idle process (764) can run at 100% and without being disturbed by > > > the idle process (765). > > > > Did you just do a very complicated true idle time scheduler, with all > > the problems that brings? > > When colocating CPU-intensive jobs with latency-sensitive services can > improve CPU utilization but it is difficult to meet the stringent > tail-latency requirements of latency-sensitive services. We use a true idle > time scheduler for CPU-intensive jobs to minimize the impact on > latency-sensitive services. Hard NAK on any true idle-time scheduler until you make the whole kernel immune to lock holder starvation issues. And as said; this is a terrible way to do a true idle-time scheduler.