Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2392047pxb; Mon, 20 Sep 2021 21:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLAQfYXe9PVgwNWqtZlaReGfOyUQ6bQR5FHEFKRX/EhH7yuMQi1rgbKTEj49uiVagg39Gu X-Received: by 2002:a92:dc85:: with SMTP id c5mr19700349iln.104.1632197414911; Mon, 20 Sep 2021 21:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632197414; cv=none; d=google.com; s=arc-20160816; b=SuUU6vWOUzoxUCBzLhAPvL05G04216lMsEcnbXG0kbFVDtVkAD8ELWjSiSZqzIaqTy ToH2/h2hslkxnxtWnO6hMewvDmUuo9+iRUzb8zJPYGSNfOypciIM2xPAyGti+HVrwdJP Arsy+nuJHH+1OcdsmBm/dmIwDhS0v0r97fdSxS2JPrjjHxinsigtLuouhr04lOE3D2Pa 5DYLLjM9CyQaQDVQd11CFaMfULa4Ap5nzei/nHI8LYxEaIYWxx8vwBLyPEt2IXzDEx8d 7c9Bs/TbhbFkdZwJ9nrgPLVaeSsX+7wIWXBv5gu0Qv6itL1fj2roMh1Eoem8I8iYgL28 Z9WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=Ya2v78ekXvl0ETXKdoAHzSj9fIodjT6eBw8YbYy08Ts=; b=QhzNHu5fZWeHHi+irM+8RO6McFgXoXfSDMxO+TCwyswL8ibSSChmmgX8RltGb9ORrg lpSNxo9JMEk3wGoVWxWnVHneVW7kf7nLEwvulv0fGOJLbyTkF8Tk8IfHN/Ckhp7McSGe BluCYwVJrmctvS4HOf/wb4V7f6jg1qpcTfcKjqq0/AKCY5k5RZRRi0mXZk7g6CiWu5Q1 RB5v1oY+AAv7vTzO7Vx2TSXCUfX4AurnoXvYkrlr6USIUk8PMpPomutg9jpV+rJYLjCg Nx1jh85lQtFPR85/Z9r99rlmGJiE8uQDTpivt4lsbQiHqlkvPxPhxCr/gJ02Rfc4RKmy WhoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=aYUAwglq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si15496244iow.29.2021.09.20.21.10.03; Mon, 20 Sep 2021 21:10:14 -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=@gmx.net header.s=badeba3b8450 header.b=aYUAwglq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbhIUDyf (ORCPT + 99 others); Mon, 20 Sep 2021 23:54:35 -0400 Received: from mout.gmx.net ([212.227.15.18]:47815 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhIUDye (ORCPT ); Mon, 20 Sep 2021 23:54:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1632196355; bh=r3xl6ViXZ8jgRjOEtQO4whBlrs8Seet1iwhiVgObEe4=; h=X-UI-Sender-Class:Subject:From:To:Cc:Date:In-Reply-To:References; b=aYUAwglq1MFT5nK4GczHCkIIrKBj/lhWWtjEqv64oFPi1PBMIpq3cnUEDxo2McZXq fmfavDtNkw/PWQCjxq9sg3PFAgg8+YzuULBilqrQHIqql9w9rC4Otvp8ut/gPyPH89 0F+8rUL0nbnmo4MmOFs1kzfk70Mhqu0fnto1e+kU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from homer.fritz.box ([185.191.219.33]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MLiCo-1mArSN0lAO-00HcVP; Tue, 21 Sep 2021 05:52:35 +0200 Message-ID: <22e7133d674b82853a5ee64d3f5fc6b35a8e18d6.camel@gmx.de> Subject: Re: [PATCH 2/2] sched/fair: Scale wakeup granularity relative to nr_running From: Mike Galbraith To: Mel Gorman , Peter Zijlstra Cc: Ingo Molnar , Vincent Guittot , Valentin Schneider , Aubrey Li , Barry Song , Srikar Dronamraju , LKML Date: Tue, 21 Sep 2021 05:52:32 +0200 In-Reply-To: <20210920142614.4891-3-mgorman@techsingularity.net> References: <20210920142614.4891-1-mgorman@techsingularity.net> <20210920142614.4891-3-mgorman@techsingularity.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:9t0pnDVoamktI2GrIJ23ADQ3eimqjSO43/Q15i5jfR/LWP54snE eAfTWf7z6NaOvvRMAPbQSCjU55WwVUEFP5C7gX0VXIrEfR8NvBTpYPZxuCXAl6NhUn4Y0iB M0096XOVu5qFgi9LOaQ4iWkTzazxWhFGRqnyc+oi2ChhcVBxpE8V6laTge6GlvX8xH4Jaeg fiBOnu2uvEgtahY48abew== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Odmo0F2+fAY=:9Iday6/sSCWy6U0EcJhRfn vqvja/EIqn7CKRM/8GaoSqHAV0l9GdNEdsfyC05I78w83Iia9ydY1s2+UjJnYgLSrXLWs+Jo1 HM5YCF3sGbY6OZ0KfX8cFDLBQnNPeJ3mTRqNXDIhESy7aTbZ8bXzZ4Chu8eoXdwF4cX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patch scales the wakeup granularity based on the number of running > tasks on the CPU up to a max of 8ms by default.=C2=A0 The intent is to > allow tasks to run for longer while overloaded so that some tasks may > complete faster and reduce the degree a domain is overloaded. Note that > the TuneD throughput-performance profile allows up to 15ms but there > is no explanation why such a long period was necessary so this patch is > conservative and uses the value that check_preempt_wakeup() also takes > into account.=C2=A0 An internet search for instances where this paramete= r are > tuned to high values offer either no explanation or a broken one. > > This improved hackbench on a range of machines when communicating via > pipes (sockets show little to no difference). For a 2-socket CascadeLake > machine, the results were Twiddling wakeup preemption based upon the performance of a fugly fork bomb seems like a pretty bad idea to me. Preemption does rapidly run into diminishing return as load climbs for a lot of loads, but as you know, it's a rather sticky wicket because even when over-committed, preventing light control threads from slicing through (what can be a load's own work crew of) hogs can seriously injure performance. > @@ -7044,10 +7045,22 @@ balance_fair(struct rq *rq, struct task_struct *= prev, struct rq_flags *rf) > =C2=A0} > =C2=A0#endif /* CONFIG_SMP */ > =C2=A0 > -static unsigned long wakeup_gran(struct sched_entity *se) > +static unsigned long > +wakeup_gran(struct cfs_rq *cfs_rq, struct sched_entity *se) > =C2=A0{ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0unsigned long gran =3D s= ysctl_sched_wakeup_granularity; > =C2=A0 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * If rq is specified, scale = the granularity relative to the number > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * of running tasks but no mo= re than 8ms with default > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * sysctl_sched_wakeup_granul= arity settings. The wakeup gran > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * reduces over-scheduling bu= t if tasks are stacked then the > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * domain is likely overloade= d and over-scheduling may > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * prolong the overloaded sta= te. > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (cfs_rq && cfs_rq->nr_runn= ing > 1) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0gran *=3D min(cfs_rq->nr_running >> 1, sched_nr_laten= cy); > + Maybe things have changed while I wasn't watching closely, but... The scaled up tweakables on my little quad desktop box: sched_nr_latency =3D 8 sched_wakeup_granularity =3D 4ms sched_latency =3D 24ms Due to the FAIR_SLEEPERS feature, a task can only receive a max of sched_latency/2 sleep credit, ie the delta between waking sleeper and current is clipped to a max of 12 virtual ms, so the instant our preempt threshold reaches 12.000ms, by human booboo or now 3 runnable tasks with this change, wakeup preemption is completely disabled, or? -Mike