Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1236294ybf; Thu, 27 Feb 2020 07:16:04 -0800 (PST) X-Google-Smtp-Source: APXvYqyxOJSU9wrRXvSGAvFYNjKeLRI332if0enfEqbZll10fdP7mlxMaT7xHdyVk4B601Z41Kl3 X-Received: by 2002:a9d:6a85:: with SMTP id l5mr87968otq.231.1582816564086; Thu, 27 Feb 2020 07:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582816564; cv=none; d=google.com; s=arc-20160816; b=zjX7KU61jK7WQ4SAGHnB0PLWXR4MN0c/dhk0Dlt4a93LN7Vo7Pty8smzA1vd93B8FA XsIFJ7XeasvBrUheV8ukghfJpnJTm1xCRY5zSN2lcklzL6F/zZ+w787LXFcT+krhd7ON MSE6BZZcuNxk2Uj+0T6/uvYGAOHXbTVYZ1dHo6I7/OEF+MPQu4dCqGdR/4o10aT0kayF mrREJskauo46GnIPAWAVmUt5jXfu9xXy3urT2S0kewEYhqyq+v96734uG4MjOqdzJdv4 qZRzqN5mJJu8WE43qKPux6rCO0uFQ4i4kVLolt/+Zqi9W7PUiTxMa3VdAkyFtCtZ5e/I urxA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/GCgihHkkPZzF0pccBI8H6Q+6MHrJ5TRNB0PQi3kIZk=; b=pAglVc60opXv6/H1UPTio3MRHJh2DT6MZKP/k11IUltl0oFcOKk/6fhdlqa0atHPK+ 2jbqSL6kMEF1bII4+VUrV0LicdjC/+FFEUm/nNdl+BSHkJcsUFurDM7xwl2b+gQSPahN O/pZpm/kK7j4hgxY2Mql5R4GvGgeeyKLWzQ/K6hi3X6uHgCKVveQY7j5mLbcls2OxAWu 5ELbG/X2uLdQ6Sgm3vCJrhRgaS55L4Su/ZAVLcVqZw7Psgx1JV9iYdMvC65yb1I/OEEe EghaiuiJRO4kZdopbi9Kk3s3UFHB8OJKvPTxCk42g5pv2P5V8obXir2t48cxlRbLdOC/ 91RQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i78si1554341oib.1.2020.02.27.07.15.47; Thu, 27 Feb 2020 07:16:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729708AbgB0PPl (ORCPT + 99 others); Thu, 27 Feb 2020 10:15:41 -0500 Received: from foss.arm.com ([217.140.110.172]:53446 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729174AbgB0PPl (ORCPT ); Thu, 27 Feb 2020 10:15:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92B3D31B; Thu, 27 Feb 2020 07:15:40 -0800 (PST) Received: from [10.0.8.126] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 83AD83F7B4; Thu, 27 Feb 2020 07:15:38 -0800 (PST) Subject: Re: [PATCH] sched/fair: fix runnable_avg for throttled cfs To: Vincent Guittot , Tao Zhou Cc: Ben Segall , Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Mel Gorman , linux-kernel , Phil Auld , Parth Shah , Valentin Schneider , Hillf Danton References: <20200226181640.21664-1-vincent.guittot@linaro.org> <8f72ea72-f36d-2611-e026-62ddff5c3422@arm.com> <20200227131228.GA5872@geo.homenetwork> From: Dietmar Eggemann Message-ID: Date: Thu, 27 Feb 2020 15:15:37 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.02.20 13:12, Vincent Guittot wrote: > On Thu, 27 Feb 2020 at 14:10, Tao Zhou wrote: >> >> Hi Dietmar, >> >> On Thu, Feb 27, 2020 at 11:20:05AM +0000, Dietmar Eggemann wrote: >>> On 26.02.20 21:01, Vincent Guittot wrote: >>>> On Wed, 26 Feb 2020 at 20:04, wrote: >>>>> >>>>> Vincent Guittot writes: >>>>> >>>>>> When a cfs_rq is throttled, its group entity is dequeued and its running >>>>>> tasks are removed. We must update runnable_avg with current h_nr_running >>>>>> and update group_se->runnable_weight with new h_nr_running at each level >>> >>> ^^^ >>> >>> Shouldn't his be 'curren' rather 'new' h_nr_running for >>> group_se->runnable_weight? IMHO, you want to cache the current value >>> before you add/subtract task_delta. >> >> /me think Vincent is right. h_nr_running is updated in the previous >> level or out. The next level will use current h_nr_running to update >> runnable_avg and use the new group cfs_rq's h_nr_running which was >> updated in the previous level or out to update se runnable_weight. Ah OK, 'old' as in 'old' cached value se->runnable_weight and 'new' as the 'new' se->runnable_weight which gets updated *after* update_load_avg and before +/- task_delta. So when we throttle e.g. /tg1/tg11 previous level is: /tg1/tg11 next level: /tg1 loop for /tg1: for_each_sched_entity(se) cfs_rq = cfs_rq_of(se); update_load_avg(cfs_rq, se ...) <-- uses 'old' se->runnable_weight se->runnable_weight = se->my_q->h_nr_running <-- 'new' value (updated in previous level, group cfs_rq) [...]