Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp403816ybn; Tue, 1 Oct 2019 23:27:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxz4wG7zKzPN4THABWy00Vw0aCa0lB5xXqL0B1t0WzeyU0yYxE5B8C0je4BjZrPUKzVqj+m X-Received: by 2002:a17:906:198f:: with SMTP id g15mr1596493ejd.76.1569997663736; Tue, 01 Oct 2019 23:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569997663; cv=none; d=google.com; s=arc-20160816; b=wZicyn586/tXXPEwg7dACkZGSo6ESYwF7LOdauteWDNVENWQak4qgwJ3hSFgjO01ep 9q1jgrrgBy8mnk6ig3VtrSW5pFgukR+B4/vkXLcPOw/VBhQb1tmed/AH61nBGEn8Uoic v8CdojRndi+pvq8vnQF+3cIOSFwu2OB9YnubRP3q6j17ePASc+1fS27WVgT21PjG7wCC glAnuFrMpAI/gU1M1AAT63SrtKSsYck45k+MK2MUTlkBpBbSWNEMeQSoiq0iHN9OEDdC aqfECj79FpWsaVCKeLtLkSaZQKaeRVekCj9LsX/lRKdvaWm9M+1eogRs/tsyp3iS+uP/ /GAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=1fxAcgpO+c0bRyp2y04H6DEVDJIviAr/p2Jm7Hd8l4Y=; b=samLBhyLXTFDA0ul5XA+qKvdU1CI+SrNVkbbz7oKZLHO6aAOkagNuYWkxU57ra38gV mwZnVUd2KEpu/f3hqf4p7Ev4Q4MPBOjt+F9WCV5JTqoenIgJ0Nc1hI4MPIm3xbUnKsST cTuo7R9XJYbQjNF7nF4/AXsnY8BGb5sFoVf88PrfLcTfITwMsANzW67nTGOhqB58zvD8 7oPkz3S0zTdwY177rGRyWR3zDbmj7Y3NNQhyDuOlPWKSLQ0dkgi6glf8f+GpHnDrQdRY GWsasM9KDb/jK/kV1JejCtGlrzfnmOSNRRN/KDa63VdMn9SxdgqAKWKnBlQsD82w86Hz c/qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si10066898ejj.174.2019.10.01.23.27.18; Tue, 01 Oct 2019 23:27:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729633AbfJBBUM (ORCPT + 99 others); Tue, 1 Oct 2019 21:20:12 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:10390 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725908AbfJBBUM (ORCPT ); Tue, 1 Oct 2019 21:20:12 -0400 X-UUID: c3a51ee9fba84d509627aeab88ea7030-20191002 X-UUID: c3a51ee9fba84d509627aeab88ea7030-20191002 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1161986974; Wed, 02 Oct 2019 09:20:07 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 2 Oct 2019 09:20:06 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 2 Oct 2019 09:20:06 +0800 Message-ID: <1569979206.4892.23.camel@mtkswgap22> Subject: Re: [PATCH 1/1] sched/rt: avoid contend with CFS task From: Jing-Ting Wu To: Qais Yousef CC: Vincent Guittot , Valentin Schneider , Peter Zijlstra , Matthias Brugger , , linux-kernel , LAK , Date: Wed, 2 Oct 2019 09:20:06 +0800 In-Reply-To: <20190919151152.m2zmiaspr6s5mcfh@e107158-lin.cambridge.arm.com> References: <1567048502-6064-1-git-send-email-jing-ting.wu@mediatek.com> <20190830145501.zadfv2ffuu7j46ft@e107158-lin.cambridge.arm.com> <1567689999.2389.5.camel@mtkswgap22> <1568892135.4892.10.camel@mtkswgap22> <20190919142315.vmrrpvljpspqpurp@e107158-lin.cambridge.arm.com> <20190919151152.m2zmiaspr6s5mcfh@e107158-lin.cambridge.arm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-09-19 at 16:11 +0100, Qais Yousef wrote: > On 09/19/19 16:37, Vincent Guittot wrote: > > On Thu, 19 Sep 2019 at 16:32, Vincent Guittot > > wrote: > > > > > > On Thu, 19 Sep 2019 at 16:23, Qais Yousef wrote: > > > > > > > > On 09/19/19 14:27, Vincent Guittot wrote: > > > > > > > > But for requirement of performance, I think it is better to differentiate between idle CPU and CPU has CFS task. > > > > > > > > > > > > > > > > For example, we use rt-app to evaluate runnable time on non-patched environment. > > > > > > > > There are (NR_CPUS-1) heavy CFS tasks and 1 RT Task. When a CFS task is running, the RT task wakes up and choose the same CPU. > > > > > > > > The CFS task will be preempted and keep runnable until it is migrated to another cpu by load balance. > > > > > > > > But load balance is not triggered immediately, it will be triggered until timer tick hits with some condition satisfied(ex. rq->next_balance). > > > > > > > > > > > > > > Yes you will have to wait for the next tick that will trigger an idle > > > > > > > load balance because you have an idle cpu and 2 runnable tack (1 RT + > > > > > > > 1CFS) on the same CPU. But you should not wait for more than 1 tick > > > > > > > > > > > > > > The current load_balance doesn't handle correctly the situation of 1 > > > > > > > CFS and 1 RT task on same CPU while 1 CPU is idle. There is a rework > > > > > > > of the load_balance that is under review on the mailing list that > > > > > > > fixes this problem and your CFS task should migrate to the idle CPU > > > > > > > faster than now > > > > > > > > > > > > > > > > > > > Period load balance should be triggered when current jiffies is behind > > > > > > rq->next_balance, but rq->next_balance is not often exactly the same > > > > > > with next tick. > > > > > > If cpu_busy, interval = sd->balance_interval * sd->busy_factor, and > > > > > > > > > > But if there is an idle CPU on the system, the next idle load balance > > > > > should apply shortly because the busy_factor is not used for this CPU > > > > > which is not busy. > > > > > In this case, the next_balance interval is sd_weight which is probably > > > > > 4ms at cluster level and 8ms at system level in your case. This means > > > > > between 1 and 2 ticks > > > > > > > > But if the CFS task we're preempting was latency sensitive - this 1 or 2 tick > > > > is too late of a recovery. > > > > > > > > So while it's good we recover, but a preventative approach would be useful too. > > > > Just saying :-) I'm still not sure if this is the best longer term approach. > > > > > > like using a rt task ? > > > > I mean, RT task should select a sub optimal CPU because of CFS > > If you want to favor CFS compared to RT it's probably because your > > task should be RT too > > Yes possibly. But I don't think this is always doable. Especially when you're > running on generic system not a special purposed one. > > And we don't need to favor CFS over RT. But I think they can play nicely > together. > > For example on Android there are few RT tasks and rarely more than 1 runnable > RT task at a time. But if it happened to wakeup on the same CPU that is > running the UI thread you could lose a frame. And from what I've seen as well > we have 1-3 CFS tasks runnable, weighted more towards 1 task. So we do have > plenty of idle CPUs on average. > > But as I mentioned earlier I couldn't prove yet this being a serious problem. > I was hoping the use case presented here is based on a real workload, but it's > synthetic. So I agree we need stronger reasons, but I think conceptually we do > have a conflict of interest where RT task could unnecessarily hurt the > performance of CFS task. > > Another way to look at the problem is that the system is not partitioned > correctly and the admin could do a better job to prevent this. > > -- > Qais Yousef I use some third-party application, such as weibo and others, to test the application launch time. I apply this RT patch, and compare it with original design. Both RT patch test case and original design test case are already apply the patch:https://lore.kernel.org/patchwork/patch/1129117/ After apply the RT patch, launch time of weibo from 1325.72ms to 1214.88 ms, its launch time decreases 110.84ms(about 8.36%). Other applications also decrease 7~13%. At original design test case, RT tasks(surfaceflinger) could preempt some CFS tasks, if we add all these CFS tasks runnable time, it may have some impact on app launch time. So even if we already use the load balance patch and reduce a lot of CFS runnable time, I think choose idle CPU at RT scheduler could also reduce the some CFS runnable time. Best regards, Jing-Ting Wu