Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1646697pxa; Thu, 20 Aug 2020 17:15:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEYP4PHlOeu2yrjX9QqtutgMpp5+9E7IddwQBmJJvkrI0IsO7rylaeV8brYW2NyYe7dGT7 X-Received: by 2002:a17:906:a3d5:: with SMTP id ca21mr279162ejb.453.1597968946322; Thu, 20 Aug 2020 17:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597968946; cv=none; d=google.com; s=arc-20160816; b=svC2mDH6PsBvCz8J184jtqrglir6P8rmCwsALCQM/iGaAB88YLomBTD8B0v/CPKeZs MpCzzKSc05EyJYry8rT1Zr0j3WuikodG2j7OVlnVNqxM0ihUoJkBUo33+emizKIf5YbY HAs+l7N7BtP3Ioi/WTl0wKtq7uzbbkd6qOmWZo1suuUJeeNbp6VqC1PzPeLdRn/z2a7G Ez1GzUZ3kL7vfR/9tOgHPLOxtw5o9Oj0Br+/sS7UJx8HwC2lz/jgfp18FiSzGfPWFs8c CwekzprmIPIZhCBDoEVfofyHR46iXR5ROoKCfDqvqG1WwcutxjdlZfeV0Z8lTqYVlNlC WW8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=86kttTG1csndCylSNFgBh/JL192WZ77A7vACiVeacFU=; b=OiiTPsI7aTikhxeWR0vLv+lm1lKvH+uAuvOYz3aJVSf1DZwd0HI5k0RBgI4tKcdH4U oWCHJ24qNhradTQWRFo9y9Lba5savdaQyuU1aDy3s+aYqwkKgX17TH9byF0acANsxusU tiTAh9Daua91knJqUzI6AF1AIJQJyqnx/db4VOtCAwt9iJO8Xg4CHLH0EtLbs13juXjS qyvg8yGi3hx+Y2Nub/y29KhlerMUHh//ONiuvdz4yfaGh0HtezQ342DaaGYSyhxiF6rC ywNKyMyKKo2VGeK9uKt1e5r9pZ+aDyDcnBPYAdDYDOul0MpDmpVMmpVPU+4HVPEG3/TA YAIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h4DK4Hcr; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si39229ejs.497.2020.08.20.17.15.22; Thu, 20 Aug 2020 17:15:46 -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=h4DK4Hcr; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726873AbgHUAOi (ORCPT + 99 others); Thu, 20 Aug 2020 20:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725834AbgHUAOh (ORCPT ); Thu, 20 Aug 2020 20:14:37 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11994C061385 for ; Thu, 20 Aug 2020 17:14:37 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id z18so293136otk.6 for ; Thu, 20 Aug 2020 17:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=86kttTG1csndCylSNFgBh/JL192WZ77A7vACiVeacFU=; b=h4DK4HcrBFuAi1gkZyLWMEqB0lwnJwgyi1ova0p1tAuZxyiFr63JkaUM5xnExqs4L2 4f6/UKyNR3m1vIpUscQ3hLWl14VMx7nBENwFg45xVNELbYOZdDlKep9GKwXNmXyWOEdD /jBUW/VmBJttqhi+kl81KUyXgUqCFSsPFXEVVGryC09siIjh1mHFnFdTRnku+kdyDEIO 67UkR0osi3GYWm+ieaYVN9EEXBe2lyAEgZDds4vC00br1mB4iiZiRgiqqyvybs5Az4p/ GPe31gZBDJ/AU/Bg4icYvZmdj4E5PpuFfcTZ15+zyjfh4RdflhzYwILNLHrwMktnr+wJ 0OAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=86kttTG1csndCylSNFgBh/JL192WZ77A7vACiVeacFU=; b=L2PGpfXZ2/x+eaKZIaasC8/QBXRD5odkP886jbEvi1KVRUZnM8gkf4oeV0AXtNwteL wLbOWxo+XMIr3+ZK1bbkelu5yBnDS0iasCCbOpfoDIoNmog+jgFVNURQMHr5wL7M4ZBI fOIoDylXqumoOHTuzK3Yc5mQ4mQchwfGHbBgUtepNFo93kRgad0Tm1BdNU/CwZf/dmQD ZS08O3QNdPKljFgmsLNKMTQ/z3odV1XvC6aXUw4LZB1XdZVCiJphKTV6pa+LYWz9UwDo cbnQTCGjQCyq7/kcyHPb4qcpHStPLd5+ROs76ibAJfB4whD4YvXB7tWgbifJeeR3yWAn Koag== X-Gm-Message-State: AOAM530wx05lTkjK3mVU10wwf910pRuRrPqpm424reCrUbkNwcyvP5mW npJdVfZTDDe7ztVRU9O9MP8O16jX8lxlwVvZB4U= X-Received: by 2002:a9d:554b:: with SMTP id h11mr217179oti.330.1597968876456; Thu, 20 Aug 2020 17:14:36 -0700 (PDT) MIME-Version: 1.0 References: <20200801023248.90104-1-benbjiang@gmail.com> <5ed0fd46-3a3d-3c1a-5d75-03a74864e640@arm.com> <592F24A7-BF43-457D-AC40-DC5E35279730@tencent.com> <8bef1f94-f9bf-08a5-2ff3-3485d7796a96@arm.com> <8629CB9F-AFC8-43D6-BD14-B60A0B85ADB3@tencent.com> <5f870781-1648-b4ac-6026-557dfc347109@arm.com> <4964e359-afc5-a256-4950-853a9485eeff@arm.com> <70236E62-AA36-48C1-9382-86353649253C@tencent.com> <3a1047fc-a86a-014a-b17a-eae71f669da1@arm.com> <643B0ECE-D758-4D08-8B1B-C70F34DD9943@tencent.com> <55f04582-69d6-aeb4-85be-3e46a3b15beb@arm.com> <755BFAD0-9072-4D73-9CD7-AF4F74A79D21@tencent.com> <729675a2-b083-4211-62c0-f7ed7f483ae2@arm.com> <3A85DD77-2A4B-466F-A1F4-1BF2AF02CF58@tencent.com> In-Reply-To: From: Jiang Biao Date: Fri, 21 Aug 2020 08:14:25 +0800 Message-ID: Subject: Re: [PATCH] sched/fair: reduce preemption with IDLE tasks runable(Internet mail) To: Vincent Guittot Cc: =?UTF-8?B?YmVuYmppYW5nKOiSi+W9qik=?= , Dietmar Eggemann , "mingo@redhat.com" , "peterz@infradead.org" , "juri.lelli@redhat.com" , "rostedt@goodmis.org" , "bsegall@google.com" , "mgorman@suse.de" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Aug 2020 at 22:36, Vincent Guittot wrote: > > On Thu, 20 Aug 2020 at 16:28, Jiang Biao wrote: > > > > On Thu, 20 Aug 2020 at 20:46, Vincent Guittot > > wrote: > > > > > > On Thu, 20 Aug 2020 at 13:28, benbjiang(=E8=92=8B=E5=BD=AA) wrote: > > > > > > > > > > > > > > > > > On Aug 20, 2020, at 3:35 PM, Vincent Guittot wrote: > > > > > > > > > > On Thu, 20 Aug 2020 at 02:13, benbjiang(=E8=92=8B=E5=BD=AA) wrote: > > > > >> > > > > >> > > > > >> > > > > >>> On Aug 19, 2020, at 10:55 PM, Vincent Guittot wrote: > > > > >>> > > > > >>> On Wed, 19 Aug 2020 at 16:27, benbjiang(=E8=92=8B=E5=BD=AA) wrote: > > > > >>>> > > > > >>>> > > > > >>>> > > > > >>>>> On Aug 19, 2020, at 7:55 PM, Dietmar Eggemann wrote: > > > > >>>>> > > > > >>>>> On 19/08/2020 13:05, Vincent Guittot wrote: > > > > >>>>>> On Wed, 19 Aug 2020 at 12:46, Dietmar Eggemann wrote: > > > > >>>>>>> > > > > >>>>>>> On 17/08/2020 14:05, benbjiang(=E8=92=8B=E5=BD=AA) wrote: > > > > >>>>>>>> > > > > >>>>>>>> > > > > >>>>>>>>> On Aug 17, 2020, at 4:57 PM, Dietmar Eggemann wrote: > > > > >>>>>>>>> > > > > >>>>>>>>> On 14/08/2020 01:55, benbjiang(=E8=92=8B=E5=BD=AA) wrote: > > > > >>>>>>>>>> Hi, > > > > >>>>>>>>>> > > > > >>>>>>>>>>> On Aug 13, 2020, at 2:39 AM, Dietmar Eggemann wrote: > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> On 12/08/2020 05:19, benbjiang(=E8=92=8B=E5=BD=AA) wrot= e: > > > > >>>>>>>>>>>> Hi, > > > > >>>>>>>>>>>> > > > > >>>>>>>>>>>>> On Aug 11, 2020, at 11:54 PM, Dietmar Eggemann wrote: > > > > >>>>>>>>>>>>> > > > > >>>>>>>>>>>>> On 11/08/2020 02:41, benbjiang(=E8=92=8B=E5=BD=AA) wr= ote: > > > > >>>>>>>>>>>>>> Hi, > > > > >>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>> On Aug 10, 2020, at 9:24 PM, Dietmar Eggemann wrote: > > > > >>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>> On 06/08/2020 17:52, benbjiang(=E8=92=8B=E5=BD=AA) = wrote: > > > > >>>>>>>>>>>>>>>> Hi, > > > > >>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>>> On Aug 6, 2020, at 9:29 PM, Dietmar Eggemann wrote: > > > > >>>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>>> On 03/08/2020 13:26, benbjiang(=E8=92=8B=E5=BD=AA= ) wrote: > > > > >>>>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>>>>> On Aug 3, 2020, at 4:16 PM, Dietmar Eggemann wrote: > > > > >>>>>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>>>>> On 01/08/2020 04:32, Jiang Biao wrote: > > > > >>>>>>>>>>>>>>>>>>>> From: Jiang Biao > > > > >>>>>>> > > > > >>>>>>> [...] > > > > >>>>>>> > > > > >>>>>>>>> Are you sure about this? > > > > >>>>>>>> Yes. :) > > > > >>>>>>>>> > > > > >>>>>>>>> The math is telling me for the: > > > > >>>>>>>>> > > > > >>>>>>>>> idle task: (3 / (1024 + 1024 + 3))^(-1) * 4ms =3D 27= 35ms > > > > >>>>>>>>> > > > > >>>>>>>>> normal task: (1024 / (1024 + 1024 + 3))^(-1) * 4ms =3D = 8ms > > > > >>>>>>>>> > > > > >>>>>>>>> (4ms - 250 Hz) > > > > >>>>>>>> My tick is 1ms - 1000HZ, which seems reasonable for 600ms?= :) > > > > >>>>>>> > > > > >>>>>>> OK, I see. > > > > >>>>>>> > > > > >>>>>>> But here the different sched slices (check_preempt_tick()-> > > > > >>>>>>> sched_slice()) between normal tasks and the idle task play = a role to. > > > > >>>>>>> > > > > >>>>>>> Normal tasks get ~3ms whereas the idle task gets <0.01ms. > > > > >>>>>> > > > > >>>>>> In fact that depends on the number of CPUs on the system > > > > >>>>>> :sysctl_sched_latency =3D 6ms * (1 + ilog(ncpus)) . On a 8 c= ores system, > > > > >>>>>> normal task will run around 12ms in one shoot and the idle t= ask still > > > > >>>>>> one tick period > > > > >>>>> > > > > >>>>> True. This is on a single CPU. > > > > >>>> Agree. :) > > > > >>>> > > > > >>>>> > > > > >>>>>> Also, you can increase even more the period between 2 runs o= f idle > > > > >>>>>> task by using cgroups and min shares value : 2 > > > > >>>>> > > > > >>>>> Ah yes, maybe this is what Jiang wants to do then? If his run= time does > > > > >>>>> not have other requirements preventing this. > > > > >>>> That could work for increasing the period between 2 runs. But = could not > > > > >>>> reduce the single runtime of idle task I guess, which means no= rmal task > > > > >>>> could have 1-tick schedule latency because of idle task. > > > > >>> > > > > >>> Yes. An idle task will preempt an always running task during 1= tick > > > > >>> every 680ms. But also you should keep in mind that a waking nor= mal > > > > >>> task will preempt the idle task immediately which means that it= will > > > > >>> not add scheduling latency to a normal task but "steal" 0.14% o= f > > > > >>> normal task throughput (1/680) at most > > > > >> That=E2=80=99s true. But in the VM case, when VM are busy(MWAIT = passthrough > > > > >> or running cpu eating works), the 1-tick scheduling latency coul= d be > > > > >> detected by cyclictest running in the VM. > > > > >> > > > > >> OTOH, we compensate vruntime in place_entity() to boot waking > > > > >> without distinguish SCHED_IDLE task, do you think it=E2=80=99s n= ecessary to > > > > >> do that? like > > > > >> > > > > >> --- a/kernel/sched/fair.c > > > > >> +++ b/kernel/sched/fair.c > > > > >> @@ -4115,7 +4115,7 @@ place_entity(struct cfs_rq *cfs_rq, struct= sched_entity *se, int initial) > > > > >> vruntime +=3D sched_vslice(cfs_rq, se); > > > > >> > > > > >> /* sleeps up to a single latency don't count. */ > > > > >> - if (!initial) { > > > > >> + if (!initial && likely(!task_has_idle_policy(task_of(se)= ))) { > > > > >> unsigned long thresh =3D sysctl_sched_latency; > > > > > > > > > > Yeah, this is a good improvement. > > > > Thanks, I=E2=80=99ll send a patch for that. :) > > > > > > > > > Does it solve your problem ? > > > > > > > > > Not exactly. :) I wonder if we can make SCHED_IDLE more pure(harml= ess)? > > > > > > We can't prevent it from running time to time. Proxy execution featur= e > > > could be a step for considering to relax this constraint > > > > > Could you please help to explain more about the *Proxy execution featur= e*? > > I'm not sure I got the right point. > > https://lwn.net/Articles/820575/ > https://lwn.net/Articles/793502/ Good to hear about that. I guess there would still be a long way to go. :) Thanks again for your kindly patience. Regard, Jiang