Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp505325ybk; Wed, 13 May 2020 05:58:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoD4GGnC6HwFWOI4XCCPjhWiJDbzSvUz72xwzoKjS/8waR9CXEk6GkVnRNQEgMrZBTkQJU X-Received: by 2002:a17:907:7206:: with SMTP id dr6mr3234851ejc.149.1589374705102; Wed, 13 May 2020 05:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589374705; cv=none; d=google.com; s=arc-20160816; b=DSZnYNI/MWVWjhp+pWAN7Oad6Qzp1aNdlHoJuF5Rue2OxVv6ASrDd+KBYwgwgg0jtu YD4vUBjS/OkCn/LOXqpC/tB2YNKUoAnU4vEWcPYG1qMkHPPePWrTVmsSdZHd6oL+kggU JdGxtWSdKgVdmY3TCjH3nKo74Z8IbZKIK/NaZAclSuZhJEwAjpTmE4PX9lkqX2PpN5DZ IqyEwij1Ki8UsqnC7GP9LivWN7uxFsci/hZDrHbqSiVLAp+laD4dFrmWaZ6rEotDy+Oh 5byu6VwBzTn7Dy0BTJvHHlI4bn4s65cOx1o+PI0FQLfxNDyXhs/08jW1MC+SzkjMVdwt meXA== 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=Rg6JkW5pd+D3Jw1ike2ImD0WSry7w4HYlBO089Hj5fo=; b=Ud3V5Ikhc7b93MLbuEwWMOiPVvMak5bwv6pP6uw5nUtukF2iYYPuTk7VVC4WgyJbSn oZ/4ZRaweIdsOnf4Bwq74xJHyXX8kOZuxekYtUlyMEHUUu0tlpxMVn3upeTCAIVZAWoT coyGVJMg/kRhgVCpFNoX0M4idD8oRO6frJ0Mvis9xoc1OAkNzDfw87LUcX9ODqYDlq9K uQvTAjDsDyudiAsoCalQtKkekMWHcW6DqNPDM3oy35ZvgiqX60ru9tMsT54WFYKynQGE h+Rrf/KlJ/VPuqcgE+NCqb3orYvYOEAkRYjKyhpb340c8zZ/N37T4fS6HDWWl7tKFt2m pSUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=beYiwgyd; 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 h5si3042317eji.230.2020.05.13.05.58.01; Wed, 13 May 2020 05:58:25 -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=beYiwgyd; 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 S1733079AbgEMM4V (ORCPT + 99 others); Wed, 13 May 2020 08:56:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38522 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733058AbgEMM4S (ORCPT ); Wed, 13 May 2020 08:56:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589374576; 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=Rg6JkW5pd+D3Jw1ike2ImD0WSry7w4HYlBO089Hj5fo=; b=beYiwgydbZMA0AdjWKt6NwgSpHan2RIwTJiPK4lmXuGaNjbrlJyeldpelSjprOEEF2S7Ys CBHTaaw9+QSnS7jA2bfXqMliVNL9+z+bk/j0o9riaCao4BqWw1cN52N9wRvN4+4jcFNudC GSutHiECzbgZ9KO2A08PdN7qTMyFo6w= 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-294-IKGYLsVMMAyDhyUHlrG70w-1; Wed, 13 May 2020 08:56:13 -0400 X-MC-Unique: IKGYLsVMMAyDhyUHlrG70w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BE4F108BD0B; Wed, 13 May 2020 12:56:11 +0000 (UTC) Received: from lorien.usersys.redhat.com (ovpn-113-165.phx2.redhat.com [10.3.113.165]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52B9C2E033; Wed, 13 May 2020 12:56:02 +0000 (UTC) Date: Wed, 13 May 2020 08:56:00 -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, pkondeti@codeaurora.org Subject: Re: [PATCH v2] sched/fair: fix unthrottle_cfs_rq for leaf_cfs_rq list Message-ID: <20200513125600.GC12425@lorien.usersys.redhat.com> References: <20200513123422.28299-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200513123422.28299-1-vincent.guittot@linaro.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vincent, On Wed, May 13, 2020 at 02:34:22PM +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. > > Reported-by Tao Zhou > Reviewed-by: Phil Auld > Signed-off-by: Vincent Guittot > --- > > v2 changes: > - Remove useless if statement > > kernel/sched/fair.c | 41 ++++++++++++++++++++++++++++++----------- > 1 file changed, 30 insertions(+), 11 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 4e12ba882663..a0c690d57430 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -4816,26 +4816,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; Can probably drop the now-unused enqueue variable too. Cheers, Phil > + 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); > + /* At this point se is NULL and we are at root level*/ > + 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 > @@ -4844,7 +4862,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 > --