Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp384838imm; Tue, 15 May 2018 03:13:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpc7OAQD1j90yWI5OQNExb9Iegw9djLZyoMsJe4zNK/XAVdEMngbNUr8nJqZ3eDwjIuhD39 X-Received: by 2002:a63:7154:: with SMTP id b20-v6mr11668068pgn.13.1526379214148; Tue, 15 May 2018 03:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526379214; cv=none; d=google.com; s=arc-20160816; b=Y+5xCV6Pjw/3I+GxkUuFbAVK6PdPXyRXv+Qgs8lAzEwGvZTQTSo+BkNq32j1x4jKLb BOzk1SFMSlrX6ynb+qL+fi/J2Zcwm8eAZQ+45Race4SNhfEdVA1PQAH/lU1IE53UD0UF Q3K6U9y/YDR3adlYHwr4afdvUiSJVodSlBPgKl1BbKokDAgrUa3vpWXCRrHqG5bTqLEw yAtPipm+ubYwMhrJgRj78YsFLrS1uKAUHS9t4XiYYAX3twFLFVuM50wkpZhh6vBwWiVG 8Flvuafoz+NsKp94cCXRcig83uYMCrzgSa0sO7Uf/tR6DyAlfcd280W+FOZnSOpy5HJb JG9w== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=lPaNNINX4Abr9zwDcunjxbHQgmrmzGSIOCEvSSk7Mh8=; b=Zy8Q1qxEiAWGpKozh0RwGaPo12covrXFpbyVHm3VgKXgd4V0+TL4QNbgMnDpXfO5IE zTzM0lOVc07yHzOnLe5ybxyEsv+V55gg6IyCVH8rCO1GDfgn0vYxHOFXaPVeZToXvchG znJICOgYFpkCXAD6ayCoAhMt9gBrFO5QGPBVl5FyntL/gBAn7yYcwYdUAOf6YqfG41av bvL+HocbhPE9D7QvfHTY0giVH2iTptS49SzwAGLcFoQaxnyDD7FZLYsqSCXzqc+9Wbzu GhTuSeqglJBf2X10ARlViLK2gcEjtNpBHnGCBxRWzXiGQ7Ndzfe3xZmKuw8Slu9wtR7F 1W+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hgIqGd0J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6-v6si1620113pga.25.2018.05.15.03.13.19; Tue, 15 May 2018 03:13:34 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=hgIqGd0J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752813AbeEOKMp (ORCPT + 99 others); Tue, 15 May 2018 06:12:45 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:52278 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404AbeEOKMn (ORCPT ); Tue, 15 May 2018 06:12:43 -0400 Received: by mail-it0-f65.google.com with SMTP id y189-v6so17743671itb.2 for ; Tue, 15 May 2018 03:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lPaNNINX4Abr9zwDcunjxbHQgmrmzGSIOCEvSSk7Mh8=; b=hgIqGd0JJQ+UTWmXwAVOYd7zKwTOKFfdECPz930WJ6x2VEif935o93eOjP82Fr51pd 6Z9Jl1txXZPXi29PKJ7K0zDMsxvSxXuXtuQlVQG44CLT+RTj9RUnufWCdVaBu1CQurFZ eopHk0MCrJLu5/oaUUGt6nTt5BstZvTlCaEjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lPaNNINX4Abr9zwDcunjxbHQgmrmzGSIOCEvSSk7Mh8=; b=DIIjo0g0ZdY/Ym6/uq82oB0QYo72N5nrtREZKZDsXDZ9TQ80lJBDumNltmzReoo9YF aIQVoodrw52kh/OBSdZ4hukugNSB1XMTzzDSL1xCe9w0cGsADoeObOVC7DIMVPNECSEK RJRkUhlstaDlzkMKWq5+Pf73D+yP94ZkWa1pnk/XBo8AzAt0phFeF2v7wHlv8z+akDsc NyuhMnuxm/ELbEgjwzqmqNoVvQwaXTaUIFtOVq2KclmRVY4FbYUibBwnPN3qRlMJ4qos IRazDP3Xv4c7mOfMr92RXyyg3m9ZvnzsrhdMLO/ZquHwFGdqRomOUeMWKpl5Nx7enHXJ Ny5g== X-Gm-Message-State: ALKqPwfBrUGFyOMgCiy8y+BX/PyQ3zJY6MAdyiZjnCui84m+T/1l58xJ a1q/zYH6yO1r8LOx1ukHloJG7zj6as0SlppbIdjVWG/M X-Received: by 2002:a6b:b0d1:: with SMTP id z200-v6mr15644578ioe.196.1526379162503; Tue, 15 May 2018 03:12:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.4.204 with HTTP; Tue, 15 May 2018 03:12:22 -0700 (PDT) In-Reply-To: <20180511131509.16275-4-patrick.bellasi@arm.com> References: <20180511131509.16275-1-patrick.bellasi@arm.com> <20180511131509.16275-4-patrick.bellasi@arm.com> From: Vincent Guittot Date: Tue, 15 May 2018 12:12:22 +0200 Message-ID: Subject: Re: [PATCH v2 3/3] sched/fair: schedutil: explicit update only when required To: Patrick Bellasi Cc: linux-kernel , "open list:THERMAL" , Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Steve Muckle 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 Hi Patrick, On 11 May 2018 at 15:15, Patrick Bellasi wrote: > Schedutil updates for FAIR tasks are triggered implicitly each time a > cfs_rq's utilization is updated via cfs_rq_util_change(), currently > called by update_cfs_rq_load_avg(), when the utilization of a cfs_rq has > changed, and {attach,detach}_entity_load_avg(). > > This design is based on the idea that "we should callback schedutil > frequently enough" to properly update the CPU frequency at every > utilization change. However, such an integration strategy has also > some downsides: > > - schedutil updates are triggered by RQ's load updates, which makes > sense in general but it does not allow to know exactly which other RQ > related information have been updated. > Recently, for example, we had issues due to schedutil dependencies on > cfs_rq->h_nr_running and estimated utilization updates. > > - cfs_rq_util_change() is mainly a wrapper function for an already > existing "public API", cpufreq_update_util(), which is required > just to ensure we actually update schedutil only when we are updating > a root cfs_rq. > Thus, especially when task groups are in use, most of the calls to > this wrapper function are not required. > > - the usage of a wrapper function is not completely consistent across > fair.c, since we could still need additional explicit calls to > cpufreq_update_util(). > For example this already happens to report the IOWAIT boot flag in > the wakeup path. > > - it makes it hard to integrate new features since it could require to > change other function prototypes just to pass in an additional flag, > as it happened for example in commit: > > commit ea14b57e8a18 ("sched/cpufreq: Provide migration hint") > > All the above considered, let's make schedutil updates more explicit in > fair.c by removing the cfs_rq_util_change() wrapper function in favour > of the existing cpufreq_update_util() public API. removing the wrapper makes sense > This can be done by calling cpufreq_update_util() explicitly in the few > call sites where it really makes sense and when all the (potentially) > required cfs_rq's information have been updated. > > This patch mainly removes code and adds explicit schedutil updates > only when we: > - {enqueue,dequeue}_task_fair() a task to/from the root cfs_rq The task's utilization is added during attach/detach and not during the enqueue/dequeue. > - (un)throttle_cfs_rq() a set of tasks up to the root cfs_rq > - task_tick_fair() to update the utilization of the root cfs_rq > > All the other code paths, currently _indirectly_ covered by a call to > update_load_avg(), are still covered. Indeed, some paths already imply > enqueue/dequeue calls: > - switch_{to,from}_fair() > - sched_move_task() > while others are followed by enqueue/dequeue calls: > - cpu_cgroup_fork() and > post_init_entity_util_avg(): > are used at wakeup_new_task() time and thus already followed by an > enqueue_task_fair() > - migrate_task_rq_fair(): > updates the removed utilization but not the actual cfs_rq > utilization, which is updated by a following sched event The removed utilization will be applied during next call to update_cfs_rq_load_avg() which means at next call to update_load_avg() or update_blocked_averages() I'm going to continue on the longer reply that you made to Joel > > This new proposal allows also to better aggregate schedutil related > flags, which are required only at enqueue_task_fair() time. > IOWAIT and MIGRATION flags are now requested only when a task is > actually visible at the root cfs_rq level. > > Signed-off-by: Patrick Bellasi > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Rafael J. Wysocki > Cc: Viresh Kumar > Cc: Joel Fernandes > Cc: Juri Lelli > Cc: linux-kernel@vger.kernel.org > Cc: linux-pm@vger.kernel.org > > ---