Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp339446imw; Fri, 15 Jul 2022 04:26:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vad0d4nUGNLboIOOv2X9+Y0kVqunLvoP0p7Qb9BrL6CZNsAF4zOfLmIrhCvXX8obw5FaVO X-Received: by 2002:a17:90a:a884:b0:1ef:8eb8:7473 with SMTP id h4-20020a17090aa88400b001ef8eb87473mr15091833pjq.161.1657884417919; Fri, 15 Jul 2022 04:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657884417; cv=none; d=google.com; s=arc-20160816; b=W+96xok4k/KSXdpsuiDTy2b59z/1AjxvO28yN0wuGJLgXghsYjwrku1cTbjxfuGf5Y kXWVBzy+tUqAHiUIWsG0nc5Lk4fjjCxL2c1lkud7TSFRTaCrMWvXLQjq0P9V8Pe/uQit cPmttP+S26jUBSrgKVfLUcOX9pcFa8KE9qp1dMQFZcJm5DMuNPXzvO3mszudILZf5KSt jBszMaRKgkW80y0Vv5MPY9p/RIxfR1DQu/cY3p1UPHdvXLwa+UNhLpbjsvktjXlEuVjn 3J+pVvd5T/xH+8xCluSEzLhR5KfpDksfrhidAvO5epH4nUJZ/oaObZcQrgM4Bbf35Qfa UfYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=+vypn0Bii5lUFUMrgnk5d19bQB1srHUtU7ws93VNKpo=; b=jLxfhwzdYeHwJl4L6AA3iUrIwkn9jzjk2m/tRuZUaJXnRhoiS6O8pV+Ho0OMfASR5p dzQ5HFBQOCnhhUynbWPDoFjif/LMSrVmdxX8fZYGarejbmWEJHO8ik2w5+ViYcFP404c mVoR38YOClrhOtfsjOSUBHDOUAaAl3k4NG2JjmJ/UCaGSPxKnlLfUxJln/Cg6bGur+hR qc9HPmWRX/J+qzKxsbuuw1ecfwQc7ASQe2sOpUZ4v22+Y7sVrYNbWRcbF7cLhfHKEoTX 2kmu7WUbkbIi/oWiDa9n88l7mQ/YNTShFemqlf3l8wDB7QY/kCeE7IpWG9EER7h3LPJX PhsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a63e448000000b0040c9e0a1ef5si4941198pgk.516.2022.07.15.04.26.42; Fri, 15 Jul 2022 04:26:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231653AbiGOLPj (ORCPT + 99 others); Fri, 15 Jul 2022 07:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiGOLPh (ORCPT ); Fri, 15 Jul 2022 07:15:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA83A87217 for ; Fri, 15 Jul 2022 04:15:35 -0700 (PDT) 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 E61961474; Fri, 15 Jul 2022 04:15:35 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F5EA3F73D; Fri, 15 Jul 2022 04:15:34 -0700 (PDT) Message-ID: <7eae9f41-7b33-2fc1-6b31-bbfd8d7b1364@arm.com> Date: Fri, 15 Jul 2022 13:15:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [External] Re: [PATCH v2 09/10] sched/fair: stop load tracking when task switched_from_fair() Content-Language: en-US To: Chengming Zhou , mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, rostedt@goodmis.org, bsegall@google.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org References: <20220713040430.25778-1-zhouchengming@bytedance.com> <20220713040430.25778-10-zhouchengming@bytedance.com> <27f0675e-8ac3-2200-749f-7290a256e3d9@arm.com> From: Dietmar Eggemann In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/07/2022 15:43, Chengming Zhou wrote: > On 2022/7/14 20:33, Dietmar Eggemann wrote: >> On 13/07/2022 06:04, Chengming Zhou wrote: [...] >> IMHO, a queued !fair task when switching back to fair will already be >> enqueued (attached) as a fair task in __sched_setscheduler() prior to >> the check_class_changed() call. > > Right, this is true for a queued !fair task, it will enqueued (attached) before > check_class_changed(). > > enqueue_task_fair() > enqueue_entity() > update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH) > if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) --> true > __update_load_avg_se(now, cfs_rq, se) --> (1) > check_class_changed() > switched_to_fair() > attach_task_cfs_rq() > attach_entity_cfs_rq() > update_load_avg(cfs_rq, se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD) > if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) --> true > __update_load_avg_se(now, cfs_rq, se) --> (2) > > > 1. for queued !fair: (1) delta = (now - last_update_time), last_update_time is the time > when switched_from_fair(). > > 2. for !queued !fair: (2) delta = (now - last_update_time), last_update_time is the time > when switched_from_fair(). > > The scenario in the commit message only cover !queued !fair case, I forget the queued !fair > case, their problem is the same. OK, that makes sense to me then. >> I can't see how this will work with your proposed change in using >> last_update_time=0 for fair->!fair->fair class changes? > If we reset last_update_time=0 for !fair task, then: > > 1. for queued !fair: will not do (1) since the if condition is false. > > 2. for !queued !fair: will not do (2) since the if condition is false. OK. [...] >>> This patch reset it's sched_avg last_update_time to 0, stop load >>> tracking for !fair task, later in switched_to_fair() -> >>> update_load_avg(), we can use its saved sched_avg. >>> >>> Signed-off-by: Chengming Zhou >>> --- >>> kernel/sched/fair.c | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>> index 50f65a2ede32..576028f5a09e 100644 >>> --- a/kernel/sched/fair.c >>> +++ b/kernel/sched/fair.c >>> @@ -11552,6 +11552,11 @@ static void attach_task_cfs_rq(struct task_struct *p) >>> static void switched_from_fair(struct rq *rq, struct task_struct *p) >>> { >>> detach_task_cfs_rq(p); >>> + >>> +#ifdef CONFIG_SMP >>> + /* Stop load tracking for !fair task */ You're not really stopping p->se load tracking by doing this. We don't do this outside fair anyway. IMHO, you freeze p->se's PELT _avg/_sum values to be used as initial values when re-entering fair. >>> + p->se.avg.last_update_time = 0; >>> +#endif >>> } >>> >>> static void switched_to_fair(struct rq *rq, struct task_struct *p)