Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2831855ybk; Tue, 12 May 2020 09:09:29 -0700 (PDT) X-Google-Smtp-Source: APiQypJDodotpoaePZdio3uqbewoVCVte6hZOhENR9fgJdcE4Ot1WcvK8t2drB5QjaB/BD716hl7 X-Received: by 2002:a50:a883:: with SMTP id k3mr18288031edc.198.1589299769364; Tue, 12 May 2020 09:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589299769; cv=none; d=google.com; s=arc-20160816; b=B1h5HW9q+vYAkqj5qOqfJGXrBfSymFC62rBLOqhurVNfGnJf/K7xk7Z5/ZQ+A41mNf urJXoPtHWpUsU1HvwoFrXPSEUXIIIZn9TMdAv54XXf1JGohcpdI74Ey3pXqzxza53Cri 2EQf2zE6tF4D/y2OlYHjVEtg0Xsfq+unTJiWtJS0gNZFLqsEQQfbrx6+Rvn2wYF4ULID WNf+LJzV2WkfOcICYdK65MVsVS8vlWgP5KnoBbIJf6UGCEngVi8Fz2fLQ15dnDp6DlDm Tm+3WxsJC6xxY4cFCvJJFmzv7B4fqEJXRd9P5+eFwLNySofUke5MaoHa0rnwv903sHQw PfuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zOD1ZMsJH+6+YOeIeEjkmiXARILcJYCNRieBUs4BWZs=; b=AMD/PfjieL1pBzhMpd0qzubtO1ATzZ+MlYbzYd2YqfTSP1kDxNaMRCvb5V3VI49g/Y Ig63d4BE/5Zol4PbluAsQ5WU9k3rmjcwr6uB17J1QPdbz3BmQ3WznS1P2rt1832Uz2+n lmUJEEXWX/W6xoYeK86axKre61UHeNhPQsX5nAck4ux9US5QdUfqmvpnu+n4Zs+4/ICW YWtW7tz81TjXAfQzIPMvs9S/msV1mN2C0Iaijc897vjtL44PxPY2KLeBvLNLGVfCoq4k upG+CH8Pca/Cc4Of5g2vN2ID8nKlLitC9NyhS59D6Ab5Y6gfI9sLBxOMoxyomlKhdLD/ QC3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GZd6jb/2"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv7si1221458ejb.451.2020.05.12.09.08.40; Tue, 12 May 2020 09:09:29 -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=@redhat.com header.s=mimecast20190719 header.b="GZd6jb/2"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbgELQD6 (ORCPT + 99 others); Tue, 12 May 2020 12:03:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34605 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725992AbgELQD6 (ORCPT ); Tue, 12 May 2020 12:03:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589299436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zOD1ZMsJH+6+YOeIeEjkmiXARILcJYCNRieBUs4BWZs=; b=GZd6jb/2sR594E4dl2zS22h9CmpAFV3BZ7Vw94z39Dx8wwdNTbUotVBh/rVj6c4nJmCx6E VlajLBXxqkoNE9i5df1CGWAOwBFurydW4lDiEhBWnqSxMbBq4e+f2/68Y1l1ecY6q2nwKP hHYCu7DhGCoex3sPgzWZcVllerah5js= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-ERroi7vNOuSCGEBY1tfB1Q-1; Tue, 12 May 2020 12:03:52 -0400 X-MC-Unique: ERroi7vNOuSCGEBY1tfB1Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC31A473; Tue, 12 May 2020 16:03:50 +0000 (UTC) Received: from lorien.usersys.redhat.com (ovpn-114-4.phx2.redhat.com [10.3.114.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2629B100EBAE; Tue, 12 May 2020 16:03:46 +0000 (UTC) Date: Tue, 12 May 2020 12:03:44 -0400 From: Phil Auld To: Vincent Guittot Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org, ouwen210@hotmail.com Subject: Re: [PATCH] sched/fair: fix unthrottle_cfs_rq for leaf_cfs_rq list Message-ID: <20200512160344.GC4256@lorien.usersys.redhat.com> References: <20200511191320.31854-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200511191320.31854-1-vincent.guittot@linaro.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 09:13:20PM +0200 Vincent Guittot wrote: > Although not exactly identical, unthrottle_cfs_rq() and enqueue_task_fair() > are quite close and follow the same sequence for enqueuing an entity in the > cfs hierarchy. Modify unthrottle_cfs_rq() to use the same pattern as > enqueue_task_fair(). This fixes a problem already faced with the latter and > add an optimization in the last for_each_sched_entity loop. > > Fixes: fe61468b2cb (sched/fair: Fix enqueue_task_fair warning) > Reported-by Tao Zhou > Signed-off-by: Vincent Guittot > --- > > This path applies on top of 20200507203612.GF19331@lorien.usersys.redhat.com > and fixes similar problem for unthrottle_cfs_rq() > > kernel/sched/fair.c | 37 ++++++++++++++++++++++++++++--------- > 1 file changed, 28 insertions(+), 9 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index e2450c2e0747..4b73518aa25c 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -4803,26 +4803,44 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) > idle_task_delta = cfs_rq->idle_h_nr_running; > for_each_sched_entity(se) { > if (se->on_rq) > - enqueue = 0; > + break; > + cfs_rq = cfs_rq_of(se); > + enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); > > + cfs_rq->h_nr_running += task_delta; > + cfs_rq->idle_h_nr_running += idle_task_delta; > + > + /* end evaluation on encountering a throttled cfs_rq */ > + if (cfs_rq_throttled(cfs_rq)) > + goto unthrottle_throttle; > + } > + > + for_each_sched_entity(se) { > cfs_rq = cfs_rq_of(se); > - if (enqueue) { > - enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); > - } else { > - update_load_avg(cfs_rq, se, 0); > - se_update_runnable(se); > - } > + > + update_load_avg(cfs_rq, se, UPDATE_TG); > + se_update_runnable(se); > > cfs_rq->h_nr_running += task_delta; > cfs_rq->idle_h_nr_running += idle_task_delta; > > + > + /* end evaluation on encountering a throttled cfs_rq */ > if (cfs_rq_throttled(cfs_rq)) > - break; > + goto unthrottle_throttle; > + > + /* > + * One parent has been throttled and cfs_rq removed from the > + * list. Add it back to not break the leaf list. > + */ > + if (throttled_hierarchy(cfs_rq)) > + list_add_leaf_cfs_rq(cfs_rq); > } > > if (!se) > add_nr_running(rq, task_delta); > > +unthrottle_throttle: > /* > * The cfs_rq_throttled() breaks in the above iteration can result in > * incomplete leaf list maintenance, resulting in triggering the > @@ -4831,7 +4849,8 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) > for_each_sched_entity(se) { > cfs_rq = cfs_rq_of(se); > > - list_add_leaf_cfs_rq(cfs_rq); > + if (list_add_leaf_cfs_rq(cfs_rq)) > + break; > } > > assert_list_leaf_cfs_rq(rq); > -- > 2.17.1 > I ran my reproducer test with this one as well. As expected, since the first patch fixed the issue I was seeing and I wasn't hitting the assert here anyway, I didn't hit the assert. But I also didn't hit any other issues, new or old. It makes sense to use the same logic flow here as enqueue_task_fair. Reviewed-by: Phil Auld Cheers, Phil --