Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp807953ybk; Wed, 13 May 2020 13:43:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwOE9huxeY5q+jqqM9oC/y0TMNiob9rM0hOjmgMoWQu8jam51Qio5rXbnEBbBWuTBfsoYt X-Received: by 2002:a50:d1c4:: with SMTP id i4mr1315440edg.344.1589402601572; Wed, 13 May 2020 13:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589402601; cv=none; d=google.com; s=arc-20160816; b=aUnioF3dWcgSSmPusBqQVsvj1lbuitkEPCMGwYUr6GMRVN4cf8Gf30Vqi/z/F3n4CW 5XVhM7AcmoVnhIY4Mylr6ihV6paNthJnPprNECyxLlK9qRQ47Ne17xRR7O8TY094W8gB JvtR9G5hlq9He4bm7AsQ3lTNWrUYDq6JozGd+kLhzykAFJ4iSI7A3EMfbUDvRxUW4HIw BxG6fIlijRRq/cvKw/DOev2YdH/5fD5MxUqyRdLvm88l/wOWWrhWWv2SA73+BFRELRtU fzdRFrOl1n/zdwpxXH5v4SCtN/5bdBH+XncRve/d1AUM8uQZ70P9IdqpRKfirK4CS9nE m2pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ctNRDk9XGc9CHMoQDqvFHi5vxID2gsh5buG4nKb35qU=; b=cvb/JlMUMYogsOR+gIxoOBO1Iu7zSaQvFOVVBKyXKPhzqDFASOw4bTmHDUDSQun9z6 hmlues3O/s0R/aFsgDIlrO7afyi3oTTfkk4/e9nlpf4WyOUJU0aAln5mBPOAu9+8xlJu t6hzO73v93XZKIRpx/se8vbtgGncjey2L4aNcXuJcBg2TTCOiWWgoxpFGGjspMUdRdJ3 i2KfJVRfYIG+0Ja5tzNk5cOSk03TNHYgcVtmrkQXbapiflHn1qeNkJfUEUkC3q3aGzUj Y23rbRE1+8XF3vhGY8qqeL+2AA+A6qqazxNqPq3eKPKIR0/IASWzai3f7swF8ygVOhRy fIxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bUhpZbiZ; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si450275edq.89.2020.05.13.13.42.58; Wed, 13 May 2020 13:43:21 -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=@linaro.org header.s=google header.b=bUhpZbiZ; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387703AbgEMNZq (ORCPT + 99 others); Wed, 13 May 2020 09:25:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbgEMNZo (ORCPT ); Wed, 13 May 2020 09:25:44 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B502EC061A0C for ; Wed, 13 May 2020 06:25:43 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id g1so11855743ljk.7 for ; Wed, 13 May 2020 06:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ctNRDk9XGc9CHMoQDqvFHi5vxID2gsh5buG4nKb35qU=; b=bUhpZbiZX2ExbTaWxKBu12anjLM5QsTRXZlxtQ3J8phy61HMAdwQtD/ciJ+RZjbB4l TPiNYZ65LO4eOpef3IRXMgDqW9ncENwhQD1JgamCKjDODuXK56Uu4R1w8hyMfiCDsAo2 VPg4XaBBY0T7VQYirgFnBafM3HyKbdlg6geDLIBI5fLzWoyp7j+lNuetuCdW/TwIpFac 0y92eoZJ7VyFwMDiMpSCqsh6xgcCE21azzNivuZED4bgxqPL/9aJTikReB2bz2qrJYYl qllIyroLbq3nA7NUh5FsKfkowUcdK8FUA7DTLHdzanutUgrwV3jEpKZG/xFDwi4/+hv2 6OTg== 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; bh=ctNRDk9XGc9CHMoQDqvFHi5vxID2gsh5buG4nKb35qU=; b=dGKkjH6lu3hwTN7thG77qhPvau0fFGqI0HBKmi6iGoVUMwZDTI+eaFA8V5mcyfPC7L Ajk6aeIoyGyf8lCT5RByjTNHeSbfjBtQG9fzaQnWupCFHP9w6gP5RBFXMQ6NiUDQcjAc QdvDC2RdayNlw2LxoRmekyokZxGlBHapRxw9ztLYRDrcU2kL5ApY+z7KH6cKEWLfb7UE nYDmvaLzyOLG7rpXjfSaWXcYvjij+1lsBenD1AFL6apP3mgGc4lU9Im8RwQ1Tb2wWOla ThuxGrPTJS9yGVkGbNgvJ0c+W8BNqfMk8kS02Mvhn6nbLOzzU8Qu1UbPApcvtxGEfCao eqPQ== X-Gm-Message-State: AOAM532+72XtAG5xuqA9dtkyIWPA/B6rg2pG/eWvXuYVlBZK7Th86yJE XO58pcXjhFzSoqLBpgVYpmrx4feAb5qnjzxCZbJJaQ== X-Received: by 2002:a2e:3209:: with SMTP id y9mr16226819ljy.154.1589376341852; Wed, 13 May 2020 06:25:41 -0700 (PDT) MIME-Version: 1.0 References: <20200513123335.28122-1-vincent.guittot@linaro.org> <20200513124540.GB12425@lorien.usersys.redhat.com> <20200513131337.GF12425@lorien.usersys.redhat.com> <20200513131808.GG12425@lorien.usersys.redhat.com> In-Reply-To: <20200513131808.GG12425@lorien.usersys.redhat.com> From: Vincent Guittot Date: Wed, 13 May 2020 15:25:29 +0200 Message-ID: Subject: Re: [PATCH v2] sched/fair: enqueue_task_fair optimization To: Phil Auld Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel , Tao Zhou , Pavan Kondeti Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 May 2020 at 15:18, Phil Auld wrote: > > On Wed, May 13, 2020 at 03:15:53PM +0200 Vincent Guittot wrote: > > On Wed, 13 May 2020 at 15:13, Phil Auld wrote: > > > > > > On Wed, May 13, 2020 at 03:10:28PM +0200 Vincent Guittot wrote: > > > > On Wed, 13 May 2020 at 14:45, Phil Auld wrote: > > > > > > > > > > Hi Vincent, > > > > > > > > > > On Wed, May 13, 2020 at 02:33:35PM +0200 Vincent Guittot wrote: > > > > > > enqueue_task_fair jumps to enqueue_throttle label when cfs_rq_of(se) is > > > > > > throttled which means that se can't be NULL and we can skip the test. > > > > > > > > > > > > > > > > s/be NULL/be non-NULL/ > > > > > > > > > > I think. > > > > > > > > This sentence refers to the move of enqueue_throttle and the fact that > > > > se can't be null when goto enqueue_throttle and we can jump directly > > > > after the if statement, which is now removed in v2 because se is > > > > always NULL if we don't use goto enqueue_throttle. > > > > > > > > I haven't change the commit message for the remove of if statement > > > > > > > > > > Fair enough, it just seems backwards from the intent of the patch now. > > > > > > There is also an extra } after the update_overutilized_status. > > > > don't know what I did but it's crap. sorry about that > > > > No worries. I didn't see it when I read it either. The compiler told me :) Yeah, but i thought that i compiled it which is obviously not true > > > > Let me prepare a v3 > > > > > > > > > > > Cheers, > > > Phil > > > > > > > > > > > > > > > > > > > It's more like if it doesn't jump to the label then se must be NULL for > > > > > the loop to terminate. The final loop is a NOP if se is NULL. The check > > > > > wasn't protecting that. > > > > > > > > > > Otherwise still > > > > > > > > > > > Reviewed-by: Phil Auld > > > > > > > > > > Cheers, > > > > > Phil > > > > > > > > > > > > > > > > Signed-off-by: Vincent Guittot > > > > > > --- > > > > > > > > > > > > v2 changes: > > > > > > - Remove useless if statement > > > > > > > > > > > > kernel/sched/fair.c | 39 ++++++++++++++++++++------------------- > > > > > > 1 file changed, 20 insertions(+), 19 deletions(-) > > > > > > > > > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > > > > index a0c690d57430..b51b12d63c39 100644 > > > > > > --- a/kernel/sched/fair.c > > > > > > +++ b/kernel/sched/fair.c > > > > > > @@ -5513,28 +5513,29 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > > > > > > list_add_leaf_cfs_rq(cfs_rq); > > > > > > } > > > > > > > > > > > > -enqueue_throttle: > > > > > > - if (!se) { > > > > > > - add_nr_running(rq, 1); > > > > > > - /* > > > > > > - * Since new tasks are assigned an initial util_avg equal to > > > > > > - * half of the spare capacity of their CPU, tiny tasks have the > > > > > > - * ability to cross the overutilized threshold, which will > > > > > > - * result in the load balancer ruining all the task placement > > > > > > - * done by EAS. As a way to mitigate that effect, do not account > > > > > > - * for the first enqueue operation of new tasks during the > > > > > > - * overutilized flag detection. > > > > > > - * > > > > > > - * A better way of solving this problem would be to wait for > > > > > > - * the PELT signals of tasks to converge before taking them > > > > > > - * into account, but that is not straightforward to implement, > > > > > > - * and the following generally works well enough in practice. > > > > > > - */ > > > > > > - if (flags & ENQUEUE_WAKEUP) > > > > > > - update_overutilized_status(rq); > > > > > > + /* At this point se is NULL and we are at root level*/ > > > > > > + add_nr_running(rq, 1); > > > > > > + > > > > > > + /* > > > > > > + * Since new tasks are assigned an initial util_avg equal to > > > > > > + * half of the spare capacity of their CPU, tiny tasks have the > > > > > > + * ability to cross the overutilized threshold, which will > > > > > > + * result in the load balancer ruining all the task placement > > > > > > + * done by EAS. As a way to mitigate that effect, do not account > > > > > > + * for the first enqueue operation of new tasks during the > > > > > > + * overutilized flag detection. > > > > > > + * > > > > > > + * A better way of solving this problem would be to wait for > > > > > > + * the PELT signals of tasks to converge before taking them > > > > > > + * into account, but that is not straightforward to implement, > > > > > > + * and the following generally works well enough in practice. > > > > > > + */ > > > > > > + if (flags & ENQUEUE_WAKEUP) > > > > > > + update_overutilized_status(rq); > > > > > > > > > > > > } > > > > > > > > > > > > +enqueue_throttle: > > > > > > if (cfs_bandwidth_used()) { > > > > > > /* > > > > > > * When bandwidth control is enabled; the cfs_rq_throttled() > > > > > > -- > > > > > > 2.17.1 > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > > > > -- > > > > > > > -- >